This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP][NVPTX]Add __kmpc_syncwarp(int32_t) function.
ClosedPublic

Authored by ABataev on Aug 23 2019, 12:00 PM.

Details

Summary

Added function void __kmpc_syncwarp(int32_t) to expose it to the
compiler. It is required to fix the problem with the critical regions in
Cuda9.0+. We cannot use barrier in the critical region, but still need
to reconverge the threads in the warp after. This function allows to do
this.

Event Timeline

ABataev created this revision.Aug 23 2019, 12:00 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: guansong. · View Herald Transcript

I guess there is a clang-side patch as well which makes use of the new exposed kmpc function? Can you add it to the description? Also, can you add a basic test with a critical region that doesn't work correctly without this patch?

ABataev added a comment.EditedAug 23 2019, 12:13 PM

I guess there is a clang-side patch as well which makes use of the new exposed kmpc function? Can you add it to the description? Also, can you add a basic test with a critical region that doesn't work correctly without this patch?

The test is libomptarget/deviceRTLs/nvptx/test/parallel/spmd_parallel_regions.cpp. Currently it does not work in Cuda9+.
The clang patch is D66673. It is not completed yet, the tests are not updated. The functional part is finished and tested with Cuda 9.2.

We have uses of __SYNCWARP in the library, right? Can we use the function instead and maybe put it in the language dependent part?

We have uses of __SYNCWARP in the library, right? Can we use the function instead and maybe put it in the language dependent part?

Move __SYNCWARP macro to target_impl.h? And introduce __kmpc_impl_synwarp()?

ABataev updated this revision to Diff 216932.Aug 23 2019, 1:01 PM

Added target specific __kmpc_impl_syncwarp() function.

Looks good. Delighted to see extensions to target_impl.

Is this approved?

This revision is now accepted and ready to land.Aug 26 2019, 9:51 AM
This revision was automatically updated to reflect the committed changes.