From c254f0c61deedd8f3b96e0dd81a88b614b97f44e Mon Sep 17 00:00:00 2001 From: Aidan Belton Date: Thu, 8 Jul 2021 15:44:20 +0100 Subject: [PATCH 1/5] ROCm flags added to test suite, readme updated with docs, basic test update --- SYCL/FilterSelector/select.cpp | 16 ++++++++++++++ SYCL/Plugin/sycl-ls-gpu-rocm.cpp | 19 +++++++++++++++++ SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp | 8 ++++++- SYCL/README.md | 18 ++++++++++++---- SYCL/lit.cfg.py | 33 +++++++++++++++++++++++------ SYCL/lit.site.cfg.py.in | 2 ++ 6 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 SYCL/Plugin/sycl-ls-gpu-rocm.cpp diff --git a/SYCL/FilterSelector/select.cpp b/SYCL/FilterSelector/select.cpp index 8b7a259f71..c39973b0ed 100644 --- a/SYCL/FilterSelector/select.cpp +++ b/SYCL/FilterSelector/select.cpp @@ -39,6 +39,7 @@ int main() { bool HasLevelZeroDevices = false; bool HasOpenCLDevices = false; bool HasCUDADevices = false; + bool HasROCmDevices = false; bool HasOpenCLGPU = false; bool HasLevelZeroGPU = false; @@ -50,6 +51,8 @@ int main() { HasOpenCLDevices = true; } else if (Backend == backend::cuda) { HasCUDADevices = true; + } else if (Backedn == backend::rocm) { + HasROCmDevices = true; } } @@ -64,6 +67,7 @@ int main() { std::cout << "HasLevelZeroDevices = " << HasLevelZeroDevices << std::endl; std::cout << "HasOpenCLDevices = " << HasOpenCLDevices << std::endl; std::cout << "HasCUDADevices = " << HasCUDADevices << std::endl; + std::cout << "HasROCmDevices = " << HasROCmDevices << std::endl; std::cout << "HasOpenCLGPU = " << HasOpenCLGPU << std::endl; std::cout << "HasLevelZeroGPU = " << HasLevelZeroGPU << std::endl; @@ -198,5 +202,17 @@ int main() { std::cout << "...PASS" << std::endl; } + if (HasROCmDevices) { + std::cout << "Test 'rocm'"; + device d19(ONEAPI::filter_selector("rocm")); + assert(d19.get_platform().get_backend() == backend::rocm); + std:: cout << "...PASS" << std::endl; + + std::cout << "test 'rocm:gpu'"; + device d20(ONEAPI::filter_selector("rocm:gpu")); + assert(d20.is_gpu() && d19.get_platform().get_backend() == backend::rocm); + std::cout << "...PASS" << std::endl; + } + return 0; } diff --git a/SYCL/Plugin/sycl-ls-gpu-rocm.cpp b/SYCL/Plugin/sycl-ls-gpu-rocm.cpp new file mode 100644 index 0000000000..75dbf6075a --- /dev/null +++ b/SYCL/Plugin/sycl-ls-gpu-rocm.cpp @@ -0,0 +1,19 @@ +// REQUIRES: gpu, rocm + +// RUN: env SYCL_DEVICE_FILTER=rocm sycl-ls --verbose >%t.rocm.out +// RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-ROCM,CHECK-CUSTOM-GPU-ROCM --input-file %t.rocm.out + +// CHECK-BUILTIN-GPU-ROCM: gpu_selector(){{.*}}GPU :{{.*}}ROCM +// CHECK-CUSTOM-GPU-ROCM: custom_selector(gpu){{.*}}GPU :{{.*}}ROCM + +//==---- sycl-ls-gpu-rocm.cpp - SYCL test for discovered/selected devices --==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + + + + diff --git a/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp b/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp index 6a67a680ca..2cc4d1b9dc 100644 --- a/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp +++ b/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp @@ -1,4 +1,4 @@ -// REQUIRES: gpu, cuda, opencl +// REQUIRES: gpu, cuda, rocm, opencl // RUN: sycl-ls --verbose >%t.default.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.default.out @@ -15,6 +15,12 @@ // CHECK-BUILTIN-GPU-CUDA: gpu_selector(){{.*}}GPU : CUDA // CHECK-CUSTOM-GPU-CUDA: custom_selector(gpu){{.*}}GPU : CUDA +// RUN: env SYCL_DEVICE_FILTER=rocm sycl-ls --verbose >%t.rocm.out +// RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-ROCM,CHECK-CUSTOM-GPU-ROCM --input-file %t.rocm.out + +// CHECK-BUILTIN-GPU-ROCM: gpu_selector(){{.*}}GPU : ROCM +// CHECK-CUSTOM-GPU-ROCM: custom_selector(gpu){{.*}}GPU : ROCM + //==---- sycl-ls-gpu-sycl-be.cpp - SYCL test for discovered/selected devices //--==// // diff --git a/SYCL/README.md b/SYCL/README.md index 7749c2ff24..060fcbabca 100644 --- a/SYCL/README.md +++ b/SYCL/README.md @@ -81,18 +81,19 @@ list of configurations. Each configuration includes backend separated from comma-separated list of target devices with colon. Example: ``` --DCHECK_SYCL_ALL="opencl:cpu,host;level_zero:gpu,host;cuda:gpu" +-DCHECK_SYCL_ALL="opencl:cpu,host;level_zero:gpu,host;cuda:gpu;rocm:gpu" ``` ***SYCL_BE*** SYCL backend to be used for testing. Supported values are: - **opencl** - for OpenCL backend; - **cuda** - for CUDA backend; + - **ROCm** - for ROCm backend; - **level_zero** - Level Zero backend. ***SYCL_TARGET_DEVICES*** comma separated list of target devices for testing. Default value is cpu,gpu,acc,host. Supported values are: - **cpu** - CPU device available in OpenCL backend only; - - **gpu** - GPU device available in OpenCL, Level Zero and CUDA backends; + - **gpu** - GPU device available in OpenCL, Level Zero, CUDA, and ROCm backends; - **acc** - FPGA emulator device available in OpenCL backend only; - **host** - SYCL Host device available with all backends. @@ -105,6 +106,15 @@ specified by this variable. ***LEVEL_ZERO_LIBS_DIR*** path to Level Zero libraries. +***ROCM_PLATFORM*** platform selection for ROCm targeted devices. +Defaults to AMD if no value is given. Supported values are: + - **AMD** - for ROCm to target AMD GPUs + - **NVIDIA** - for ROCm to target NVIDIA GPUs + + ***MCPU*** Please not, flag must be set for when using ROCm triple. + For example it may be set to "gfx906". + + # Special test categories There are two special directories for extended testing. See documentation at: @@ -124,7 +134,7 @@ unavailable. * **windows**, **linux** - host OS; * **cpu**, **gpu**, **host**, **accelerator** - target device; - * **cuda**, **opencl**, **level_zero** - target backend; + * **cuda**, **rocm**, **opencl**, **level_zero** - target backend; * **sycl-ls** - sycl-ls tool availability; * **cl_options** - CL command line options recognized (or not) by compiler; * **opencl_icd** - OpenCL ICD loader availability; @@ -142,7 +152,7 @@ configure specific single test execution in the command line: * **dpcpp_compiler** - full path to dpcpp compiler; * **target_device** - comma-separated list of target devices (cpu, gpu, acc, host); - * **sycl_be** - SYCL backend to be used (opencl, level_zero, cuda); + * **sycl_be** - SYCL backend to be used (opencl, level_zero, cuda, rocm); * **dump_ir** - if IR dumping is supported for compiler (True, False); * **gpu-intel-dg1** - tells LIT infra that Intel GPU DG1 is present in the system. It is developer / CI infra responsibility to make sure that the diff --git a/SYCL/lit.cfg.py b/SYCL/lit.cfg.py index 4b438d2796..5239e47b44 100644 --- a/SYCL/lit.cfg.py +++ b/SYCL/lit.cfg.py @@ -152,7 +152,7 @@ # Mapping from SYCL_BE backend definition style to SYCL_DEVICE_FILTER used # for backward compatibility try: - config.sycl_be = { 'PI_OPENCL': 'opencl', 'PI_CUDA': 'cuda', 'PI_LEVEL_ZERO': 'level_zero'}[config.sycl_be] + config.sycl_be = { 'PI_OPENCL': 'opencl', 'PI_CUDA': 'cuda', 'PI_ROCM': 'rocm', 'PI_LEVEL_ZERO': 'level_zero'}[config.sycl_be] except: # do nothing a we expect that new format of plugin values are used pass @@ -166,12 +166,24 @@ if config.dump_ir_supported: config.available_features.add('dump_ir') -if config.sycl_be not in ['host', 'opencl','cuda', 'level_zero']: - lit_config.error("Unknown SYCL BE specified '" + - config.sycl_be + - "' supported values are opencl, cuda, level_zero") +if config.sycl_be not in ['host', 'opencl', 'cuda', 'rocm', 'level_zero']: + lit_config.error("Unknown SYCL BE specified '" + + config.sycl_be + + "' supported values are opencl, cuda, rocm, level_zero") -config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags ) ) +# If ROCM_PLATFORM flag is not set, default to AMD, and check if ROCM platform is supported +supported_rocm_platforms=["AMD", "NVIDIA"] +if config.rocm_platform == "": + config.rocm_platform = "AMD" +if config.rocm_platform not in supported_rocm_platforms: + lit_config.error("Unknown ROCm platform '" + config.rocm_platform + "' supported platforms are " + ', '.join(supported_rocm_platforms)) + +if config.sycl_be == "rocm" and config.rocm_platform == "AMD": + mcpu_flag = '-mcpu=' + config.mcpu +else: + mcpu_flag = "" + +config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + mcpu_flag) ) config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags ) ) config.substitutions.append( ('%threads_lib', config.sycl_threads_lib) ) @@ -273,11 +285,18 @@ config.substitutions.append( ('%ACC_RUN_PLACEHOLDER', acc_run_substitute) ) config.substitutions.append( ('%ACC_CHECK_PLACEHOLDER', acc_check_substitute) ) -if config.sycl_be == 'cuda': +if config.sycl_be == 'cuda' or (config.sycl_be == 'rocm' and config.rocm_platform == 'NVIDIA'): config.substitutions.append( ('%sycl_triple', "nvptx64-nvidia-cuda-sycldevice" ) ) +elif config.sycl_be == 'rocm' and config.rocm_platform == 'AMD': + config.substitutions.append( ('%sycl_triple', "amdgcn-amd-amdhsa-sycldevice" ) ) else: config.substitutions.append( ('%sycl_triple', "spir64-unknown-unknown-sycldevice" ) ) +if config.sycl_be == 'rocm' and config.rocm_platform == 'AMD': + config.substitutions.append( ('%mcpu', "-mcpu=gfx906" ) ) +else: + config.substitutions.append( ('%mcpu', "") ) + if find_executable('sycl-ls'): config.available_features.add('sycl-ls') diff --git a/SYCL/lit.site.cfg.py.in b/SYCL/lit.site.cfg.py.in index 9916def273..fade794f5c 100644 --- a/SYCL/lit.site.cfg.py.in +++ b/SYCL/lit.site.cfg.py.in @@ -22,6 +22,8 @@ config.level_zero_include = "@LEVEL_ZERO_INCLUDE@" config.opencl_include_dir = config.sycl_include config.target_devices = lit_config.params.get("target_devices", "@SYCL_TARGET_DEVICES@") config.sycl_be = lit_config.params.get("sycl_be", "@SYCL_BE@") +config.rocm_platform = "@ROCM_PLATFORM@" +config.mcpu = "@MCPU@" config.sycl_threads_lib = '@SYCL_THREADS_LIB@' config.extra_environment = lit_config.params.get("extra_environment", "@LIT_EXTRA_ENVIRONMENT@") config.cxx_flags = "@CMAKE_CXX_FLAGS@" From 1d03da5a331401f84189afdf004d4d0d2c7742eb Mon Sep 17 00:00:00 2001 From: Aidan Belton Date: Thu, 8 Jul 2021 15:52:34 +0100 Subject: [PATCH 2/5] Fixed error in SYCL/lit.cfg.py --- SYCL/lit.cfg.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SYCL/lit.cfg.py b/SYCL/lit.cfg.py index 5239e47b44..ce0ddcade4 100644 --- a/SYCL/lit.cfg.py +++ b/SYCL/lit.cfg.py @@ -292,11 +292,6 @@ else: config.substitutions.append( ('%sycl_triple', "spir64-unknown-unknown-sycldevice" ) ) -if config.sycl_be == 'rocm' and config.rocm_platform == 'AMD': - config.substitutions.append( ('%mcpu', "-mcpu=gfx906" ) ) -else: - config.substitutions.append( ('%mcpu', "") ) - if find_executable('sycl-ls'): config.available_features.add('sycl-ls') From e4a20bd2ecbcb0bbc21036f9f9ecadfada000549 Mon Sep 17 00:00:00 2001 From: AidanBeltonS <87009434+AidanBeltonS@users.noreply.github.com> Date: Fri, 9 Jul 2021 10:01:14 +0100 Subject: [PATCH 3/5] Update README.md --- SYCL/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SYCL/README.md b/SYCL/README.md index 060fcbabca..b20e5de63c 100644 --- a/SYCL/README.md +++ b/SYCL/README.md @@ -111,7 +111,7 @@ Defaults to AMD if no value is given. Supported values are: - **AMD** - for ROCm to target AMD GPUs - **NVIDIA** - for ROCm to target NVIDIA GPUs - ***MCPU*** Please not, flag must be set for when using ROCm triple. + ***MCPU*** Flag must be set for when using ROCm triple. For example it may be set to "gfx906". From 094551cd5851f97f7e97fa8addfc9f566b6fd883 Mon Sep 17 00:00:00 2001 From: Aidan Belton Date: Fri, 9 Jul 2021 10:24:18 +0100 Subject: [PATCH 4/5] Update from PR comments --- SYCL/FilterSelector/select.cpp | 2 +- SYCL/Plugin/sycl-ls-gpu-rocm.cpp | 6 +----- SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp | 6 +++--- SYCL/README.md | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/SYCL/FilterSelector/select.cpp b/SYCL/FilterSelector/select.cpp index c39973b0ed..7f08001536 100644 --- a/SYCL/FilterSelector/select.cpp +++ b/SYCL/FilterSelector/select.cpp @@ -206,7 +206,7 @@ int main() { std::cout << "Test 'rocm'"; device d19(ONEAPI::filter_selector("rocm")); assert(d19.get_platform().get_backend() == backend::rocm); - std:: cout << "...PASS" << std::endl; + std::cout << "...PASS" << std::endl; std::cout << "test 'rocm:gpu'"; device d20(ONEAPI::filter_selector("rocm:gpu")); diff --git a/SYCL/Plugin/sycl-ls-gpu-rocm.cpp b/SYCL/Plugin/sycl-ls-gpu-rocm.cpp index 75dbf6075a..ad4dee20a0 100644 --- a/SYCL/Plugin/sycl-ls-gpu-rocm.cpp +++ b/SYCL/Plugin/sycl-ls-gpu-rocm.cpp @@ -1,4 +1,4 @@ -// REQUIRES: gpu, rocm +// REQUIRES: gpu, rocm, sycl-ls // RUN: env SYCL_DEVICE_FILTER=rocm sycl-ls --verbose >%t.rocm.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-ROCM,CHECK-CUSTOM-GPU-ROCM --input-file %t.rocm.out @@ -13,7 +13,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// - - - - diff --git a/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp b/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp index 2cc4d1b9dc..bb7dee9927 100644 --- a/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp +++ b/SYCL/Plugin/sycl-ls-gpu-sycl-be.cpp @@ -1,4 +1,4 @@ -// REQUIRES: gpu, cuda, rocm, opencl +// REQUIRES: gpu, cuda, rocm, opencl, sycl-ls // RUN: sycl-ls --verbose >%t.default.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.default.out @@ -18,8 +18,8 @@ // RUN: env SYCL_DEVICE_FILTER=rocm sycl-ls --verbose >%t.rocm.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-ROCM,CHECK-CUSTOM-GPU-ROCM --input-file %t.rocm.out -// CHECK-BUILTIN-GPU-ROCM: gpu_selector(){{.*}}GPU : ROCM -// CHECK-CUSTOM-GPU-ROCM: custom_selector(gpu){{.*}}GPU : ROCM +// CHECK-BUILTIN-GPU-ROCM: gpu_selector(){{.*}}GPU : ROCm +// CHECK-CUSTOM-GPU-ROCM: custom_selector(gpu){{.*}}GPU : ROCm //==---- sycl-ls-gpu-sycl-be.cpp - SYCL test for discovered/selected devices //--==// diff --git a/SYCL/README.md b/SYCL/README.md index 060fcbabca..01a31d4d14 100644 --- a/SYCL/README.md +++ b/SYCL/README.md @@ -87,7 +87,7 @@ from comma-separated list of target devices with colon. Example: ***SYCL_BE*** SYCL backend to be used for testing. Supported values are: - **opencl** - for OpenCL backend; - **cuda** - for CUDA backend; - - **ROCm** - for ROCm backend; + - **rocm** - for ROCm backend; - **level_zero** - Level Zero backend. ***SYCL_TARGET_DEVICES*** comma separated list of target devices for testing. @@ -111,7 +111,7 @@ Defaults to AMD if no value is given. Supported values are: - **AMD** - for ROCm to target AMD GPUs - **NVIDIA** - for ROCm to target NVIDIA GPUs - ***MCPU*** Please not, flag must be set for when using ROCm triple. + ***MCPU*** Flag must be set for when using ROCm triple. For example it may be set to "gfx906". From 45ab2ce6795528bd9baafe29300f355fe3d3a0bb Mon Sep 17 00:00:00 2001 From: Aidan Belton Date: Wed, 14 Jul 2021 09:27:48 +0100 Subject: [PATCH 5/5] Fixed typo in FilterSelector/select.cpp --- SYCL/FilterSelector/select.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SYCL/FilterSelector/select.cpp b/SYCL/FilterSelector/select.cpp index 7f08001536..693ff949a4 100644 --- a/SYCL/FilterSelector/select.cpp +++ b/SYCL/FilterSelector/select.cpp @@ -51,7 +51,7 @@ int main() { HasOpenCLDevices = true; } else if (Backend == backend::cuda) { HasCUDADevices = true; - } else if (Backedn == backend::rocm) { + } else if (Backend == backend::rocm) { HasROCmDevices = true; } }