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.
This commit is contained in:
parent
54a63c10e8
commit
0e005f7793
2 changed files with 16 additions and 21 deletions
|
@ -170,27 +170,23 @@ if (LLAMA_CUBLAS)
|
|||
endif()
|
||||
|
||||
if (LLAMA_HIPBLAS)
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
find_package(hip)
|
||||
find_package(hipblas)
|
||||
|
||||
if (hipblas_FOUND)
|
||||
if (${hipblas_FOUND} AND ${hip_FOUND})
|
||||
message(STATUS "hipBLAS found")
|
||||
add_compile_definitions(GGML_USE_HIPBLAS)
|
||||
enable_language(HIP)
|
||||
add_library(ggml-hip OBJECT ggml-cuda.cu ggml-cuda.h)
|
||||
set_source_files_properties(ggml-cuda.cu PROPERTIES LANGUAGE HIP)
|
||||
target_link_libraries(ggml-hip PRIVATE hip::device)
|
||||
|
||||
set(LLAMA_HIPBLAS_PLATFORM "AMD" CACHE STRING "hip device type" FORCE)
|
||||
set_property(CACHE LLAMA_HIPBLAS_PLATFORM PROPERTY STRINGS "AMD" "NVIDIA")
|
||||
|
||||
add_compile_definitions(GGML_USE_HIPBLAS "__HIP_PLATFORM_${LLAMA_HIPBLAS_PLATFORM}__")
|
||||
|
||||
add_library(ggml-hip OBJECT ggml-cuda.cu)
|
||||
set_source_files_properties(ggml-cuda.cu PROPERTIES LANGUAGE CXX)
|
||||
target_link_libraries(ggml-hip hip::device)
|
||||
|
||||
if (LLAMA_STATIC)
|
||||
message(FATAL_ERROR "Static linking not supported for HIP/ROCm")
|
||||
endif()
|
||||
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} hip::host roc::hipblas ggml-hip)
|
||||
|
||||
else()
|
||||
message(WARNING "hipBLAS not found")
|
||||
message(WARNING "hipBLAS or HIP not found. Try setting CMAKE_PREFIX_PATH=/opt/rocm")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
13
Makefile
13
Makefile
|
@ -108,13 +108,12 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
|
|||
nvcc -arch=native -c -o $@ $<
|
||||
endif
|
||||
ifdef LLAMA_HIPBLAS
|
||||
ROCMPATH?= /opt/rocm
|
||||
CFLAGS += -DGGML_USE_HIPBLAS -D__HIP_PLATFORM_AMD__ -I$(ROCMPATH)/include
|
||||
CXXFLAGS+= -D__HIP_PLATFORM_AMD__ -I$(ROCMPATH)/include
|
||||
HIPFLAGS?= -amdgpu-early-inline-all=true -amdgpu-function-calls=false -march=native
|
||||
LDFLAGS += -lhipblas -lamdhip64 -L$(ROCMPATH)/lib
|
||||
HIPCC ?= $(ROCMPATH)/bin/hipcc
|
||||
OBJS += ggml-cuda.o
|
||||
ROCM_PATH ?= /opt/rocm
|
||||
LDFLAGS += -lhipblas -lamdhip64 -L$(ROCM_PATH)/lib
|
||||
HIPCC ?= $(ROCM_PATH)/bin/hipcc
|
||||
OBJS += ggml-cuda.o
|
||||
ggml.o: CFLAGS += -DGGML_USE_HIPBLAS -D__HIP_PLATFORM_AMD__ -I$(ROCM_PATH)/include
|
||||
ggml-cuda.o: CXXFLAGS += -march=native -D__HIP_PLATFORM_AMD__ -I$(ROCMPATH)/include
|
||||
ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
|
||||
$(HIPCC) $(CXXFLAGS) -x hip $(HIPFLAGS) -c -o $@ $<
|
||||
endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue