필터 지우기
필터 지우기

AVX Programming, how to do within C mex file

조회 수: 9 (최근 30일)
Alain Barraud
Alain Barraud 2023년 10월 25일
이동: Walter Roberson 2023년 10월 26일
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

채택된 답변

Walter Roberson
Walter Roberson 2023년 10월 25일
이동: Walter Roberson 2023년 10월 26일
  댓글 수: 1
Alain Barraud
Alain Barraud 2023년 10월 25일
이동: Walter Roberson 2023년 10월 26일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by