Skip to content

Commit 3677235

Browse files
committed
More build file changes
1 parent d3e1984 commit 3677235

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,24 @@ if (LLAMA_CUBLAS)
170170
endif()
171171

172172
if (LLAMA_HIPBLAS)
173+
list(APPEND CMAKE_PREFIX_PATH /opt/rocm)
174+
175+
if (NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
176+
message(WARNING "Only LLVM is supported for HIP, hint: CC=/opt/rocm/llvm/bin/clang")
177+
endif()
178+
if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
179+
message(WARNING "Only LLVM is supported for HIP, hint: CXX=/opt/rocm/llvm/bin/clang++")
180+
endif()
181+
173182
find_package(hip)
174183
find_package(hipblas)
175184

176185
if (${hipblas_FOUND} AND ${hip_FOUND})
177186
message(STATUS "hipBLAS found")
178187
add_compile_definitions(GGML_USE_HIPBLAS)
179-
enable_language(HIP)
180188
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)
189+
set_source_files_properties(ggml-cuda.cu PROPERTIES LANGUAGE CXX)
190+
target_link_libraries(ggml-hip PUBLIC hip::device)
183191

184192
if (LLAMA_STATIC)
185193
message(FATAL_ERROR "Static linking not supported for HIP/ROCm")
@@ -188,6 +196,7 @@ if (LLAMA_HIPBLAS)
188196
else()
189197
message(WARNING "hipBLAS or HIP not found. Try setting CMAKE_PREFIX_PATH=/opt/rocm")
190198
endif()
199+
191200
endif()
192201

193202
if (LLAMA_ALL_WARNINGS)

Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ ifndef UNAME_M
1313
UNAME_M := $(shell uname -m)
1414
endif
1515

16-
CCV := $(shell $(CC) --version | head -n 1)
17-
CXXV := $(shell $(CXX) --version | head -n 1)
16+
CCV = $(shell $(CC) --version | head -n 1)
17+
CXXV = $(shell $(CXX) --version | head -n 1)
1818

1919
# Mac OS + Arm can report x86_64
2020
# ref: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789
@@ -108,14 +108,17 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
108108
nvcc -arch=native -c -o $@ $<
109109
endif
110110
ifdef LLAMA_HIPBLAS
111-
ROCM_PATH ?= /opt/rocm
112-
LDFLAGS += -lhipblas -lamdhip64 -L$(ROCM_PATH)/lib -Wl,-rpath=$(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
111+
ROCM_PATH ?= /opt/rocm
112+
CC := $(ROCM_PATH)/llvm/bin/clang
113+
CXX := $(ROCM_PATH)/llvm/bin/clang++
114+
GPU_TARGETS!= $(ROCM_PATH)/llvm/bin/offload-arch
115+
CFLAGS += -DGGML_USE_HIPBLAS $(shell $(ROCM_PATH)/bin/hipconfig -C)
116+
CXXFLAGS += -DGGML_USE_HIPBLAS $(shell $(ROCM_PATH)/bin/hipconfig -C)
117+
LDFLAGS += -L/opt/rocm/lib -lhipblas -lamdhip64
118+
OBJS += ggml-cuda.o
119+
ggml-cuda.o: CXXFLAGS += $(addprefix --offload-arch=,$(GPU_TARGETS))
117120
ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
118-
$(HIPCC) $(CXXFLAGS) -x hip $(HIPFLAGS) -c -o $@ $<
121+
$(CXX) $(CXXFLAGS) -x hip -c -o $@ $<
119122
endif
120123
ifdef LLAMA_GPROF
121124
CFLAGS += -pg

0 commit comments

Comments
 (0)