@@ -29,115 +29,6 @@ endif()
2929unset (GGML_EXTRA_LIBS_PRIVATE)
3030unset (GGML_EXTRA_LIBS_PUBLIC)
3131
32- if  (GGML_HIPBLAS)
33-     if  (NOT  EXISTS  $ENV{ROCM_PATH} )
34-         if  (NOT  EXISTS  /opt/rocm)
35-             set (ROCM_PATH /usr)
36-         else ()
37-             set (ROCM_PATH /opt/rocm)
38-         endif ()
39-     else ()
40-         set (ROCM_PATH $ENV{ROCM_PATH} )
41-     endif ()
42- 
43-     list (APPEND  CMAKE_PREFIX_PATH   ${ROCM_PATH} )
44-     list (APPEND  CMAKE_PREFIX_PATH  "${ROCM_PATH} /lib64/cmake" )
45- 
46-     # CMake on Windows doesn't support the HIP language yet 
47-     if  (WIN32 )
48-         set (CXX_IS_HIPCC TRUE )
49-     else ()
50-         string (REGEX  MATCH "hipcc(\. bat)?$"  CXX_IS_HIPCC "${CMAKE_CXX_COMPILER} " )
51-     endif ()
52- 
53-     if  (CXX_IS_HIPCC)
54-         if  (LINUX)
55-             if  (NOT  ${CMAKE_CXX_COMPILER_ID}  MATCHES  "Clang" )
56-                 message (WARNING "Only LLVM is supported for HIP, hint: CXX=/opt/rocm/llvm/bin/clang++" )
57-             endif ()
58- 
59-             message (WARNING "Setting hipcc as the C++ compiler is legacy behavior." 
60-                     " Prefer setting the HIP compiler directly. See README for details." )
61-         endif ()
62-     else ()
63-         # Forward AMDGPU_TARGETS to CMAKE_HIP_ARCHITECTURES. 
64-         if  (AMDGPU_TARGETS AND  NOT  CMAKE_HIP_ARCHITECTURES)
65-             set (CMAKE_HIP_ARCHITECTURES ${AMDGPU_TARGETS} )
66-         endif ()
67-         cmake_minimum_required (VERSION  3.21)
68-         enable_language (HIP)
69-     endif ()
70- 
71-     find_package (hip     REQUIRED)
72-     find_package (hipblas REQUIRED)
73-     find_package (rocblas REQUIRED)
74- 
75-     message (STATUS  "HIP and hipBLAS found" )
76- 
77-     file (GLOB   GGML_HEADERS_ROCM "ggml-cuda/*.cuh" )
78-     list (APPEND  GGML_HEADERS_ROCM "../include/ggml-cuda.h" )
79- 
80-     file (GLOB   GGML_SOURCES_ROCM "ggml-cuda/*.cu" )
81-     list (APPEND  GGML_SOURCES_ROCM "ggml-cuda.cu" )
82-     file (GLOB   SRCS "ggml-cuda/template-instances/fattn-wmma*.cu" )
83-     list (APPEND  GGML_SOURCES_ROCM ${SRCS} )
84-     file (GLOB   SRCS "ggml-cuda/template-instances/mmq*.cu" )
85-     list (APPEND  GGML_SOURCES_ROCM ${SRCS} )
86- 
87-     if  (GGML_CUDA_FA_ALL_QUANTS)
88-         file (GLOB   SRCS "ggml-cuda/template-instances/fattn-vec*.cu" )
89-         list (APPEND  GGML_SOURCES_ROCM ${SRCS} )
90-         add_compile_definitions (GGML_CUDA_FA_ALL_QUANTS)
91-     else ()
92-         file (GLOB   SRCS "ggml-cuda/template-instances/fattn-vec*q4_0-q4_0.cu" )
93-         list (APPEND  GGML_SOURCES_ROCM ${SRCS} )
94-         file (GLOB   SRCS "ggml-cuda/template-instances/fattn-vec*q8_0-q8_0.cu" )
95-         list (APPEND  GGML_SOURCES_ROCM ${SRCS} )
96-         file (GLOB   SRCS "ggml-cuda/template-instances/fattn-vec*f16-f16.cu" )
97-         list (APPEND  GGML_SOURCES_ROCM ${SRCS} )
98-     endif ()
99- 
100-     list (APPEND  GGML_CDEF_PUBLIC GGML_USE_CUDA)
101- 
102-     add_compile_definitions (GGML_USE_HIPBLAS)
103-     add_compile_definitions (GGML_CUDA_DMMV_X=${GGML_CUDA_DMMV_X} )
104-     add_compile_definitions (GGML_CUDA_MMV_Y=${GGML_CUDA_MMV_Y} )
105-     add_compile_definitions (K_QUANTS_PER_ITERATION=${GGML_CUDA_KQUANTS_ITER} )
106- 
107-     if  (GGML_HIP_UMA)
108-         add_compile_definitions (GGML_HIP_UMA)
109-     endif ()
110- 
111-     if  (GGML_CUDA_FORCE_DMMV)
112-         add_compile_definitions (GGML_CUDA_FORCE_DMMV)
113-     endif ()
114- 
115-     if  (GGML_CUDA_FORCE_MMQ)
116-         add_compile_definitions (GGML_CUDA_FORCE_MMQ)
117-     endif ()
118- 
119-     if  (GGML_CUDA_FORCE_CUBLAS)
120-         add_compile_definitions (GGML_CUDA_FORCE_CUBLAS)
121-     endif ()
122- 
123-     if  (GGML_CUDA_NO_PEER_COPY)
124-         add_compile_definitions (GGML_CUDA_NO_PEER_COPY)
125-     endif ()
126- 
127-     if  (CXX_IS_HIPCC)
128-         set_source_files_properties (${GGML_SOURCES_ROCM}  PROPERTIES LANGUAGE  CXX)
129-         list (APPEND  GGML_EXTRA_LIBS_PRIVATE hip::device)
130-     else ()
131-         set_source_files_properties (${GGML_SOURCES_ROCM}  PROPERTIES LANGUAGE  HIP)
132-     endif ()
133- 
134-     if  (GGML_STATIC)
135-         message (FATAL_ERROR "Static linking not supported for HIP/ROCm" )
136-     endif ()
137- 
138-     list (APPEND  GGML_EXTRA_LIBS_PUBLIC hip::host roc::rocblas roc::hipblas)
139- endif ()
140- 
14132function (get_flags CCID CCVER)
14233    set (C_FLAGS "" )
14334    set (CXX_FLAGS  "" )
@@ -354,12 +245,12 @@ function(ggml_add_backend backend)
354245    endif ()
355246endfunction ()
356247
357- set (GGML_CPU ON )
358248ggml_add_backend(CPU)
359249ggml_add_backend(AMX)
360250ggml_add_backend(BLAS)
361251ggml_add_backend(CANN)
362252ggml_add_backend(CUDA)
253+ ggml_add_backend(HIP)
363254ggml_add_backend(Kompute)
364255ggml_add_backend(METAL)
365256ggml_add_backend(RPC)
0 commit comments