Skip to content

Commit

Permalink
enabling test for rccl hsakmt-roct and rocm-opencl (spack#35465)
Browse files Browse the repository at this point in the history
* initial commit for enabling test for rccl hsakmt-roct and rocm-opencl
* fix styling and cleaning code
* adding missing imports and minor fixes
* minor style fix
* moidfying hsakmt-roct test to run right after installation
  • Loading branch information
afzpatel authored Apr 21, 2023
1 parent bf970eb commit 134b954
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
36 changes: 36 additions & 0 deletions var/spack/repos/builtin/packages/hsakmt-roct/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)


import os

from spack.package import *


Expand Down Expand Up @@ -113,6 +115,7 @@ class HsakmtRoct(CMakePackage):
depends_on("cmake@3:", type="build")
depends_on("numactl")
depends_on("libdrm", when="@4.5.0:")
depends_on("llvm-amdgpu", type="test", when="@5.3.0:")

# See https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/issues/72
# and https://github.com/spack/spack/issues/28398
Expand All @@ -128,3 +131,36 @@ def install_targets(self):

def cmake_args(self):
return [self.define_from_variant("BUILD_SHARED_LIBS", "shared")]

@run_after("install")
@on_package_attributes(run_tests=True)
def check_install(self):
if self.spec.satisfies("@:5.3.0"):
print("Skipping: stand-alone tests")
return
test_dir = "tests/kfdtest"
with working_dir(test_dir, create=True):
cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake")
prefixes = ";".join(
[
self.spec["libdrm"].prefix,
self.spec["hsakmt-roct"].prefix,
self.spec["numactl"].prefix,
self.spec["pkgconfig"].prefix,
self.spec["llvm-amdgpu"].prefix,
self.spec["zlib"].prefix,
self.spec["ncurses"].prefix,
]
)
hsakmt_path = ";".join([self.spec["hsakmt-roct"].prefix])
cc_options = [
"-DCMAKE_PREFIX_PATH=" + prefixes,
"-DLIBHSAKMT_PATH=" + hsakmt_path,
".",
]
self.run_test(cmake_bin, cc_options)
make()
os.environ["LD_LIBRARY_PATH"] = hsakmt_path
os.environ["BIN_DIR"] = os.getcwd()
self.run_test("scripts/run_kfdtest.sh")
make("clean")
11 changes: 11 additions & 0 deletions var/spack/repos/builtin/packages/rccl/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class Rccl(CMakePackage):
"5.4.3",
]:
depends_on("rocm-smi-lib@" + ver, when="@" + ver)
depends_on("chrpath", when="@5.3.0:")

@classmethod
def determine_version(cls, lib):
Expand Down Expand Up @@ -216,4 +217,14 @@ def cmake_args(self):

if self.spec.satisfies("@4.5.0:"):
args.append(self.define("ROCM_SMI_DIR", self.spec["rocm-smi-lib"].prefix))
if self.spec.satisfies("@5.3.0:"):
args.append(self.define("BUILD_TESTS", "ON"))
return args

def test(self):
if self.spec.satisfies("@:5.3.0"):
print("Skipping: stand-alone tests")
return
test_dir = join_path(self.spec["rccl"].prefix, "bin")
with working_dir(test_dir, create=True):
self.run_test("UnitTests")
14 changes: 13 additions & 1 deletion var/spack/repos/builtin/packages/rocm-opencl/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import os
import re

from spack.package import *
Expand Down Expand Up @@ -229,7 +230,7 @@ def flag_handler(self, name, flags):
return (flags, None, None)

def cmake_args(self):
args = ["-DUSE_COMGR_LIBRARY=yes"]
args = ["-DUSE_COMGR_LIBRARY=yes", "-DBUILD_TESTS=ON"]
if self.spec.satisfies("@:4.3.0"):
"-DROCclr_DIR={0}".format(self.spec["hip-rocclr"].prefix),
"-DLIBROCclr_STATIC_DIR={0}/lib".format
Expand All @@ -251,3 +252,14 @@ def post_install(self):
config_file_name = "amdocl64_30800.icd"
with open(join_path(vendor_config_path, config_file_name), "w") as f:
f.write("libamdocl64.so")

test_src_dir = "tests/ocltst"

def test(self):
test_dir = join_path(self.spec["rocm-opencl"].prefix, self.test_src_dir)
with working_dir(test_dir, create=True):
os.environ["LD_LIBRARY_PATH"] += os.pathsep + test_dir
args = ["-m", "liboclruntime.so", "-A", "oclruntime.exclude"]
self.run_test("ocltst", args)
args = ["-m", "liboclperf.so", "-A", "oclperf.exclude"]
self.run_test("ocltst", args)

0 comments on commit 134b954

Please sign in to comment.