Aussie AI
AVX-512 SIMD Multiplication
-
Book Excerpt from "Generative AI in C++"
-
by David Spuler, Ph.D.
AVX-512 SIMD Multiplication
Here is the basic 16 float SIMD vector multiplication using 512-bits in AVX-512.
void aussie_avx512_multiply_16_floats(
float v1[16], float v2[16], float vresult[16])
{
// Multiply 16x32-bit floats in 512-bit registers
__m512 r1 = _mm512_loadu_ps(v1); // Load 16 floats
__m512 r2 = _mm512_loadu_ps(v2);
__m512 dst = _mm512_mul_ps(r1, r2); // Multiply (SIMD)
_mm512_storeu_ps(vresult, dst); // Convert to floats
}
Note that AVX-512 will fail with an “unhandled exception: illegal instruction” (e.g. in MSVS) if AVX-512 is not supported on your CPU.
|
• Next: • Up: Table of Contents |
|
The new AI programming book by Aussie AI co-founders:
Get your copy from Amazon: Generative AI in C++ |