@@ -29,10 +29,10 @@ namespace __omp_backend
29
29
30
30
template <class _Index , class _Fp >
31
31
void
32
- __parallel_for_body (_Index __first, _Index __last, _Fp __f)
32
+ __parallel_for_body (_Index __first, _Index __last, _Fp __f, std:: size_t __grainsize )
33
33
{
34
34
// initial partition of the iteration space into chunks
35
- auto __policy = oneapi::dpl::__omp_backend::__chunk_partitioner (__first, __last);
35
+ auto __policy = oneapi::dpl::__omp_backend::__chunk_partitioner (__first, __last, __grainsize );
36
36
37
37
// To avoid over-subscription we use taskloop for the nested parallelism
38
38
_PSTL_PRAGMA (omp taskloop untied mergeable)
@@ -49,20 +49,21 @@ __parallel_for_body(_Index __first, _Index __last, _Fp __f)
49
49
50
50
template <class _ExecutionPolicy , class _Index , class _Fp >
51
51
void
52
- __parallel_for (oneapi::dpl::__internal::__omp_backend_tag, _ExecutionPolicy&&, _Index __first, _Index __last, _Fp __f)
52
+ __parallel_for (oneapi::dpl::__internal::__omp_backend_tag, _ExecutionPolicy&&, _Index __first, _Index __last, _Fp __f,
53
+ std::size_t __grainsize = __default_chunk_size)
53
54
{
54
55
if (omp_in_parallel ())
55
56
{
56
57
// we don't create a nested parallel region in an existing parallel
57
58
// region: just create tasks
58
- oneapi::dpl::__omp_backend::__parallel_for_body (__first, __last, __f);
59
+ oneapi::dpl::__omp_backend::__parallel_for_body (__first, __last, __f, __grainsize );
59
60
}
60
61
else
61
62
{
62
63
// in any case (nested or non-nested) one parallel region is created and
63
64
// only one thread creates a set of tasks
64
65
_PSTL_PRAGMA (omp parallel)
65
- _PSTL_PRAGMA (omp single nowait) { oneapi::dpl::__omp_backend::__parallel_for_body (__first, __last, __f); }
66
+ _PSTL_PRAGMA (omp single nowait) { oneapi::dpl::__omp_backend::__parallel_for_body (__first, __last, __f, __grainsize ); }
66
67
}
67
68
}
68
69
0 commit comments