This is a bit of a weird case, and I think must happen in structures like this in socrates:
do outer_loop = 1, N
# some random code
#outer loop is unused to here.
#pragma omp parallel
do chunked_loop_var = 1, M, 32
#pragma omp task ...
do inner_loop = chunked_loop_var, chunked_loop_var+32, 1
something(inner_loop) = array(inner_loop, outer_loop)
end do
end do
end do
In this case, since outer_loop's variable only has a single, read-only access and is set outside the parallel region the parallel region sets it as shared (or rather, doesn't set it as private etc.). Tasking refuses at the moment to accept shared variables as loop indices (since that behaviour feels a bit race-conditiony in general so we'd need to handle the value in some way).
Since this can only happen in PSyclone at the moment for scalar variables which are read-only, it is possible for me to workaround this by checking if the shared variable is a scalar access, and if so, I could treat this the same as a private variable for now to get this working for Socrates.
I'm not sure I like that as a general solution since if we change the behaviour of OMPParallelDirective.infer_sharing_clauses then the tasking code could start making illegal code - i might just add the change (once I get it working) to this issue and a failing testcase as well and leave it to fix if we use tasking more widely.
This is a bit of a weird case, and I think must happen in structures like this in socrates:
In this case, since
outer_loop
's variable only has a single, read-only access and is set outside the parallel region the parallel region sets it as shared (or rather, doesn't set it as private etc.). Tasking refuses at the moment to accept shared variables as loop indices (since that behaviour feels a bit race-conditiony in general so we'd need to handle the value in some way).Since this can only happen in PSyclone at the moment for scalar variables which are read-only, it is possible for me to workaround this by checking if the shared variable is a scalar access, and if so, I could treat this the same as a private variable for now to get this working for Socrates.
I'm not sure I like that as a general solution since if we change the behaviour of
OMPParallelDirective.infer_sharing_clauses
then the tasking code could start making illegal code - i might just add the change (once I get it working) to this issue and a failing testcase as well and leave it to fix if we use tasking more widely.@sergisiso does this seem reasonable to you?