From 30378eace7d119eea83483c5e238338e80289800 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Wed, 17 Mar 2021 18:43:37 +0100 Subject: [PATCH 1/8] Add build HIP check --- cscs-checks/prgenv/hip/build_hip.py | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cscs-checks/prgenv/hip/build_hip.py diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py new file mode 100644 index 0000000000..469d792512 --- /dev/null +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -0,0 +1,38 @@ +import reframe as rfm +import reframe.utility.sanity as sn + +import os + + +@rfm.simple_test +class BuildHip(rfm.RegressionTest): + '''Download and install HIP around the nvcc compiler.''' + + # HIP build variables + hip_path = variable(str, value='hip') + hip_platform = variable(str, value='nvcc') + + valid_systems = ['daint:gpu', 'dom:gpu'] + valid_prog_environs = ['PrgEnv-gnu'] + sourcesdir = 'https://github.com/ROCm-Developer-Tools/HIP.git' + build_system = 'CMake' + postbuild_cmds = ['make install'] + executable = f'{hip_path}/bin/hipcc' + executable_opts = ['--version'] + maintainers = ['JO'] + + @rfm.run_before('compile') + def set_compile_options(self): + self.hip_full_path = os.path.abspath( + os.path.join(self.stagedir, self.hip_path) + ) + self.build_system.builddir = 'build' + self.build_system.config_opts = [ + f'-DCMAKE_INSTALL_PREFIX={self.hip_full_path}', + f'-DHIP_PLATFORM={self.hip_platform}', + f'-DHIP_PATH={self.hip_full_path}' + ] + + @rfm.run_before('sanity') + def set_sanity_patterns(self): + self.sanity_patterns = sn.assert_found(r'nvcc:\s+NVIDIA', self.stdout) From beddf69f8af574345f244c3e720c4eecbcf8f6e9 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Mon, 22 Mar 2021 17:00:30 +0100 Subject: [PATCH 2/8] Cleanup cmake setup --- cscs-checks/prgenv/hip/build_hip.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index 469d792512..99c174a674 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -30,7 +30,6 @@ def set_compile_options(self): self.build_system.config_opts = [ f'-DCMAKE_INSTALL_PREFIX={self.hip_full_path}', f'-DHIP_PLATFORM={self.hip_platform}', - f'-DHIP_PATH={self.hip_full_path}' ] @rfm.run_before('sanity') From 33829a15aea4aadff315b1a90832d17c42a91e05 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Tue, 23 Mar 2021 12:51:24 +0100 Subject: [PATCH 3/8] Add hello world test --- cscs-checks/prgenv/hip/build_hip.py | 41 ++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index 99c174a674..e893e75aba 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -10,16 +10,18 @@ class BuildHip(rfm.RegressionTest): # HIP build variables hip_path = variable(str, value='hip') + hip_full_path = variable(str) hip_platform = variable(str, value='nvcc') valid_systems = ['daint:gpu', 'dom:gpu'] valid_prog_environs = ['PrgEnv-gnu'] - sourcesdir = 'https://github.com/ROCm-Developer-Tools/HIP.git' + sourcesdir = 'https://github.com/ROCm-Developer-Tools/HIP.git' build_system = 'CMake' postbuild_cmds = ['make install'] executable = f'{hip_path}/bin/hipcc' executable_opts = ['--version'] maintainers = ['JO'] + tags = {'production'} @rfm.run_before('compile') def set_compile_options(self): @@ -35,3 +37,40 @@ def set_compile_options(self): @rfm.run_before('sanity') def set_sanity_patterns(self): self.sanity_patterns = sn.assert_found(r'nvcc:\s+NVIDIA', self.stdout) + + +@rfm.simple_test +class HelloHip(rfm.RegressionTest): + '''A Hello World test for HIP.''' + + sample = variable(str, value='HelloWorld') + sample_dir = variable(str, value='HIP-Examples-Applications') + + valid_systems = ['daint:gpu', 'dom:gpu'] + valid_prog_environs = ['PrgEnv-gnu'] + modules = ['cdt-cuda'] + sourcesdir = 'https://github.com/ROCm-Developer-Tools/HIP-Examples.git' + build_system = 'Make' + maintainers = ['JO'] + tags = {'production'} + + def __init__(self): + self.depends_on('BuildHip') + + @rfm.require_deps + def get_hip_path(self, BuildHip): + self.hip_path = BuildHip().hip_full_path + + @rfm.run_before('compile') + def set_env(self): + self.variables = {'HIP_PATH': f'{self.hip_path}'} + self.build_system.cxx = os.path.join(self.hip_path, 'bin', 'hipcc') + self.prebuild_cmds = [f'cd {self.sample_dir}/{self.sample}'] + + @rfm.run_before('run') + def set_executable(self): + self.executable = f'{self.sample_dir}/{self.sample}/{self.sample}' + + @rfm.run_before('sanity') + def set_sanity(self): + self.sanity_patterns = sn.assert_found(r'HelloWorld', self.stdout) From b5dae052050e6ecce1bcc1a2619e057c21488ff2 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Tue, 23 Mar 2021 12:53:00 +0100 Subject: [PATCH 4/8] Add copyright --- cscs-checks/prgenv/hip/build_hip.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index e893e75aba..a3b840fec2 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -1,7 +1,11 @@ -import reframe as rfm -import reframe.utility.sanity as sn +# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich) +# ReFrame Project Developers. See the top-level LICENSE file for details. +# +# SPDX-License-Identifier: BSD-3-Clause import os +import reframe as rfm +import reframe.utility.sanity as sn @rfm.simple_test From bfb08ac6b6db40c0008fe3de1f527e47d84bda9a Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Tue, 23 Mar 2021 13:03:34 +0100 Subject: [PATCH 5/8] Set executable in the class body --- cscs-checks/prgenv/hip/build_hip.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index a3b840fec2..983fcfdcd3 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -47,14 +47,18 @@ def set_sanity_patterns(self): class HelloHip(rfm.RegressionTest): '''A Hello World test for HIP.''' + # Declare custom test variables sample = variable(str, value='HelloWorld') sample_dir = variable(str, value='HIP-Examples-Applications') + hip_path = variable(str) valid_systems = ['daint:gpu', 'dom:gpu'] valid_prog_environs = ['PrgEnv-gnu'] modules = ['cdt-cuda'] sourcesdir = 'https://github.com/ROCm-Developer-Tools/HIP-Examples.git' + prebuild_cmds = [f'cd {sample_dir}/{sample}'] build_system = 'Make' + executable = f'{sample_dir}/{sample}/{sample}' maintainers = ['JO'] tags = {'production'} @@ -69,11 +73,6 @@ def get_hip_path(self, BuildHip): def set_env(self): self.variables = {'HIP_PATH': f'{self.hip_path}'} self.build_system.cxx = os.path.join(self.hip_path, 'bin', 'hipcc') - self.prebuild_cmds = [f'cd {self.sample_dir}/{self.sample}'] - - @rfm.run_before('run') - def set_executable(self): - self.executable = f'{self.sample_dir}/{self.sample}/{self.sample}' @rfm.run_before('sanity') def set_sanity(self): From 23afa3da9abddac6b733897553a18f0c7ba65b3f Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Tue, 23 Mar 2021 13:08:52 +0100 Subject: [PATCH 6/8] Add FIXME --- cscs-checks/prgenv/hip/build_hip.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index 983fcfdcd3..d54032f3d9 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -63,6 +63,7 @@ class HelloHip(rfm.RegressionTest): tags = {'production'} def __init__(self): + # FIXME: PR #1868 should move this into the class body. self.depends_on('BuildHip') @rfm.require_deps From 5cb7b3fb20dd5c0b2bae5944efdcd177563bc214 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Wed, 21 Apr 2021 09:38:03 +0200 Subject: [PATCH 7/8] Update hip_platform variable --- cscs-checks/prgenv/hip/build_hip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index d54032f3d9..6da1db82cc 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -15,7 +15,7 @@ class BuildHip(rfm.RegressionTest): # HIP build variables hip_path = variable(str, value='hip') hip_full_path = variable(str) - hip_platform = variable(str, value='nvcc') + hip_platform = variable(str, value='nvidia') valid_systems = ['daint:gpu', 'dom:gpu'] valid_prog_environs = ['PrgEnv-gnu'] From a18eb2eb7e789dfa3a91816744f1bff828d886d2 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Wed, 21 Apr 2021 10:06:12 +0200 Subject: [PATCH 8/8] Set deps in post-init hook --- cscs-checks/prgenv/hip/build_hip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cscs-checks/prgenv/hip/build_hip.py b/cscs-checks/prgenv/hip/build_hip.py index 6da1db82cc..3db90ba3e4 100644 --- a/cscs-checks/prgenv/hip/build_hip.py +++ b/cscs-checks/prgenv/hip/build_hip.py @@ -62,8 +62,8 @@ class HelloHip(rfm.RegressionTest): maintainers = ['JO'] tags = {'production'} - def __init__(self): - # FIXME: PR #1868 should move this into the class body. + @rfm.run_after('init') + def set_deps(self): self.depends_on('BuildHip') @rfm.require_deps