How do I eliminate temporaries in vectorized code generation?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I'm using Matlab Coder to turn some matlab code into vectorized C code.
In general, my matlab script runs elementwise transformations on the same arrays without changing their shape:
X = Foo(Y)
Z = Bar(X)
When I compile this with matlab coder with no replacement libraries, each function does its work directly on the X and Y arrays, which is great.
But when I try to enable SIMD vectorization for an x64 target (IPP libraries with AVX instructions from Embedded Coder), it generates a temporary within each function which is aligned to 32 bytes (a requirement for the IPP library?), does the vectorized transformations on that, then copies it to the output array.
__declspec(align(32)) float fv3[4096];
It's understandable if this alignment is needed for vectorization, but the extra memory and the copy operation seem really inefficient, and I'd like to avoid them.
Is there a way to get rid of these temporaries automatically?
Maybe some way to hint to Matlab coder that my my arrays (X,Y, and Z) should be aligned to 32 bytes, and then change the code replacement library so it doesn't generate this temporary?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!