Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: HIP_PATH from ROCM_PATH #2948

Merged
merged 5 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/hip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
-DAMReX_LINEAR_SOLVERS=ON \
-DAMReX_GPU_BACKEND=HIP \
-DAMReX_AMD_ARCH=gfx908 \
-DAMReX_ROCTX=ON \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_Fortran_COMPILER=$(which flang) \
Expand Down Expand Up @@ -91,6 +92,7 @@ jobs:
-DAMReX_LINEAR_SOLVERS=ON \
-DAMReX_GPU_BACKEND=HIP \
-DAMReX_AMD_ARCH=gfx908 \
-DAMReX_ROCTX=ON \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which hipcc) \
-DCMAKE_Fortran_COMPILER=$(which gfortran) \
Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_GpuDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#if defined(AMREX_USE_HIP)
#include <hip/hip_runtime.h>
#if defined(AMREX_USE_ROCTX)
#include <roctracer_ext.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make this change, please update Tools/GNUMake/comps/hip.mak.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

#include <roctracer/roctracer_ext.h>
#if defined(AMREX_PROFILING) || defined (AMREX_TINY_PROFILING)
#include <roctx.h>
#include <roctracer/roctx.h>
#endif
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_TinyProfiler.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

#if defined(AMREX_USE_HIP) && defined(AMREX_USE_ROCTX)
#include <roctx.h>
#include <roctracer/roctx.h>
#endif

#include <deque>
Expand Down
20 changes: 14 additions & 6 deletions Tools/CMake/AMReXParallelBackends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ if (AMReX_HIP)
unset(_valid_hip_compilers)

if(NOT DEFINED HIP_PATH)
if(NOT DEFINED ENV{HIP_PATH})
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
else()
if(DEFINED ENV{HIP_PATH})
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
elseif(DEFINED ENV{ROCM_PATH})
set(HIP_PATH "$ENV{ROCM_PATH}/hip" CACHE PATH "Path to which HIP has been installed")
else()
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
endif()
endif()

Expand Down Expand Up @@ -255,9 +257,15 @@ if (AMReX_HIP)
if(AMReX_ROCTX)
# To be modernized in the future, please see:
# https://github.com/ROCm-Developer-Tools/roctracer/issues/56
target_include_directories(amrex PUBLIC ${HIP_PATH}/../roctracer/include ${HIP_PATH}/../rocprofiler/include)
target_link_libraries(amrex PUBLIC "-L${HIP_PATH}/../roctracer/lib/ -lroctracer64" "-L${HIP_PATH}/../roctracer/lib -lroctx64")
endif ()
target_include_directories(amrex SYSTEM PUBLIC
${HIP_PATH}/../roctracer/include
${HIP_PATH}/../rocprofiler/include
)
target_link_libraries(amrex PUBLIC
"-L${HIP_PATH}/../roctracer/lib -lroctracer64"
"-L${HIP_PATH}/../roctracer/lib -lroctx64"
)
endif()
target_link_libraries(amrex PUBLIC hip::hiprand roc::rocrand roc::rocprim)

# avoid forcing the rocm LLVM flags on a gfortran
Expand Down
13 changes: 6 additions & 7 deletions Tools/GNUMake/comps/hip.mak
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ifeq ($(HIP_COMPILER),clang)

# Generic HIP info
ROC_PATH=$(realpath $(dir $(HIP_PATH)))
SYSTEM_INCLUDE_LOCATIONS += $(HIP_PATH)/include
SYSTEM_INCLUDE_LOCATIONS += $(ROC_PATH)/include $(HIP_PATH)/include

# rocRand
SYSTEM_INCLUDE_LOCATIONS += $(ROC_PATH)/include/hiprand $(ROC_PATH)/include/rocrand
Expand All @@ -120,13 +120,12 @@ ifeq ($(HIP_COMPILER),clang)
# rocThrust - Header only
# SYSTEM_INCLUDE_LOCATIONS += $(ROC_PATH)/include/rocthrust

ifeq ($(USE_ROCTX),TRUE)
# rocTracer
CXXFLAGS += -DAMREX_USE_ROCTX
HIPCC_FLAGS += -DAMREX_USE_ROCTX
SYSTEM_INCLUDE_LOCATIONS += $(ROC_PATH)/include/roctracer $(ROC_PATH)/include/rocprofiler
LIBRARY_LOCATIONS += $(ROC_PATH)/lib
LIBRARIES += -lroctracer64 -lroctx64
ifeq ($(USE_ROCTX),TRUE)
CXXFLAGS += -DAMREX_USE_ROCTX
HIPCC_FLAGS += -DAMREX_USE_ROCTX
LIBRARY_LOCATIONS += $(ROC_PATH)/lib
LIBRARIES += -Wl,--rpath=$(ROC_PATH)/lib -lroctracer64 -lroctx64
endif

# hipcc passes a lot of unused arguments to clang
Expand Down