Borrar filtros
Borrar filtros

AVX Programming, how to do within C mex file

9 visualizaciones (últimos 30 días)
Alain Barraud
Alain Barraud el 25 de Oct. de 2023
Movida: Walter Roberson el 26 de Oct. de 2023
Hi everybody, fma operations or more generally using avx programming may be very usefull on some circonstancies, better accuracy within dot product for example, faster execution of unrolled loop as blas routines do,....
Is it possible to use this approach within C mex file? Is it nessessary to add specific compilation options at mex command?
Any help or hints about this subject will be great. I have not the fixed-point designer toolbox which probably answers to my question. However I don't use any fixed-point arithmetic.
Best regards
Alain

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Oct. de 2023
Movida: Walter Roberson el 26 de Oct. de 2023
  1 comentario
Alain Barraud
Alain Barraud el 25 de Oct. de 2023
Movida: Walter Roberson el 26 de Oct. de 2023
Following your answer AVX.c contains a fma basic test
__m256d veca = _mm256_setr_pd(6.0, 6.0, 6.0, 6.0);
__m256d vecb = _mm256_setr_pd(2.0, 2.0, 2.0, 2.0);
__m256d vecc = _mm256_setr_pd(7.0, 7.0, 7.0, 7.0);
__m256d resultat = _mm256_fmaddsub_pd(veca, vecb, vecc);
double* res = (double*)&resultat;
wihin an appropriate mex gateway with some includes as follows
#include <immintrin.h>
#include <stdio.h>
#include "mex.h"
#include "matrix.h"
mex COMPFLAGS='$COMPFLAGS /arch:AVX2' AVX.c
Building with 'Microsoft Visual C++ 2019 (C)'.
MEX completed successfully.
I obtain the attended results

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by