Skip to content
Snippets Groups Projects
Commit fd1da301 authored by Neil Vaytet's avatar Neil Vaytet
Browse files

Refs #20443 : Reverted to OMP schedule(static)

parent deab8bb2
No related branches found
No related tags found
No related merge requests found
......@@ -165,17 +165,19 @@ join(ITERATOR_TYPE begin, ITERATOR_TYPE end, const std::string &separator,
// Initialise ostringstream
std::ostringstream thread_stream;
// Compute loop start and stop for current thread
int nchunk = dist / nThreads;
int nstart = nchunk * idThread;
int nextra = dist % nchunk;
if (idThread < nextra)
nchunk++;
nstart += std::min(idThread % nThreads, nextra);
int nstop = nstart + nchunk;
// Write to ostringstream for this thread
for (int i = nstart; i < nstop; i++) {
/* To make sure the loop is done in the right order, we use schedule(static).
From the OpenMP documentation:
"When schedule(static, chunk_size) is specified, iterations are divided into
chunks of size chunk_size, and the chunks are assigned to the threads in the
team in a round-robin fashion **in the order of the thread number**."
"When no chunk_size is specified, the iteration space is divided into chunks
that are approximately equal in size, and at most one chunk is distributed to
each thread."
*/
#pragma omp for schedule(static)
for (int i = 0; i < dist; i++) {
thread_stream << separator << *(begin + i);
}
output[idThread] = thread_stream.str();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment