Skip to content

Commit 6fed6b2

Browse files
authored
[SYCL][HIP] Add HIP arch argument for lit tests (#4676)
When using the HIP backend for an AMD platform the gpu's architecture must be sepcified with `-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=<target>`. This patch adds an option to `buildbot/configure.py` which allows the user to state the gpu architecture for lit tests when running `check-sycl-hip`. Relevant messages and docs are updated within the patch. This patch is needed even if the tests do not run on hardware, as the amd architecture must be specified for compilation.
1 parent 87e9fa7 commit 6fed6b2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

buildbot/configure.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def do_configure(args):
3232
sycl_build_pi_esimd_cpu = 'OFF'
3333
sycl_build_pi_hip = 'OFF'
3434
sycl_build_pi_hip_platform = 'AMD'
35+
sycl_clang_extra_flags = ''
3536
sycl_werror = 'ON'
3637
llvm_enable_assertions = 'ON'
3738
llvm_enable_doxygen = 'OFF'
@@ -67,6 +68,8 @@ def do_configure(args):
6768
if args.hip_platform == 'AMD':
6869
llvm_targets_to_build += ';AMDGPU'
6970
libclc_targets_to_build += ';amdgcn--;amdgcn--amdhsa'
71+
if args.hip_amd_arch:
72+
sycl_clang_extra_flags += "-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch="+args.hip_amd_arch
7073

7174
# The HIP plugin for AMD uses lld for linking
7275
llvm_enable_projects += ';lld'
@@ -126,7 +129,8 @@ def do_configure(args):
126129
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing),
127130
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld),
128131
"-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu),
129-
"-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror)
132+
"-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror),
133+
"-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags)
130134
]
131135

132136
if args.l0_headers and args.l0_loader:
@@ -188,6 +192,7 @@ def main():
188192
parser.add_argument("--cuda", action='store_true', help="switch from OpenCL to CUDA")
189193
parser.add_argument("--hip", action='store_true', help="switch from OpenCL to HIP")
190194
parser.add_argument("--hip-platform", type=str, choices=['AMD', 'NVIDIA'], default='AMD', help="choose hardware platform for HIP backend")
195+
parser.add_argument("--hip-amd-arch", type=str, help="Sets AMD gpu architecture for llvm lit tests, this is only needed for the HIP backend and AMD platform")
191196
parser.add_argument("--arm", action='store_true', help="build ARM support rather than x86")
192197
parser.add_argument("--enable-esimd-cpu-emulation", action='store_true', help="build with ESIMD_CPU emulation support")
193198
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")

sycl/doc/GetStartedGuide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ If CUDA support has been built, it is tested only if there are CUDA devices
488488
available.
489489
490490
If testing with HIP for AMD make sure to specify the GPU being used
491-
by adding `-Xsycl-target-backend=amdgcn-amd-amdhsa
492-
--offload-arch=<target>` to the CMake variable
493-
`SYCL_CLANG_EXTRA_FLAGS`.
491+
by adding `-hip-amd-arch=<target>`to buildbot/configure.py or add
492+
`-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=<target>`
493+
to the CMake variable `SYCL_CLANG_EXTRA_FLAGS`.
494494
495495
#### Run DPC++ E2E test suite
496496

sycl/test/lit.cfg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
if not re.match('.*--offload-arch.*', config.sycl_clang_extra_flags):
110110
raise Exception("Error: missing --offload-arch flag when trying to " \
111111
"run lit tests for AMD GPU, please add " \
112+
"--hip-amd-arch=<target> to buildbot/configure.py or add" \
112113
"`-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=<target>` to " \
113114
"the CMake variable SYCL_CLANG_EXTRA_FLAGS")
114115

0 commit comments

Comments
 (0)