Skip to content

Commit

Permalink
modified some flags of parallelize() to force (in the 'smart tpoll' m…
Browse files Browse the repository at this point in the history
…ode) use of the max available number of threads, or other variant.
  • Loading branch information
GillesDuvert committed Aug 29, 2023
1 parent 1105b1f commit 783b3fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/datatypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ BaseGDL* Data_<Sp>::Transpose(DUInt* perm) { TRACE_ROUTINE(__FUNCTION__,__FILE__
long chunksize = nElem;
long nchunk = 1;
bool do_parallel = false;
GDL_NTHREADS=parallelize( nElem, TP_MEMORY_ACCESS);
GDL_NTHREADS=parallelize( nElem, TP_CPU_INTENSIVE);
if (GDL_NTHREADS > 1) { //no use start parallel threading for small numbers.
chunksize = nElem / GDL_NTHREADS;
nchunk = nElem / chunksize;
Expand Down Expand Up @@ -1491,7 +1491,7 @@ void Data_<Sp>::Reverse(DLong dim) { TRACE_ROUTINE(__FUNCTION__,__FILE__,__LINE_
if (this->dim[dim]%2) halfDim++;
SizeT outerStride = this->dim.Stride(dim + 1);
SizeT span=outerStride - revStride;
if ((GDL_NTHREADS=parallelize(nEl, TP_MEMORY_ACCESS))==1) { //most frequent
if ((GDL_NTHREADS=parallelize(nEl, TP_CPU_INTENSIVE))==1) { //most frequent
for (SizeT o = 0; o < nEl; o += outerStride) {
for (SizeT i = o; i < o+revStride; ++i) {
for (SizeT s = i, opp=span+i; s < halfDim+i ; s += revStride, opp-=revStride) {
Expand Down Expand Up @@ -1529,7 +1529,7 @@ BaseGDL* Data_<Sp>::DupReverse(DLong dim) { TRACE_ROUTINE(__FUNCTION__,__FILE__,
if (this->dim[dim]%2) halfDim++;
SizeT outerStride = this->dim.Stride(dim + 1);
SizeT span=outerStride - revStride;
if ((GDL_NTHREADS=parallelize(nEl, TP_MEMORY_ACCESS))==1) { //most frequent
if ((GDL_NTHREADS=parallelize(nEl, TP_CPU_INTENSIVE))==1) { //most frequent
for (SizeT o = 0; o < nEl; o += outerStride) {
for (SizeT i = o; i < o+revStride; ++i) {
for (SizeT s = i, opp=span+i; s < halfDim+i ; s += revStride, opp-=revStride) {
Expand Down Expand Up @@ -1569,7 +1569,7 @@ BaseGDL* Data_<SpDPtr>::DupReverse(DLong dim) {
if (this->dim[dim] % 2) halfDim++;
SizeT outerStride = this->dim.Stride(dim + 1);
SizeT span = outerStride - revStride;
if ((GDL_NTHREADS=parallelize(nEl, TP_MEMORY_ACCESS)) == 1) { //most frequent
if ((GDL_NTHREADS=parallelize(nEl, TP_CPU_INTENSIVE)) == 1) { //most frequent
for (SizeT o = 0; o < nEl; o += outerStride) {
for (SizeT i = o; i < o + revStride; ++i) {
for (SizeT s = i, opp = span + i; s < halfDim + i; s += revStride, opp -= revStride) {
Expand Down Expand Up @@ -1611,7 +1611,7 @@ BaseGDL* Data_<SpDObj>::DupReverse(DLong dim) {
if (this->dim[dim] % 2) halfDim++;
SizeT outerStride = this->dim.Stride(dim + 1);
SizeT span = outerStride - revStride;
if ((GDL_NTHREADS=parallelize(nEl, TP_MEMORY_ACCESS)) == 1) { //most frequent
if ((GDL_NTHREADS=parallelize(nEl, TP_CPU_INTENSIVE)) == 1) { //most frequent
for (SizeT o = 0; o < nEl; o += outerStride) {
for (SizeT i = o; i < o + revStride; ++i) {
for (SizeT s = i, opp = span + i; s < halfDim + i; s += revStride, opp -= revStride) {
Expand Down Expand Up @@ -3823,7 +3823,7 @@ void Data_<Sp>::CatInsert (const Data_* srcArr, const SizeT atDim, SizeT& at)
SizeT gap = this->dim.Stride (atDim + 1); // dest array

//GD: speed up by using indexing that permit parallel and collapse.
if ((GDL_NTHREADS=parallelize( len*nCp, TP_MEMORY_ACCESS))==1) { //most frequent
if ((GDL_NTHREADS=parallelize( len*nCp, TP_CPU_INTENSIVE))==1) { //most frequent
for (OMPInt c = 0; c < nCp; ++c) {
for (SizeT destIx = 0; destIx < len; destIx++) (*this)[destIx + destStart + c * gap] = (*srcArr)[ destIx + c * len];
}
Expand Down
12 changes: 6 additions & 6 deletions src/math_fun_jmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ namespace lib {
}

/* Double loop on the output image */
if ((GDL_NTHREADS=parallelize( nEl))==1) {
if ((GDL_NTHREADS=parallelize( nEl, TP_CPU_INTENSIVE))==1) {
for (OMPInt j = 0; j < nRows; ++j) {
for (OMPInt i = 0; i < nCols; ++i) {
// Compute the original source for this pixel, note order of j and i in P and Q definition of IDL doc.
Expand Down Expand Up @@ -1027,7 +1027,7 @@ namespace lib {
}

/* Double loop on the output image */
if ((GDL_NTHREADS=parallelize( nEl))==1) {
if ((GDL_NTHREADS=parallelize( nEl, TP_CPU_INTENSIVE))==1) {
for (OMPInt j = 0; j < nRows; ++j) {
for (OMPInt i = 0; i < nCols; ++i) {
// Compute the original source for this pixel, note order of j and i in P and Q definition of IDL doc.
Expand Down Expand Up @@ -1225,7 +1225,7 @@ namespace lib {
}

/* Double loop on the output image */
if ((GDL_NTHREADS=parallelize( nEl))==1) {
if ((GDL_NTHREADS=parallelize( nEl, TP_CPU_INTENSIVE))==1) {
for (OMPInt j = 0; j < nRows; ++j) {
for (OMPInt i = 0; i < nCols; ++i) {
// Compute the original source for this pixel, note order of j and i in P and Q definition of IDL doc.
Expand Down Expand Up @@ -1373,7 +1373,7 @@ namespace lib {
}

/* Double loop on the output image */
if ((GDL_NTHREADS=parallelize( nEl))==1) {
if ((GDL_NTHREADS=parallelize( nEl, TP_CPU_INTENSIVE))==1) {
for (OMPInt j = 0; j < nRows; ++j) {
for (OMPInt i = 0; i < nCols; ++i) {
// Compute the original source for this pixel, note order of j and i.
Expand Down Expand Up @@ -1485,7 +1485,7 @@ namespace lib {
}

/* Double loop on the output image */
if ((GDL_NTHREADS=parallelize( nEl))==1) {
if ((GDL_NTHREADS=parallelize( nEl, TP_CPU_INTENSIVE))==1) {
for (OMPInt j = 0; j < nRows; ++j) {
for (OMPInt i = 0; i < nCols; ++i) {
// Compute the original source for this pixel, note order of j and i.
Expand Down Expand Up @@ -1691,7 +1691,7 @@ namespace lib {
}

/* Double loop on the output image */
if ((GDL_NTHREADS=parallelize( nEl))==1) {
if ((GDL_NTHREADS=parallelize( nEl, TP_CPU_INTENSIVE))==1) {
for (OMPInt j = 0; j < nRows; ++j) {
for (OMPInt i = 0; i < nCols; ++i) {
// Compute the original source for this pixel, note order of j and i.
Expand Down
2 changes: 1 addition & 1 deletion src/minmax_include.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


SizeT nElem = (stop - start) / step;
GDL_NTHREADS=parallelize( nElem);
GDL_NTHREADS=parallelize( nElem, TP_CPU_INTENSIVE);
//trap existence of ABSFUNC and create something that stands cppchekck useage (needed by contiunous integration scripts!)
#ifndef ABSFUNC
#define FUNCABS
Expand Down

0 comments on commit 783b3fa

Please sign in to comment.