From c498f01b211d6db50963a1f61857e07ec452e082 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Sat, 16 Mar 2024 13:00:31 +0100 Subject: [PATCH] Simplify OpenMP clause to avoid compiler bugs Issues were encountered when using NVC++ compiler and ScoreP wrapper. Those are compiler bugs, but extracting the chunk size not only avoids the problem, but also makes the code (subjectively) easier to read. --- src/muParserBase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/muParserBase.cpp b/src/muParserBase.cpp index 5ffbb49..1ee8875 100644 --- a/src/muParserBase.cpp +++ b/src/muParserBase.cpp @@ -1903,7 +1903,8 @@ namespace mu #endif omp_set_num_threads(nMaxThreads); -#pragma omp parallel for schedule(static, std::max(nBulkSize/nMaxThreads, 1)) private(nThreadID) + const int chunkSize = std::max(nBulkSize/nMaxThreads, 1); +#pragma omp parallel for schedule(static, chunkSize) private(nThreadID) for (i = 0; i < nBulkSize; ++i) { nThreadID = omp_get_thread_num();