OpenMPIRBuilder target teams distribute parallel for

Hello,

I’m trying to use the OpenMPIRBuilder to capture the following code:

#pragma omp target data map(to:X[0 : N]) map(tofrom:Y[0 : N])
#pragma omp target
#pragma omp teams
#pragma omp distribute parallel for
for (...) {
 ...
}

However, it is not entirely clear to me which API calls I need to make to the OpenMPIRBuilder. I suppose that OpenMPIRBuilder::createTargetData ( ... ) covers the first line. Lines 2-4 can in my understanding be written in one semantically equivalent line #pragma omp target teams distribute parallel for. However, it doesn’t appear that OpenMPIRBuilder::createTarget() could fully cover this, such that I effectively need three API calls, createTarget(), createTeams(), and likely one for distribute? I’m not entirely sure what the calls should be, and if capturing this construct is currently supported by the OpenMPIRBuilder?

BR,
Nicolai

Hi,
OpenMPIRBuilder does not support all OpenMP clauses. Support for target teams parallel for pragma is still in progress.

I suggest you to use LLVM-Flang compiler and Fortran OpenMP code, because Flang relies solely on OMPIRBuilder. Usage of OMPIRBuilder for Clang is optional and not all code from Clang OpenMP codegen is moved to OpenMPIRBuilder.

Hi,
patch [OpenMPIRBuilder] Add support for target workshare loops by DominikAdamski · Pull Request #73360 · llvm/llvm-project · GitHub added support for GPU LLVM IR code generation for OpenMP worksharing loop for target region.

Currently we can lower to LLVM-IR code with OpenMPIRBuilder for workshare loop without distribute clause (see: [NFC][MLIR][OpenMP] Add test to check lowering omp.wsloop inside target region by DominikAdamski · Pull Request #74857 · llvm/llvm-project · GitHub ) .

MLIR omp.distribute operation is not supported at the moment. That’s why you cannot generate LLVM-IR for distribute clause.

If you wish, you can use Flang to generate MLIR code which can be lowered to LLVM-IR by OpenMPIRBuilder.