40 template<
class ListType>
46 label nThreads = 3 * omp_get_num_procs();
50 const label nThreads(1);
58 # pragma omp parallel num_threads(nThreads)
62 label& nLocalEntries = procEntries[omp_get_thread_num()];
64 label& nLocalEntries = procEntries[0];
69 # pragma omp for schedule(static)
72 nLocalEntries +=
s[i];
77 nEntries += nLocalEntries;
94 for(
label i=0;i<omp_get_thread_num();++i)
95 start += procEntries[i];
99 # pragma omp for schedule(static)
110 template<
class GraphType>
117 label nThreads = 3 * omp_get_num_procs();
118 if( origGraph.size() < 1000 )
121 const label nThreads(1);
124 label minRow(INT_MAX), maxRow(-1);
128 # pragma omp parallel num_threads(nThreads)
132 const label threadI = omp_get_thread_num();
134 const label threadI(0);
138 dot.setSize(nThreads);
142 label localMinRow(INT_MAX), localMaxRow(-1);
144 # pragma omp for schedule(static)
148 forAll(origGraph[rowI], i)
150 const label entryI = origGraph[rowI][i];
151 localMaxRow =
Foam::max(localMaxRow, entryI);
152 localMinRow =
Foam::min(localMinRow, entryI);
159 # pragma omp critical
172 # pragma omp for schedule(static)
174 for(
label i=0;i<maxRow;++i)
181 const label range = (maxRow - minRow) / nThreads + 1;
187 # pragma omp for schedule(static)
191 forAll(origGraph[rowI], j)
193 const label entryI = origGraph[rowI][j];
195 const label threadNo = (entryI - minRow) /
range;
197 if( threadNo == threadI )
199 ++nAppearances[entryI];
213 for(
label i=0;i<nThreads;++i)
216 dataForOtherThreads[i][threadI];
219 ++nAppearances[
data[j].first()];
241 for(
label i=0;i<threadI;++i)
244 dataForOtherThreads[i][threadI];
249 graph_(entryI, nAppearances[entryI]++) =
data[j].second();
255 # pragma omp for schedule(static)
259 forAll(origGraph[rowI], j)
261 const label entryI = origGraph[rowI][j];
264 graph_(entryI, nAppearances[entryI]++) = rowI;
269 for(
label i=threadI+1;i<nThreads;++i)
272 dataForOtherThreads[i][threadI];
277 graph_(entryI, nAppearances[entryI]++) =
data[j].second();
283 template<
class ListType,
class GraphType>
286 const ListType& mapper,
287 const GraphType& origGraph
290 ListType nAppearances;
293 label nThreads = 3 * omp_get_num_procs();
294 if( origGraph.size() < 1000 )
297 const label nThreads(1);
300 label minRow(INT_MAX), maxRow(-1);
304 # pragma omp parallel num_threads(nThreads)
308 const label threadI = omp_get_thread_num();
310 const label threadI(0);
314 dot.setSize(nThreads);
318 label localMinRow(INT_MAX), localMaxRow(-1);
320 # pragma omp for schedule(static)
324 forAll(origGraph[rowI], i)
326 const label entryI = mapper[origGraph[rowI][i]];
327 localMaxRow =
Foam::max(localMaxRow, entryI);
328 localMinRow =
Foam::min(localMinRow, entryI);
335 # pragma omp critical
340 nAppearances.setSize(maxRow);
347 # pragma omp for schedule(static)
349 for(
label i=0;i<maxRow;++i)
356 const label range = (maxRow - minRow) / nThreads + 1;
362 # pragma omp for schedule(static)
366 forAll(origGraph[rowI], i)
368 const label entryI = mapper[origGraph[rowI][i]];
370 const label threadNo = (entryI - minRow) /
range;
372 if( threadNo == threadI )
374 ++nAppearances[entryI];
388 for(
label i=0;i<nThreads;++i)
391 dataForOtherThreads[i][threadI];
394 ++nAppearances[
data[j].first()];
404 setSizeAndRowSize(nAppearances);
418 for(
label i=0;i<threadI;++i)
421 dataForOtherThreads[i][threadI];
426 graph_(entryI, nAppearances[entryI]++) =
data[j].second();
432 # pragma omp for schedule(static)
436 forAll(origGraph[rowI], j)
438 const label entryI = mapper[origGraph[rowI][j]];
441 graph_(entryI, nAppearances[entryI]++) = rowI;
446 for(
label i=threadI+1;i<nThreads;++i)
449 dataForOtherThreads[i][threadI];
454 graph_(entryI, nAppearances[entryI]++) =
data[j].second();
460 template<
class ListType>
463 const ListType& mapper,
467 ListType nAppearances;
470 label nThreads = 3 * omp_get_num_procs();
471 if( origGraph.
size() < 1000 )
474 const label nThreads(1);
477 label minRow(INT_MAX), maxRow(-1);
481 # pragma omp parallel num_threads(nThreads)
485 const label threadI = omp_get_thread_num();
487 const label threadI(0);
491 dot.setSize(nThreads);
495 label localMinRow(INT_MAX), localMaxRow(-1);
497 # pragma omp for schedule(static)
503 const label entryI = mapper[origGraph(rowI, i)];
504 localMaxRow =
Foam::max(localMaxRow, entryI);
505 localMinRow =
Foam::min(localMinRow, entryI);
512 # pragma omp critical
517 nAppearances.setSize(maxRow);
524 # pragma omp for schedule(static)
526 for(
label i=0;i<maxRow;++i)
533 const label range = (maxRow - minRow) / nThreads + 1;
539 # pragma omp for schedule(static)
545 const label entryI = mapper[origGraph(rowI, i)];
547 const label threadNo = (entryI - minRow) /
range;
549 if( threadNo == threadI )
551 ++nAppearances[entryI];
565 for(
label i=0;i<nThreads;++i)
568 dataForOtherThreads[i][threadI];
571 ++nAppearances[
data[j].first()];
581 setSizeAndRowSize(nAppearances);
592 for(
label i=0;i<threadI;++i)
595 dataForOtherThreads[i][threadI];
600 graph_(entryI, nAppearances[entryI]++) =
data[j].second();
606 # pragma omp for schedule(static)
612 const label entryI = mapper[origGraph(rowI, j)];
615 graph_(entryI, nAppearances[entryI]++) = rowI;
620 for(
label i=threadI+1;i<nThreads;++i)
623 dataForOtherThreads[i][threadI];
628 graph_(entryI, nAppearances[entryI]++) =
data[j].second();