PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

OMPTargetTrans does not exclude CodeBlocks

Open arporter opened this issue 3 years ago • 3 comments

While working on https://github.com/stfc/PSycloneBench/pull/87 it turns out that OMPTargetTrans happily puts directives around a loop that does both a reduction and a WRITE. At the very least it should spot the CodeBlock containing the WRITE and refuse to transform it. Possibly OMPTargetTrans should sub-class ParallelRegionTrans rather than just RegionTrans and perhaps this is true for ACCKernelsTrans too? (See https://psyclone-ref.readthedocs.io/en/latest/_static/html/classpsyclone_1_1psyir_1_1transformations_1_1region__trans_1_1RegionTrans.html)

arporter avatar Jul 26 '22 20:07 arporter

image

arporter avatar Jul 26 '22 20:07 arporter

I agree to exclude all codeblocks in the OMPTargetTrans, in the Nemo script I have it as a condition to the loop that walks the Loop nodes. But it would be safer to avoid it a the transformation level to prevent silent issues like in tracer advection.

I don't think reductions are invalid for OMPTargetTrans as the directive alone does not parallelise the body. The reduction should be catch and prevent the OMPLoopTrans though but we may still want to run a reduction serially on the GPU to avoid transfering data (or not but this is up to the psyclone script to decide)

sergisiso avatar Jul 27 '22 08:07 sergisiso

I am taking this. I will not make it a ParallelRegionTrans since by itself is not really a Parallel Region (it needs another directive to make the contents parallel) but I will prevent CodeBlocks, UBOUNDS and LBOUNDS inside the directive body.

I do also not think that ACCKernels should be ParallelRegionTrans, in this case we offload the decision if the loop should be parallel to the compiler's automatic parallelisation algorithm. But it is not semantically incorrect to put a kernels directive in a loop that can not be parallelised. I think it is the same for the CodeBlock exclusion but in this case it would be OK to add it if it often trips the compiler.. but I don't have enough experience with this directive, so I will let you decide what's best.

sergisiso avatar Jul 29 '22 14:07 sergisiso