Skip to content

Commit

Permalink
Change HIP_PLATFORM from HCC to AMD and NVCC to NVIDIA (#713)
Browse files Browse the repository at this point in the history
Co-authored-by: Rakesh Roy <[email protected]>
  • Loading branch information
rakesroy and rakesroy authored Nov 2, 2023
1 parent ca23135 commit e68c5fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
14 changes: 5 additions & 9 deletions cmake/FindHIP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,14 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN)
endif()

if(HIP_PLATFORM)
if(${HIP_PLATFORM} STREQUAL "hcc" OR ${HIP_PLATFORM} STREQUAL "amd")
if(${HIP_COMPILER} STREQUAL "hcc")
set(HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include;${HIP_ROOT_DIR}/hcc/include")
set(HIP_LIBRARIES "${HIP_ROOT_DIR}/lib/libhip_hcc.so")
set(HIP_RUNTIME_DEFINE "__HIP_PLATFORM_HCC__")
elseif(${HIP_COMPILER} STREQUAL "clang")
if(${HIP_PLATFORM} STREQUAL "amd")
if(${HIP_COMPILER} STREQUAL "clang")
set(HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include")
set(HIP_LIBRARIES "${HIP_ROOT_DIR}/lib/libamdhip64.so")
set(HIP_RUNTIME_DEFINE "__HIP_PLATFORM_HCC__")
set(HIP_RUNTIME_DEFINE "__HIP_PLATFORM_AMD__")
set(HIP_PLATFORM "hip-clang")
endif()
elseif(${HIP_PLATFORM} STREQUAL "nvcc")
elseif(${HIP_PLATFORM} STREQUAL "nvidia")
find_package(CUDA)

#find the shared library, rather than the static that find_package returns
Expand All @@ -127,7 +123,7 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN)

set(HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include;${CUDA_INCLUDE_DIRS}")
set(HIP_LIBRARIES "${CUDART_LIB};cuda")
set(HIP_RUNTIME_DEFINE "__HIP_PLATFORM_NVCC__")
set(HIP_RUNTIME_DEFINE "__HIP_PLATFORM_NVIDIA__")
endif()
endif()
mark_as_advanced(HIP_INCLUDE_DIRS)
Expand Down
20 changes: 8 additions & 12 deletions scripts/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,19 @@ ifdef OCCA_HIP_ENABLED
hipPlatform = $(HIP_PLATFORM)
endif

ifeq ($(hipPlatform),nvcc)
ifeq ($(hipPlatform),nvidia)
linkerFlags += -lcuda
linkerFlags += -lcudart
else ifeq ($(hipPlatform),$(filter $(hipPlatform),hcc amd))
else ifeq ($(hipPlatform),amd)
#set HIP_COMPILER if not supplied by user
ifeq (,$(HIP_COMPILER))
hipCompiler = $(shell $(HIP_PATH)/bin/hipconfig --compiler)
else
hipCompiler = $(HIP_COMPILER)
endif

#Select HCC or HIP Runtime
ifeq ($(hipCompiler),hcc)
linkerFlags += -lhip_hcc
else ifeq ($(hipCompiler),clang)
#Select HIP Runtime
ifeq ($(hipCompiler),clang)
linkerFlags += -lamdhip64
endif
endif
Expand All @@ -366,21 +364,19 @@ else
hipPlatform = $(HIP_PLATFORM)
endif

ifeq ($(hipPlatform),nvcc)
ifeq ($(hipPlatform),nvidia)
hipLibFlags = $(call libraryFlagsFor,cuda)
hipLibFlags += $(call libraryFlagsFor,cudart)
else ifeq ($(hipPlatform),$(filter $(hipPlatform),hcc amd))
else ifeq ($(hipPlatform),amd)
#set HIP_COMPILER if not supplied by user
ifeq (,$(HIP_COMPILER))
hipCompiler = $(shell $(HIP_PATH)/bin/hipconfig --compiler)
else
hipCompiler = $(HIP_COMPILER)
endif

#Select HCC or HIP Runtime
ifeq ($(hipCompiler),hcc)
hipLibFlags = $(call libraryFlagsFor,hip_hcc)
else ifeq ($(hipCompiler),clang)
#Select HIP Runtime
ifeq ($(hipCompiler),clang)
hipLibFlags = $(call libraryFlagsFor,amdhip64)
endif
endif
Expand Down
4 changes: 2 additions & 2 deletions src/occa/internal/modes/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ namespace occa {
//---[ Compiling Command ]--------
command << compiler
<< " --genco"
#if defined(__HIP_PLATFORM_NVCC___) || (HIP_VERSION >= 305)
#if defined(__HIP_PLATFORM_NVIDIA__) || (HIP_VERSION >= 305)
<< ' ' << compilerFlags
#else
<< " -f=\\\"" << compilerFlags << "\\\""
#endif
<< ' ' << hipccCompilerFlags;
#if defined(__HIP_PLATFORM_NVCC___) || (HIP_VERSION >= 305)
#if defined(__HIP_PLATFORM_NVIDIA__) || (HIP_VERSION >= 305)
const bool includeOcca = kernelProps.get("kernel/include_occa", false);
const bool linkOcca = kernelProps.get("kernel/link_occa", false);
if (includeOcca) {
Expand Down

0 comments on commit e68c5fd

Please sign in to comment.