Filter löschen
Filter löschen

AVX Programming, how to do within C mex file

9 Ansichten (letzte 30 Tage)
Alain Barraud
Alain Barraud am 25 Okt. 2023
Verschoben: Walter Roberson am 26 Okt. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Okt. 2023
Verschoben: Walter Roberson am 26 Okt. 2023
  1 Kommentar
Alain Barraud
Alain Barraud am 25 Okt. 2023
Verschoben: Walter Roberson am 26 Okt. 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by