This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Fix device malloc/free
ClosedPublic

Authored by yaxunl on Jan 10 2022, 12:34 PM.

Details

Summary

ROCm 4.5 device library introduced __ockl_dm_alloc and __ockl_dm_dealloc
for supporting device side malloc/free.

This patch redefines device malloc/free to use these functions.

It also fixes a bug in the wrapper header which incorrectly defines free
with return type void* instead of void.

Diff Detail

Event Timeline

yaxunl requested review of this revision.Jan 10 2022, 12:34 PM
yaxunl created this revision.
yaxunl edited the summary of this revision. (Show Details)
tra accepted this revision.Jan 10 2022, 1:42 PM
tra added inline comments.
clang/lib/Headers/__clang_hip_runtime_wrapper.h
80

Nit: perhaps something like this would express the intent a bit more directly:

# if HIP_VERSION_MAJOR*100+HIP_VERSION_MINOR*10 > 450
This revision is now accepted and ready to land.Jan 10 2022, 1:42 PM
yaxunl added inline comments.Jan 11 2022, 6:41 AM
clang/lib/Headers/__clang_hip_runtime_wrapper.h
80

We had ROCm 3.10, so the minor version may be 10 or greater.

Probably use HIP_VERSION_MAJOR*100+HIP_VERSION_MINOR > 405 instead?

tra added inline comments.Jan 11 2022, 10:21 AM
clang/lib/Headers/__clang_hip_runtime_wrapper.h
80

LGTM.

This revision was landed with ongoing or failed builds.Jan 11 2022, 11:49 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2022, 11:49 AM