message: added parallel_in_block_of tasking version, which iterates over entire ranges of items (in blocks of N items a piece)
diff: @@ -63,5 +63,36 @@ namespace ospcommon {
  fcn(taskIndex);
  }
  +
  +
  + /* NOTE(iw) - This abstraction extends the 'parallel_for' to mixed
  + parallel/serial: we logically view the domain of N input tasks
  + as grouped into roundUp(N/M) blocks of (at most) M items each;
  + then 'itearte over the N/M blocks in parallel, and process each
  + block serailly */
  + template<int BLOCK_SIZE, typename INDEX_T, typename TASK_T>
  + inline void parallel_in_blocks_of(INDEX_T nTasks, TASK_T&& fcn)
  + {
  + using namespace traits;
  + static_assert(is_valid_index<INDEX_T>::value,
  + "ospcommon::tasking::parallel_for() requires the type"
  + " INDEX_T to be unsigned char, short, int, uint, long,"
  + " or size_t.");
  +
  + // // iw - TODO: fix this
  + // static_assert(has_operator_method_matching_param<TASK_T, INDEX_T>::value,
  + // "ospcommon::tasking::parallel_for() requires the "
  + // "implementation of method "
  + // "'void TASK_T::operator(P taskIndex), where P is of "
  + // "type INDEX_T [first parameter of parallel_for()].");
  +
  + INDEX_T numBlocks = (nTasks+BLOCK_SIZE-1)/BLOCK_SIZE;
  + parallel_for(numBlocks,[&](INDEX_T blockID){
  + INDEX_T begin = blockID * (INDEX_T)BLOCK_SIZE;
  + INDEX_T end = std::min(begin+(INDEX_T)BLOCK_SIZE,nTasks);
  + fcn(begin,end);
  + });
  + }
  +
  } // ::ospcommon::tasking
  } //::ospcommon
  