From 8572541841898d88d36d2f8f275d8e8ed6a81a72 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 22 Jan 2019 03:42:53 -0500 Subject: [PATCH] Use #pragma omp simd for OpenMP 3.0 compilers (GH #787) --- salsa.cpp | 5 +++-- scrypt.cpp | 5 +++-- test.cpp | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/salsa.cpp b/salsa.cpp index fb2dc03e..eacdabe7 100644 --- a/salsa.cpp +++ b/salsa.cpp @@ -90,11 +90,12 @@ void Salsa20_Core(word32* data, unsigned int rounds) 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) data[i] += x[i]; #else - #pragma omp simd for (size_t i = 0; i < 16; ++i) data[i] += x[i]; #endif diff --git a/scrypt.cpp b/scrypt.cpp index 859d6822..7c1b9e84 100644 --- a/scrypt.cpp +++ b/scrypt.cpp @@ -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) { -#ifdef _MSC_VER +// OpenMP 3.0 released May 2008. +#if _OPENMP >= 200805 + #pragma omp simd for (size_t i = 0; i < len; ++i) dest[i] ^= src[i]; #else - #pragma omp simd for (size_t i = 0; i < len; ++i) dest[i] ^= src[i]; #endif diff --git a/test.cpp b/test.cpp index 6ffd7e6e..8b970a22 100644 --- a/test.cpp +++ b/test.cpp @@ -547,7 +547,8 @@ void PrintSeedAndThreads() 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 }