Use #pragma omp simd for OpenMP 3.0 compilers (GH #787)

This commit is contained in:
Jeffrey Walton 2019-01-22 03:42:53 -05:00
parent 3f38a5f7dd
commit 8572541841
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 8 additions and 5 deletions

View File

@ -90,11 +90,12 @@ void Salsa20_Core(word32* data, unsigned int rounds)
x[15] ^= rotlConstant<18>(x[14]+x[13]); x[15] ^= rotlConstant<18>(x[14]+x[13]);
} }
#ifdef _MSC_VER // OpenMP 3.0 released May 2008.
#if _OPENMP >= 200805
#pragma omp simd
for (size_t i = 0; i < 16; ++i) for (size_t i = 0; i < 16; ++i)
data[i] += x[i]; data[i] += x[i];
#else #else
#pragma omp simd
for (size_t i = 0; i < 16; ++i) for (size_t i = 0; i < 16; ++i)
data[i] += x[i]; data[i] += x[i];
#endif #endif

View File

@ -64,11 +64,12 @@ static inline void BlockCopy(byte* dest, byte* src, size_t len)
static inline void BlockXOR(byte* dest, byte* src, size_t len) static inline void BlockXOR(byte* dest, byte* src, size_t len)
{ {
#ifdef _MSC_VER // OpenMP 3.0 released May 2008.
#if _OPENMP >= 200805
#pragma omp simd
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
dest[i] ^= src[i]; dest[i] ^= src[i];
#else #else
#pragma omp simd
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
dest[i] ^= src[i]; dest[i] ^= src[i];
#endif #endif

View File

@ -547,7 +547,8 @@ void PrintSeedAndThreads()
tc = omp_get_num_threads(); tc = omp_get_num_threads();
} }
std::cout << "Using " << tc << " OMP " << (tc == 1 ? "thread" : "threads") << std::endl; std::cout << "OpenMP version " << (int)_OPENMP << ", ";
std::cout << tc << (tc == 1 ? " thread" : "threads") << std::endl;
#endif #endif
} }