I am trying to use a zip iterator (from either boost or thrust library) with openmp. My goal is to have a for_each loop that will process things in parallel through openmp.
Using the example from the boost documentation:
#pragma omp parallel for
std::for_each(
boost::make_zip_iterator(
boost::make_tuple(beg1, beg2)
),
boost::make_zip_iterator(
boost::make_tuple(end1, end2)
),
zip_func()
);
However, this doesn’t appear to run in parallel.
Suggestions?
What you have to do is either use
omp parallel forfollowed by a a for loop, use gcc__gnu_parallel::for_eachas was previously suggested or explicitly partition your iteration range (notice the absence offorin the pragma):