Skip to content

Commit

Permalink
Merge pull request #2002 from glotzerlab/rocm6
Browse files Browse the repository at this point in the history
Support rocm6.
  • Loading branch information
joaander authored Feb 20, 2025
2 parents cf54cff + 8d0bf70 commit 6895476
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ Change Log
(`#1970 <https://github.com/glotzerlab/hoomd-blue/pull/1970>`__).
* ``mpcd.update.ReverseNonequilibriumShearFlow``
(`#1983 <https://github.com/glotzerlab/hoomd-blue/pull/1983>`__).
* Support rocm 6
(`#2002 <https://github.com/glotzerlab/hoomd-blue/pull/2002>`__).

*Fixed*

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

*Removed*

* Support for rocm5
(`#2002 <https://github.com/glotzerlab/hoomd-blue/pull/2002>`__).

5.0.1 (2025-01-20)
^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 5 additions & 2 deletions CMake/hoomd/FindCUDALibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ else()
add_library(CUDA::cusparse UNKNOWN IMPORTED)
endif()

if (HIP_PLATFORM STREQUAL "hip-clang")
find_package(hipfft)
if (HIP_PLATFORM STREQUAL "amd")
find_package(hipfft REQUIRED)
include_directories("${hipfft_INCLUDE_DIR}")
include_directories("${hipfft_INCLUDE_DIR}/hipfft")
message("Found hipfft includes: ${hipfft_INCLUDE_DIR}")
endif()

if (HIP_PLATFORM STREQUAL "nvcc")
Expand Down
8 changes: 5 additions & 3 deletions CMake/hoomd/HOOMDCUDASetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ if (ENABLE_HIP)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode=arch=compute_${_cuda_max_arch},code=compute_${_cuda_max_arch}")
endif()

elseif(HIP_PLATFORM STREQUAL "hip-clang")
elseif(HIP_PLATFORM STREQUAL "amd")
set(_cuda_min_arch 35)

# ignore warnings about unused results
set(CMAKE_HIP_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-unused-result")
# ignore warnings about unused results and set HIP_PLATFORM_HCC (which was previously
# set by rocm < 6.0.0)
set(CMAKE_HIP_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-unused-result -D__HIP_PLATFORM_HCC__")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__HIP_PLATFORM_HCC__")
endif()
endif (ENABLE_HIP)

Expand Down
8 changes: 4 additions & 4 deletions CMake/hoomd/HOOMDHIPSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ if(ENABLE_HIP)
SET(HOOMD_DEVICE_LANGUAGE HIP)

# setup nvcc to build for all CUDA architectures. Allow user to modify the list if desired
set(CMAKE_HIP_ARCHITECTURES gfx900 gfx906 gfx908 gfx90a CACHE STRING "List of AMD GPU to compile HIP code for. Separate with semicolons.")
set(HIP_PLATFORM hip-clang)
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.")
set(HIP_PLATFORM amd)
elseif (HOOMD_GPU_PLATFORM STREQUAL "CUDA")
# here we go if hipcc is not available, fall back on internal HIP->CUDA headers
ENABLE_LANGUAGE(CUDA)
Expand Down Expand Up @@ -48,8 +48,8 @@ if(ENABLE_HIP)
# branch upon HCC or NVCC target
if(${HIP_PLATFORM} STREQUAL "nvcc")
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS __HIP_PLATFORM_NVCC__)
elseif(${HIP_PLATFORM} STREQUAL "hip-clang")
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS __HIP_PLATFORM_AMD__)
elseif(${HIP_PLATFORM} STREQUAL "amd")
set_property(TARGET hip::host APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS __HIP_PLATFORM_AMD__ __HIP_PLATFORM_HCC__)
endif()

find_package(CUDALibs REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion hoomd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ target_compile_definitions(_hoomd PUBLIC HOOMD_LONGREAL_SIZE=${HOOMD_LONGREAL_SI

# Libraries and compile definitions for CUDA enabled builds
if (ENABLE_HIP)
if (HIP_PLATFORM STREQUAL "hip-clang")
if (HIP_PLATFORM STREQUAL "amd")
target_link_libraries(_hoomd PUBLIC hip::hipfft)
elseif(HIP_PLATFORM STREQUAL "nvcc")
target_link_libraries(_hoomd PUBLIC CUDA::cudart CUDA::cufft)
Expand Down
26 changes: 15 additions & 11 deletions hoomd/HOOMDMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ inline HOSTDEVICE float rsqrt(float x)
return ::rsqrtf(x);
#elif defined(__HIP_PLATFORM_HCC__)
return ::__frsqrt_rn(x);
#elif defined(__HIP_PLATFORM_AMD__)
return ::__frsqrt_rn(x);
#endif
#else
return 1.0f / ::sqrtf(x);
Expand Down Expand Up @@ -727,6 +729,19 @@ HOSTDEVICE inline hoomd::Scalar3& operator+=(hoomd::Scalar3& a, const hoomd::Sca
a.z += b.z;
return a;
}

//! Vector multiplication (component-wise)
HOSTDEVICE inline hoomd::Scalar3 operator*(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
{
return hoomd::make_scalar3(a.x * b.x, a.y * b.y, a.z * b.z);
}

//! Vector division (component-wise)
HOSTDEVICE inline hoomd::Scalar3 operator/(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
{
return hoomd::make_scalar3(a.x / b.x, a.y / b.y, a.z / b.z);
}

#endif

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

//! Vector multiplication (component-wise)
HOSTDEVICE inline hoomd::Scalar3 operator*(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
{
return hoomd::make_scalar3(a.x * b.x, a.y * b.y, a.z * b.z);
}

//! Vector multiplication
HOSTDEVICE inline hoomd::Scalar3& operator*=(hoomd::Scalar3& a, const hoomd::Scalar3& b)
{
Expand All @@ -758,11 +767,6 @@ HOSTDEVICE inline hoomd::Scalar3& operator*=(hoomd::Scalar3& a, const hoomd::Sca
return a;
}

//! Vector division (component-wise)
HOSTDEVICE inline hoomd::Scalar3 operator/(const hoomd::Scalar3& a, const hoomd::Scalar3& b)
{
return hoomd::make_scalar3(a.x / b.x, a.y / b.y, a.z / b.z);
}
//! Scalar - vector multiplication
HOSTDEVICE inline hoomd::Scalar3 operator*(const hoomd::Scalar& a, const hoomd::Scalar3& b)
{
Expand Down
2 changes: 1 addition & 1 deletion hoomd/extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_library(hipper INTERFACE)
add_library(HOOMD::hipper ALIAS hipper)
target_include_directories(hipper INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/hipper/include>
$<INSTALL_INTERFACE:${PYTHON_SITE_INSTALL_DIR}/include/hoomd/extern/hipper/include>)
if (HIP_PLATFORM STREQUAL "hcc" OR HIP_PLATFORM STREQUAL "hip-clang")
if (HIP_PLATFORM STREQUAL "hcc" OR HIP_PLATFORM STREQUAL "amd")
target_compile_definitions(hipper INTERFACE HIPPER_HIP)
elseif(HIP_PLATFORM STREQUAL "nvcc")
target_compile_definitions(hipper INTERFACE HIPPER_CUDA)
Expand Down

0 comments on commit 6895476

Please sign in to comment.