vec_mulADD TO COMPARE ADDED TO COMPARE
IBM Power 9 64-bit (64 bits)/ VSX
View official documentation
Location:
Arithmetic
>
Vector Multiply
Purpose:
Compute the products of corresponding elements of two vectors.
Result:
A 128-bit vector of 16 x 8-bit/8 x 16-bit/4 x 32-bit/2 x 64-bit signed integers, or 4 x 32-bit single-precision/2 x 64-bit double-precision floating-point numbers that hold the result of the multiplication.
Prototypes
Assembly Instruction:
scalarized
Usage:
vector signed long long output =
vec_mul(
vector signed long long a, vector signed long long b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector signed long long a = {
1LL, 2LL, 3LL, 4LL
};
vector signed long long b = {
4LL, 3LL, 2LL, 1LL
};
vector signed long long result = vec_mul(a, b);
long long* res = (long long*)&result;
for(int i = 0; i < 4; i++) {
printf("%lld ", res[i]);
}
return 0;
}
Assembly Instruction:
vmuluwm
Usage:
vector signed int output =
vec_mul(
vector signed int a, vector signed int b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector signed int a = {
1, 2, 3, 4
};
vector signed int b = {
4, 3, 2, 1
};
vector signed int result = vec_mul(a, b);
int* res = (int*)&result;
for(int i = 0; i < 4; i++) {
printf("%d ", res[i]);
}
return 0;
}
Assembly Instruction:
scalarized
Usage:
vector unsigned long long output =
vec_mul(
vector unsigned long long a, vector unsigned long long b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector unsigned long long a = {
1ULL, 2ULL, 3ULL, 4ULL
};
vector unsigned long long b = {
4ULL, 3ULL, 2ULL, 1ULL
};
vector unsigned long long result = vec_mul(a, b);
unsigned long long* res = (unsigned long long*)&result;
for(int i = 0; i < 4; i++) {
printf("%llu ", res[i]);
}
return 0;
}
Assembly Instruction:
xvmulsp
Usage:
vector float output =
vec_mul(
vector float a, vector float b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector float a = {
1.0f, 2.0f, 3.0f, 4.0f
};
vector float b = {
4.0f, 3.0f, 2.0f, 1.0f
};
vector float result = vec_mul(a, b);
float* res = (float*)&result;
for(int i = 0; i < 4; i++) {
printf("%f ", res[i]);
}
return 0;
}
Assembly Instruction:
xvmuldp
Usage:
vector unsigned short output =
vec_mul(
vector unsigned short a, vector unsigned short b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector unsigned short a = {
1, 2, 3, 4, 5, 6, 7, 8
};
vector unsigned short b = {
8, 7, 6, 5, 4, 3, 2, 1
};
vector unsigned short result = vec_mul(a, b);
unsigned short* res = (unsigned short*)&result;
for(int i = 0; i < 8; i++) {
printf("%u ", res[i]);
}
return 0;
}
Assembly Instruction:
xvmuldp
Usage:
vector unsigned char output =
vec_mul(
vector unsigned char a, vector unsigned char b
)
Example:
Assembly Instruction:
xvmuldp
Usage:
vector signed short output =
vec_mul(
vector signed short a, vector signed short b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector signed short a = {
1, 2, 3, 4, 5, 6, 7, 8
};
vector signed short b = {
8, 7, 6, 5, 4, 3, 2, 1
};
vector signed short result = vec_mul(a, b);
short* res = (short*)&result;
for(int i = 0; i < 8; i++) {
printf("%d ", res[i]);
}
return 0;
}
Assembly Instruction:
xvmuldp
Usage:
vector double output =
vec_mul(
vector double a, vector double b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector double a = {
1.0, 2.0
};
vector double b = {
3.0, 4.0
};
vector double result = vec_mul(a, b);
double* res = (double*)&result;
for(int i = 0; i < 2; i++) {
printf("%f ", res[i]);
}
return 0;
}
Assembly Instruction:
vmuluwm
Usage:
vector unsigned int output =
vec_mul(
vector unsigned int a, vector unsigned int b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector unsigned int a = {
1, 2, 3, 4
};
vector unsigned int b = {
4, 3, 2, 1
};
vector unsigned int result = vec_mul(a, b);
unsigned int* res = (unsigned int*)&result;
for(int i = 0; i < 4; i++) {
printf("%u ", res[i]);
}
return 0;
}
Assembly Instruction:
xvmuldp
Usage:
vector signed char output =
vec_mul(
vector signed char a, vector signed char b
)
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
vector signed char a = {
1, 2, 3, 4, 5, 6, 7, 8
};
vector signed char b = {
8, 7, 6, 5, 4, 3, 2, 1
};
vector signed char result = vec_mul(a, b);
char* res = (char*)&result;
for(int i = 0; i < 8; i++) {
printf("%d ", res[i]);
}
return 0;
}
DB statistics
SIMD Engines: | 5 |
C Intrinsics: | 10702 |
NEON: | 4232 |
AVX2: | 462 |
AVX512: | 4955 |
SSE4.2: | 652 |
VSX: | 401 |