Skip to content

Commit 0e005f7

Browse files
committed
Build file changes
Now HIP Clang is not required, the CMake scripts will configure the needed compiler, which can be system clang++. Also other code can still use GCC, but CMake will force the clang to link.
1 parent 54a63c1 commit 0e005f7

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

CMakeLists.txt

+10-14
Original file line numberDiff line numberDiff line change
@@ -170,27 +170,23 @@ if (LLAMA_CUBLAS)
170170
endif()
171171

172172
if (LLAMA_HIPBLAS)
173-
cmake_minimum_required(VERSION 3.21)
174-
175173
find_package(hip)
176174
find_package(hipblas)
177175

178-
if (hipblas_FOUND)
176+
if (${hipblas_FOUND} AND ${hip_FOUND})
179177
message(STATUS "hipBLAS found")
178+
add_compile_definitions(GGML_USE_HIPBLAS)
179+
enable_language(HIP)
180+
add_library(ggml-hip OBJECT ggml-cuda.cu ggml-cuda.h)
181+
set_source_files_properties(ggml-cuda.cu PROPERTIES LANGUAGE HIP)
182+
target_link_libraries(ggml-hip PRIVATE hip::device)
180183

181-
set(LLAMA_HIPBLAS_PLATFORM "AMD" CACHE STRING "hip device type" FORCE)
182-
set_property(CACHE LLAMA_HIPBLAS_PLATFORM PROPERTY STRINGS "AMD" "NVIDIA")
183-
184-
add_compile_definitions(GGML_USE_HIPBLAS "__HIP_PLATFORM_${LLAMA_HIPBLAS_PLATFORM}__")
185-
186-
add_library(ggml-hip OBJECT ggml-cuda.cu)
187-
set_source_files_properties(ggml-cuda.cu PROPERTIES LANGUAGE CXX)
188-
target_link_libraries(ggml-hip hip::device)
189-
184+
if (LLAMA_STATIC)
185+
message(FATAL_ERROR "Static linking not supported for HIP/ROCm")
186+
endif()
190187
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} hip::host roc::hipblas ggml-hip)
191-
192188
else()
193-
message(WARNING "hipBLAS not found")
189+
message(WARNING "hipBLAS or HIP not found. Try setting CMAKE_PREFIX_PATH=/opt/rocm")
194190
endif()
195191
endif()
196192

Makefile

+6-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,12 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
108108
nvcc -arch=native -c -o $@ $<
109109
endif
110110
ifdef LLAMA_HIPBLAS
111-
ROCMPATH?= /opt/rocm
112-
CFLAGS += -DGGML_USE_HIPBLAS -D__HIP_PLATFORM_AMD__ -I$(ROCMPATH)/include
113-
CXXFLAGS+= -D__HIP_PLATFORM_AMD__ -I$(ROCMPATH)/include
114-
HIPFLAGS?= -amdgpu-early-inline-all=true -amdgpu-function-calls=false -march=native
115-
LDFLAGS += -lhipblas -lamdhip64 -L$(ROCMPATH)/lib
116-
HIPCC ?= $(ROCMPATH)/bin/hipcc
117-
OBJS += ggml-cuda.o
111+
ROCM_PATH ?= /opt/rocm
112+
LDFLAGS += -lhipblas -lamdhip64 -L$(ROCM_PATH)/lib
113+
HIPCC ?= $(ROCM_PATH)/bin/hipcc
114+
OBJS += ggml-cuda.o
115+
ggml.o: CFLAGS += -DGGML_USE_HIPBLAS -D__HIP_PLATFORM_AMD__ -I$(ROCM_PATH)/include
116+
ggml-cuda.o: CXXFLAGS += -march=native -D__HIP_PLATFORM_AMD__ -I$(ROCMPATH)/include
118117
ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
119118
$(HIPCC) $(CXXFLAGS) -x hip $(HIPFLAGS) -c -o $@ $<
120119
endif

0 commit comments

Comments
 (0)