Skip to content

Commit 6895476

Browse files
authored
Merge pull request #2002 from glotzerlab/rocm6
Support rocm6.
2 parents cf54cff + 8d0bf70 commit 6895476

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ Change Log
1313
(`#1970 <https://github.com/glotzerlab/hoomd-blue/pull/1970>`__).
1414
* ``mpcd.update.ReverseNonequilibriumShearFlow``
1515
(`#1983 <https://github.com/glotzerlab/hoomd-blue/pull/1983>`__).
16+
* Support rocm 6
17+
(`#2002 <https://github.com/glotzerlab/hoomd-blue/pull/2002>`__).
1618

1719
*Fixed*
1820

1921
* Correctly reference ``TriggeredOperation`` in inherited documentation
2022
(`#1990 <https://github.com/glotzerlab/hoomd-blue/pull/1990>`__).
2123

24+
*Removed*
25+
26+
* Support for rocm5
27+
(`#2002 <https://github.com/glotzerlab/hoomd-blue/pull/2002>`__).
2228

2329
5.0.1 (2025-01-20)
2430
^^^^^^^^^^^^^^^^^^

CMake/hoomd/FindCUDALibs.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ else()
105105
add_library(CUDA::cusparse UNKNOWN IMPORTED)
106106
endif()
107107

108-
if (HIP_PLATFORM STREQUAL "hip-clang")
109-
find_package(hipfft)
108+
if (HIP_PLATFORM STREQUAL "amd")
109+
find_package(hipfft REQUIRED)
110+
include_directories("${hipfft_INCLUDE_DIR}")
111+
include_directories("${hipfft_INCLUDE_DIR}/hipfft")
112+
message("Found hipfft includes: ${hipfft_INCLUDE_DIR}")
110113
endif()
111114

112115
if (HIP_PLATFORM STREQUAL "nvcc")

CMake/hoomd/HOOMDCUDASetup.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ if (ENABLE_HIP)
5151
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode=arch=compute_${_cuda_max_arch},code=compute_${_cuda_max_arch}")
5252
endif()
5353

54-
elseif(HIP_PLATFORM STREQUAL "hip-clang")
54+
elseif(HIP_PLATFORM STREQUAL "amd")
5555
set(_cuda_min_arch 35)
5656

57-
# ignore warnings about unused results
58-
set(CMAKE_HIP_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-unused-result")
57+
# ignore warnings about unused results and set HIP_PLATFORM_HCC (which was previously
58+
# set by rocm < 6.0.0)
59+
set(CMAKE_HIP_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-unused-result -D__HIP_PLATFORM_HCC__")
60+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__HIP_PLATFORM_HCC__")
5961
endif()
6062
endif (ENABLE_HIP)
6163

CMake/hoomd/HOOMDHIPSetup.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ if(ENABLE_HIP)
77
SET(HOOMD_DEVICE_LANGUAGE HIP)
88

99
# setup nvcc to build for all CUDA architectures. Allow user to modify the list if desired
10-
set(CMAKE_HIP_ARCHITECTURES gfx900 gfx906 gfx908 gfx90a CACHE STRING "List of AMD GPU to compile HIP code for. Separate with semicolons.")
11-
set(HIP_PLATFORM hip-clang)
10+
set(CMAKE_HIP_ARCHITECTURES gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 CACHE STRING "List of AMD GPU to compile HIP code for. Separate with semicolons.")
11+
set(HIP_PLATFORM amd)
1212
elseif (HOOMD_GPU_PLATFORM STREQUAL "CUDA")
1313
# here we go if hipcc is not available, fall back on internal HIP->CUDA headers
1414
ENABLE_LANGUAGE(CUDA)
@@ -48,8 +48,8 @@ if(ENABLE_HIP)
4848
# branch upon HCC or NVCC target
4949
if(${HIP_PLATFORM} STREQUAL "nvcc")
5050
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS __HIP_PLATFORM_NVCC__)
51-
elseif(${HIP_PLATFORM} STREQUAL "hip-clang")
52-
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS __HIP_PLATFORM_AMD__)
51+
elseif(${HIP_PLATFORM} STREQUAL "amd")
52+
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS __HIP_PLATFORM_AMD__ __HIP_PLATFORM_HCC__)
5353
endif()
5454

5555
find_package(CUDALibs REQUIRED)

hoomd/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ target_compile_definitions(_hoomd PUBLIC HOOMD_LONGREAL_SIZE=${HOOMD_LONGREAL_SI
265265

266266
# Libraries and compile definitions for CUDA enabled builds
267267
if (ENABLE_HIP)
268-
if (HIP_PLATFORM STREQUAL "hip-clang")
268+
if (HIP_PLATFORM STREQUAL "amd")
269269
target_link_libraries(_hoomd PUBLIC hip::hipfft)
270270
elseif(HIP_PLATFORM STREQUAL "nvcc")
271271
target_link_libraries(_hoomd PUBLIC CUDA::cudart CUDA::cufft)

hoomd/HOOMDMath.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ inline HOSTDEVICE float rsqrt(float x)
237237
return ::rsqrtf(x);
238238
#elif defined(__HIP_PLATFORM_HCC__)
239239
return ::__frsqrt_rn(x);
240+
#elif defined(__HIP_PLATFORM_AMD__)
241+
return ::__frsqrt_rn(x);
240242
#endif
241243
#else
242244
return 1.0f / ::sqrtf(x);
@@ -727,6 +729,19 @@ HOSTDEVICE inline hoomd::Scalar3& operator+=(hoomd::Scalar3& a, const hoomd::Sca
727729
a.z += b.z;
728730
return a;
729731
}
732+
733+
//! Vector multiplication (component-wise)
734+
HOSTDEVICE inline hoomd::Scalar3 operator*(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
735+
{
736+
return hoomd::make_scalar3(a.x * b.x, a.y * b.y, a.z * b.z);
737+
}
738+
739+
//! Vector division (component-wise)
740+
HOSTDEVICE inline hoomd::Scalar3 operator/(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
741+
{
742+
return hoomd::make_scalar3(a.x / b.x, a.y / b.y, a.z / b.z);
743+
}
744+
730745
#endif
731746

732747
//! Vector subtraction
@@ -743,12 +758,6 @@ HOSTDEVICE inline hoomd::Scalar3& operator-=(hoomd::Scalar3& a, const hoomd::Sca
743758
return a;
744759
}
745760

746-
//! Vector multiplication (component-wise)
747-
HOSTDEVICE inline hoomd::Scalar3 operator*(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
748-
{
749-
return hoomd::make_scalar3(a.x * b.x, a.y * b.y, a.z * b.z);
750-
}
751-
752761
//! Vector multiplication
753762
HOSTDEVICE inline hoomd::Scalar3& operator*=(hoomd::Scalar3& a, const hoomd::Scalar3& b)
754763
{
@@ -758,11 +767,6 @@ HOSTDEVICE inline hoomd::Scalar3& operator*=(hoomd::Scalar3& a, const hoomd::Sca
758767
return a;
759768
}
760769

761-
//! Vector division (component-wise)
762-
HOSTDEVICE inline hoomd::Scalar3 operator/(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
763-
{
764-
return hoomd::make_scalar3(a.x / b.x, a.y / b.y, a.z / b.z);
765-
}
766770
//! Scalar - vector multiplication
767771
HOSTDEVICE inline hoomd::Scalar3 operator*(const hoomd::Scalar& a, const hoomd::Scalar3& b)
768772
{

hoomd/extern/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ add_library(hipper INTERFACE)
1313
add_library(HOOMD::hipper ALIAS hipper)
1414
target_include_directories(hipper INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/hipper/include>
1515
$<INSTALL_INTERFACE:${PYTHON_SITE_INSTALL_DIR}/include/hoomd/extern/hipper/include>)
16-
if (HIP_PLATFORM STREQUAL "hcc" OR HIP_PLATFORM STREQUAL "hip-clang")
16+
if (HIP_PLATFORM STREQUAL "hcc" OR HIP_PLATFORM STREQUAL "amd")
1717
target_compile_definitions(hipper INTERFACE HIPPER_HIP)
1818
elseif(HIP_PLATFORM STREQUAL "nvcc")
1919
target_compile_definitions(hipper INTERFACE HIPPER_CUDA)

0 commit comments

Comments
 (0)