This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][deviceRTLs] Drop `assert` in common parts of `deviceRTLs`
ClosedPublic

Authored by tianshilei1992 on Feb 3 2021, 4:43 PM.

Details

Summary

The header assert.h needs to be included in order to use assert in the code.
When building NVPTX deviceRTLs on a CUDA free system, it requires headers from
gcc-multilib, which some systems don't have. This patch drops the use of
assert in common parts of deviceRTLs. In light of
openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h, a code block

if (!cond)
  __builtin_trap();

is being used. The builtin will be translated to call void @llvm.trap(), and
the corresponding PTX is trap;.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Feb 3 2021, 4:43 PM
tianshilei1992 requested review of this revision.Feb 3 2021, 4:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 4:43 PM
tianshilei1992 edited the summary of this revision. (Show Details)Feb 3 2021, 4:58 PM

Yep, like this.

Ptx documents an intrinsic/builtin/syscall thing for assert that we could use instead of trap. Involves creating a call to __assertfail, takes five arguments one of which is sizeof(char). This is much simpler and serves the same purpose though.

Could you delete the assert impl from amdgpu at the same time?

Remove useless function in amdgcn

JonChesterfield accepted this revision.Feb 3 2021, 6:02 PM
JonChesterfield added inline comments.
openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
20–21

Can drop this include too

This revision is now accepted and ready to land.Feb 3 2021, 6:02 PM

removed #include <assert.h>

tianshilei1992 marked an inline comment as done.Feb 3 2021, 6:05 PM
tianshilei1992 added inline comments.
openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
20–21

Aha, you guys also included it here 😂

This revision was landed with ongoing or failed builds.Feb 4 2021, 9:39 AM
This revision was automatically updated to reflect the committed changes.
tianshilei1992 marked an inline comment as done.