summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorafzpatel <122491982+afzpatel@users.noreply.github.com>2023-07-10 16:05:46 -0400
committerGitHub <noreply@github.com>2023-07-10 13:05:46 -0700
commitdb23fd055ce17b48a21d307140ff4136acd64299 (patch)
tree606283944081485b481dabdd3a27b881c4b6fa46 /var
parent73acf110ff834c43e210854a3260ea18e5c83bfc (diff)
downloadspack-db23fd055ce17b48a21d307140ff4136acd64299.tar.gz
spack-db23fd055ce17b48a21d307140ff4136acd64299.tar.bz2
spack-db23fd055ce17b48a21d307140ff4136acd64299.tar.xz
spack-db23fd055ce17b48a21d307140ff4136acd64299.zip
new hip-examples package (#35891)
* initial commit for adding hip-examples package * adding test to hip-examples * fixed compile error on add4 * change standalone test to use new syntax
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/hip-examples/0001-add-inc-and-lib-paths-to-openmp-helloworld.patch12
-rw-r--r--var/spack/repos/builtin/packages/hip-examples/0002-add-fpic-compile-to-add4.patch9
-rw-r--r--var/spack/repos/builtin/packages/hip-examples/package.py64
3 files changed, 85 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/hip-examples/0001-add-inc-and-lib-paths-to-openmp-helloworld.patch b/var/spack/repos/builtin/packages/hip-examples/0001-add-inc-and-lib-paths-to-openmp-helloworld.patch
new file mode 100644
index 0000000000..385b2d1116
--- /dev/null
+++ b/var/spack/repos/builtin/packages/hip-examples/0001-add-inc-and-lib-paths-to-openmp-helloworld.patch
@@ -0,0 +1,12 @@
+diff --git a/openmp-helloworld/Makefile b/openmp-helloworld/Makefile
+index f048d26..3e0d5ac 100644
+--- a/openmp-helloworld/Makefile
++++ b/openmp-helloworld/Makefile
+@@ -6,6 +6,8 @@ endif
+ HIPCC=$(HIP_PATH)/bin/hipcc
+ CXX=$(HIPCC)
+ CXXFLAGS =-fopenmp
++CXXFLAGS += -I$(ROCM_OPENMP_EXTRAS_DIR)/include
++CXXFLAGS += -L$(ROCM_OPENMP_EXTRAS_DIR)/lib
+
+ SOURCES = openmp_helloworld.cpp
diff --git a/var/spack/repos/builtin/packages/hip-examples/0002-add-fpic-compile-to-add4.patch b/var/spack/repos/builtin/packages/hip-examples/0002-add-fpic-compile-to-add4.patch
new file mode 100644
index 0000000000..a858fd44e0
--- /dev/null
+++ b/var/spack/repos/builtin/packages/hip-examples/0002-add-fpic-compile-to-add4.patch
@@ -0,0 +1,9 @@
+diff --git a/add4/Makefile b/add4/Makefile
+index a0c6826..d7b26b1 100644
+--- a/add4/Makefile
++++ b/add4/Makefile
+@@ -1,4 +1,4 @@
+-CXXFLAGS += -std=c++11 -O3
++CXXFLAGS += -std=c++11 -O3 -fPIC
+
+ all: gpu-stream-hip
diff --git a/var/spack/repos/builtin/packages/hip-examples/package.py b/var/spack/repos/builtin/packages/hip-examples/package.py
new file mode 100644
index 0000000000..c625d0fe4b
--- /dev/null
+++ b/var/spack/repos/builtin/packages/hip-examples/package.py
@@ -0,0 +1,64 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+import os
+
+from spack.package import *
+
+
+class HipExamples(Package):
+ """Examples for HIP"""
+
+ homepage = "https://github.com/ROCm-Developer-Tools/HIP-Examples/"
+ git = "https://github.com/ROCm-Developer-Tools/HIP-Examples.git"
+ url = "https://github.com/ROCm-Developer-Tools/HIP-Examples/archive/rocm-5.4.3.tar.gz"
+ tags = ["rocm"]
+
+ maintainers("srekolam", "renjithravindrankannath", "afzpatel")
+
+ version("master", branch="master")
+
+ version("5.4.3", sha256="053b8b7892e2929e3f90bd978d8bb1c9801e4803eadd7d97fc6692ce60af1d47")
+
+ patch("0001-add-inc-and-lib-paths-to-openmp-helloworld.patch")
+ patch("0002-add-fpic-compile-to-add4.patch")
+ depends_on("hip")
+ depends_on("rocm-openmp-extras")
+
+ def install(self, spec, prefix):
+ stage = os.getcwd()
+ os.environ["ROCM_OPENMP_EXTRAS_DIR"] = self.spec["rocm-openmp-extras"].prefix
+ os.environ["LD_LIBRARY_PATH"] = self.spec["rocm-openmp-extras"].prefix.lib
+ for root, dirs, files in os.walk(stage):
+ if "Makefile" in files:
+ with working_dir(root, create=True):
+ make()
+ # itterate through the files in dir to find the newly built binary
+ for file in os.listdir("."):
+ if file not in files and os.path.isfile(file) and os.access(file, os.X_OK):
+ install(file, join_path(prefix, file))
+ if file == "RecursiveGaussian":
+ install(
+ "RecursiveGaussian_Input.bmp",
+ join_path(prefix, "RecursiveGaussian_Input.bmp"),
+ )
+
+ def test_examples(self):
+ """
+ run all hip example binaries
+ """
+
+ os.environ["LD_LIBRARY_PATH"] = self.spec["rocm-openmp-extras"].prefix.lib
+ test_dir = self.prefix
+ for file_name in os.listdir(test_dir):
+ file_path = join_path(test_dir, file_name)
+ if os.path.isfile(file_path) and os.access(file_path, os.X_OK):
+ with test_part(
+ self,
+ "test_example_{0}".format(file_name),
+ purpose="run installed {0}".format(file_name),
+ ):
+ exe = which(file_path)
+ exe()