vec_absADD TO COMPARE ADDED TO COMPARE
IBM-Z (64 bits)/ IBM-Z
View official documentation
Location:
Arithmetic
>
Vector Absolute Value
Purpose:
Returns a vector containing the absolute values of the contents of the given vector. The value of each element of the result is the absolute value of the corresponding element of a. Note: vector float and vector double will not cause IEEE exception. Minimum Arch: Z12.
Prototypes
Usage:
vector signed short result =
vec_abs(
vector signed short a
)
Example:
#include <stdio.h>
#include <vecintrin.h>
int main() {
vector signed short a = {
-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000
};
vector signed short d = vec_abs(a);
signed short *a_array = (signed short*)&a;
signed short *d_array = (signed short*)&d;
for (int i = 0; i < 8; i++) {
printf("abs(%d) = %d\n", a_array[i], d_array[i]);
}
return 0;
}
Usage:
vector signed int result =
vec_abs(
vector signed int a
)
Example:
#include <stdio.h>
#include <vecintrin.h>
int main() {
vector signed int a = {
-1000000, 2000000, -3000000, 4000000
};
vector signed int d = vec_abs(a);
signed int *a_array = (signed int*)&a;
signed int *d_array = (signed int*)&d;
for (int i = 0; i < 4; i++) {
printf("abs(%d) = %d\n", a_array[i], d_array[i]);
}
return 0;
}
Usage:
vector signed char result =
vec_abs(
vector signed char a
)
Example:
#include <stdio.h>
__vector signed char a = {
-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16
};
vec_st(result, 0, output);
for (int i = 0; i < 16; i++) {
}
}
Usage:
vector unsigned long long result =
vec_abs(
vector unsigned long long a
)
Example:
#include <stdio.h>
#include <vecintrin.h>
int main() {
vector signed long long a = {
-10000000000LL, 20000000000LL
};
vector signed long long d = vec_abs(a);
signed long long *a_array = (signed long long*)&a;
signed long long *d_array = (signed long long*)&d;
for (int i = 0; i < 2; i++) {
printf("abs(%lld) = %lld\n", a_array[i], d_array[i]);
}
return 0;
}
Usage:
vector double result =
vec_abs(
vector double a
)
Example:
#include <stdio.h>
#include <vecintrin.h>
int main() {
vector double a = {
-10.5, 20.3
};
vector double d = vec_abs(a);
double *a_array = (double*)&a;
double *d_array = (double*)&d;
for (int i = 0; i < 2; i++) {
printf("abs(%.1f) = %.1f\n", a_array[i], d_array[i]);
}
return 0;
}
Usage:
vector float result =
vec_abs(
vector float a
)
Example:
#include <stdio.h>
#include <vecintrin.h>
int main() {
vector float a = {
-10.5f, 20.3f, -15.7f, 25.1f
};
vector float d = vec_abs(a);
float *a_array = (float*)&a;
float *d_array = (float*)&d;
for (int i = 0; i < 4; i++) {
printf("abs(%.1f) = %.1f\n", a_array[i], d_array[i]);
}
return 0;
}
SIMD Intrinsics Summary
| SIMD Engines: | 6 |
| C Intrinsics: | 10444 |
| NEON: | 4353 |
| AVX2: | 405 |
| AVX512: | 4717 |
| SSE4.2: | 598 |
| VSX: | 192 |
| IBM-Z: | 179 |