From d5b8b0600aa7938354775805fd951b1f8529eece Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Tue, 24 Sep 2024 08:29:16 -0600 Subject: random123: Add support for HIP/rocm. (#46284) --- .../repos/builtin/packages/random123/package.py | 3 + .../builtin/packages/random123/v1140-hip.patch | 296 +++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 var/spack/repos/builtin/packages/random123/v1140-hip.patch (limited to 'var') diff --git a/var/spack/repos/builtin/packages/random123/package.py b/var/spack/repos/builtin/packages/random123/package.py index efcd5e9b87..e474f88279 100644 --- a/var/spack/repos/builtin/packages/random123/package.py +++ b/var/spack/repos/builtin/packages/random123/package.py @@ -16,6 +16,8 @@ class Random123(Package): homepage = "https://www.deshawresearch.com/resources_random123.html" url = "https://github.com/DEShawResearch/random123/archive/refs/tags/v1.14.0.tar.gz" + maintainers("KineticTheory") + version("1.14.0", sha256="effafd8656b18030b2a5b995cd3650c51a7c45052e6e1c21e48b9fa7a59d926e") version( "1.13.2", @@ -39,6 +41,7 @@ class Random123(Package): patch("ibmxl.patch", when="@1.09") patch("arm-gcc.patch", when="@1.09") patch("v1132-xl161.patch", when="@1.13.2") + patch("v1140-hip.patch", when="@1.14.0") def install(self, spec, prefix): # Random123 doesn't have a build system. diff --git a/var/spack/repos/builtin/packages/random123/v1140-hip.patch b/var/spack/repos/builtin/packages/random123/v1140-hip.patch new file mode 100644 index 0000000000..4e3ef56a12 --- /dev/null +++ b/var/spack/repos/builtin/packages/random123/v1140-hip.patch @@ -0,0 +1,296 @@ +warning: refname 'v1.14.0' is ambiguous. +diff --git a/include/Random123/array.h b/include/Random123/array.h +index 8076f23..06650ec 100644 +--- a/include/Random123/array.h ++++ b/include/Random123/array.h +@@ -81,7 +81,7 @@ inline R123_CUDA_DEVICE value_type assemble_from_u32(uint32_t *p32){ + + /** @endcond */ + +-#ifdef __CUDA_ARCH__ ++#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__) + /* CUDA can't handle std::reverse_iterator. We *could* implement it + ourselves, but let's not bother until somebody really feels a need + to reverse-iterate through an r123array */ +@@ -114,8 +114,8 @@ inline R123_CUDA_DEVICE value_type assemble_from_u32(uint32_t *p32){ + enum {static_size = _N}; \ + R123_CUDA_DEVICE reference operator[](size_type i){return v[i];} \ + R123_CUDA_DEVICE const_reference operator[](size_type i) const {return v[i];} \ +- R123_CUDA_DEVICE reference at(size_type i){ if(i >= _N) R123_THROW(std::out_of_range("array index out of range")); return (*this)[i]; } \ +- R123_CUDA_DEVICE const_reference at(size_type i) const { if(i >= _N) R123_THROW(std::out_of_range("array index out of range")); return (*this)[i]; } \ ++ R123_CUDA_DEVICE reference at(size_type i){ if(i >= _N) {R123_THROW(std::out_of_range("array index out of range"));}; return (*this)[i]; } \ ++ R123_CUDA_DEVICE const_reference at(size_type i) const { if(i >= _N) {R123_THROW(std::out_of_range("array index out of range"));}; return (*this)[i]; } \ + R123_CUDA_DEVICE size_type size() const { return _N; } \ + R123_CUDA_DEVICE size_type max_size() const { return _N; } \ + R123_CUDA_DEVICE bool empty() const { return _N==0; }; \ +diff --git a/include/Random123/boxmuller.hpp b/include/Random123/boxmuller.hpp +index 9c91cf8..16d91f9 100644 +--- a/include/Random123/boxmuller.hpp ++++ b/include/Random123/boxmuller.hpp +@@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + // + // r123::float2 r123::boxmuller(uint32_t u0, uint32_t u1); + // r123::double2 r123::boxmuller(uint64_t u0, uint64_t u1); +-// ++// + // float2 and double2 are identical to their synonymous global- + // namespace structures in CUDA. + // +@@ -68,7 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace r123{ + +-#if !defined(__CUDACC__) ++#if !(defined(__CUDACC__) || defined(__HIPCC__)) + typedef struct { float x, y; } float2; + typedef struct { double x, y; } double2; + #else +diff --git a/include/Random123/features/compilerfeatures.h b/include/Random123/features/compilerfeatures.h +index 0606dee..9ad3f82 100644 +--- a/include/Random123/features/compilerfeatures.h ++++ b/include/Random123/features/compilerfeatures.h +@@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + The Random123 library is portable across C, C++, CUDA, OpenCL environments, + and multiple operating systems (Linux, Windows 7, Mac OS X, FreeBSD, Solaris). + This level of portability requires the abstraction of some features +-and idioms that are either not standardized (e.g., asm statments), or for which ++and idioms that are either not standardized (e.g., asm statments), or for which + different vendors have their own standards (e.g., SSE intrinsics) or for + which vendors simply refuse to conform to well-established standards (e.g., ). + +@@ -55,7 +55,7 @@ Most of the symbols are boolean valued. In general, they will + Library users can override any value by defining the pp-symbol with a compiler option, + e.g., + +- cc -DR123_USE_MULHILO64_C99 ++ cc -DR123_USE_MULHILO64_C99 + + will use a strictly c99 version of the full-width 64x64->128-bit multiplication + function, even if it would be disabled by default. +@@ -84,8 +84,8 @@ All boolean-valued pre-processor symbols in Random123/features/compilerfeatures. + CXX11_EXPLICIT_CONVERSIONS + CXX11_LONG_LONG + CXX11_STD_ARRAY +- CXX11 +- ++ CXX11 ++ + X86INTRIN_H + IA32INTRIN_H + XMMINTRIN_H +@@ -102,7 +102,7 @@ All boolean-valued pre-processor symbols in Random123/features/compilerfeatures. + MULHILO64_C99 + + U01_DOUBLE +- ++ + @endverbatim + Most have obvious meanings. Some non-obvious ones: + +@@ -141,11 +141,11 @@ There are also non-boolean valued symbols: +