MadHatter
MadHatter

Reputation: 351

gcc header error: '_mm256_set_m128d' was not declared in this scope

I'm trying to compile a large code that was compiled with icpc and mkl math libraries using gcc instead.

Here is the code that needs AVX.

#include <immintrin.h>
#include <stdint.h>
#include <math.h>
.
.

_mm256_set_m128d(  _mm256_extractf128_pd(t2, 0) + _mm256_extractf128_pd(t2, 1),
                                        _mm256_extractf128_pd(t1, 0) + _mm256_extractf128_pd(t1, 1));

I have -mavx flag enabled when compiling, as suggested on some posts to enable advanced vectorization. _mm256_set_m128d is not defined in immintrin.h or any other in gcc include files (version 5.3).

I found that its available for intel headers though - in immintrin.h header provided with intel compiler.

Any suggestions how to fix this issue? Thanks!

Upvotes: 2

Views: 2044

Answers (1)

Paul R
Paul R

Reputation: 212969

You can just define your own macro like this:

#define _mm256_set_m128d(vh, vl) \
        _mm256_insertf128_pd(_mm256_castpd128_pd256(vl), (vh), 1)

Bracket it inside a suitable #ifdef/#endif so that it's only defined for gcc of course.

Upvotes: 1

Related Questions