This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Support `-fgpu-default-stream`
ClosedPublic

Authored by yaxunl on Feb 21 2022, 7:58 PM.

Details

Summary

Introduce -fgpu-default-stream={legacy|per-thread} option to
support per-thread default stream for HIP runtime.

When -fgpu-default-stream=per-thread, HIP kernels are
launched through hipLaunchKernel_spt instead of
hipLaunchKernel. Also -DHIP_API_PER_THREAD_DEFAULT_STREAM
is passed to clang -cc1 to enable other per-thread stream
API's.

Diff Detail

Event Timeline

yaxunl created this revision.Feb 21 2022, 7:58 PM
yaxunl requested review of this revision.Feb 21 2022, 7:58 PM
tra added inline comments.Feb 22 2022, 10:27 AM
clang/include/clang/Driver/Options.td
962

Naming, as usual, is hard. :-)

Considering that the option tweaks codegen, it may be appropriate to use -f prefix.
On the other hand, --default-stream is the option used by NVCC, so it may be more familiar to the end users.
The third option would be to use --gpu-default-stream or -fgpu-default-stream.

I'm leaning towards -fgpu-default-stream.

WDYT?

clang/lib/Driver/ToolChains/Clang.cpp
6925

This should probably be done by the preprocessor itself where we define other HIP/CUDA related environment variables. We may need to pass-through the option itself to cc1 for that. I think clang would do that by default if we were using -f*default-stream.

yaxunl marked an inline comment as done.Feb 22 2022, 10:36 AM
yaxunl added inline comments.
clang/include/clang/Driver/Options.td
962

Agree. -fgpu-default-stream fits clang better.

clang/lib/Driver/ToolChains/Clang.cpp
6925

Right. Will do it in preprocessor.

yaxunl updated this revision to Diff 410691.Feb 22 2022, 7:17 PM
yaxunl marked an inline comment as done.
yaxunl retitled this revision from [HIP] Support `--default-stream` to [HIP] Support `-fgpu-default-stream`.
yaxunl edited the summary of this revision. (Show Details)

rename the option and use preprocessor to emit the macro definition

tra accepted this revision.Feb 23 2022, 12:26 PM

LGTM with a minor nit.

Also -DHIP_API_PER_THREAD_DEFAULT_STREAM is passed to clang -cc1 to enable other per-thread stream

You may want to rephrase patch description it a bit to match the latest code. "HIP_API_PER_THREAD_DEFAULT_STREAM macro is set if ..."

This revision is now accepted and ready to land.Feb 23 2022, 12:26 PM

LGTM with a minor nit.

Also -DHIP_API_PER_THREAD_DEFAULT_STREAM is passed to clang -cc1 to enable other per-thread stream

You may want to rephrase patch description it a bit to match the latest code. "HIP_API_PER_THREAD_DEFAULT_STREAM macro is set if ..."

will fix commit message when committing. thanks

This revision was landed with ongoing or failed builds.Feb 23 2022, 7:30 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 23 2022, 7:30 PM