AVX Programming, how to do within C mex file

7 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 25 Ott 2023
Spostato: Walter Roberson il 26 Ott 2023
  1 Commento
Alain Barraud
Alain Barraud il 25 Ott 2023
Spostato: Walter Roberson il 26 Ott 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

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by