This is an archive of the discontinued LLVM Phabricator instance.

[Clang][OpenMP] GPU simd directive code generation
Needs ReviewPublic

Authored by efwright on Jul 5 2023, 11:24 PM.

Details

Reviewers
jdoerfert
ABataev
Summary

This is a portion of the work for implementing OpenMP's "simd" loop directive for GPUs. For now only working on upstreaming the code generation portion. Right now the runtime just runs the loop sequentially.

Style-wise we're using a similar methodology of other directives in libomptarget where the "parallel region" is outlined, and passed as an argument into the appropriate runtime function. These changes are in the OMPIRBuilder and right now are only enabled if OMPIRBuilder is enabled. The code also depends on the OMPCanonicalLoop class existing in the AST, which currently only happens when the OMPIRBuilder is enabled.

Diff Detail

Event Timeline

efwright created this revision.Jul 5 2023, 11:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 11:24 PM
efwright requested review of this revision.Jul 5 2023, 11:24 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJul 5 2023, 11:24 PM
tianshilei1992 retitled this revision from OpenMP GPU simd directive code generation to [Clang][OpenMP] GPU simd directive code generation.Jul 6 2023, 7:48 AM
tianshilei1992 added a reviewer: ABataev.

Do you have tests?

jdoerfert added inline comments.Jul 6 2023, 9:04 PM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
1532

This is in large parts copied from existing code. Can we extract those parts into helper functions instead of duplicating them?

efwright updated this revision to Diff 543540.Jul 24 2023, 7:32 AM

Dropping off a simple test case. If this looks about what you would expect for the tests I have a couple more involved ones that I can repurpose and add in. For more complex tests we have a couple of the benchmark codes from ICPP that were working.

Some cleanup of the code gen is coming, will be on travel tomorrow so might take a day or two.

Dropping off a simple test case. If this looks about what you would expect for the tests I have a couple more involved ones that I can repurpose and add in. For more complex tests we have a couple of the benchmark codes from ICPP that were working.

We need tests in clang to check the IR

domada added a subscriber: domada.Jul 28 2023, 6:39 AM

Hi,
thank you for your contribution.
Could you fix assertion failure which was reported by Clang CI ( https://buildkite.com/llvm-project/premerge-checks/builds/166519#01898852-f9c9-4dd2-9933-b32be792c976 ) ?
Assertion failed: OpenMPRuntime != nullptr, file C:\ws\w9\llvm-project\premerge-checks\clang\lib\CodeGen\CodeGenModule.h, line 635

Dropping off a simple test case. If this looks about what you would expect for the tests I have a couple more involved ones that I can repurpose and add in. For more complex tests we have a couple of the benchmark codes from ICPP that were working.

Some cleanup of the code gen is coming, will be on travel tomorrow so might take a day or two.

If you want to do this properly you need to have tests for various ways in which the simd directive can be used in combination with other directives. I am actually surprised you haven't had to modify any of the existing lit tests that involve the simd directive. Do you know why that is? Is it because you're not doing anything other than running sequentially?