Christian Kastner commited on
Commit
d86ba47
·
1 Parent(s): b85e3c0

ggml-cpu: x86 feature detection is specific to x86 (llama/13811)

Browse files
Files changed (1) hide show
  1. ggml/src/ggml-cpu/CMakeLists.txt +19 -19
ggml/src/ggml-cpu/CMakeLists.txt CHANGED
@@ -299,6 +299,25 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
299
  endif()
300
  endif()
301
  endif()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  elseif ("${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "ppc64le " OR "${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "powerpc ")
303
  message(STATUS "PowerPC detected")
304
  if (GGML_NATIVE)
@@ -477,25 +496,6 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
477
  target_compile_options(${GGML_CPU_NAME} PRIVATE ${ARCH_FLAGS})
478
  target_compile_definitions(${GGML_CPU_NAME} PRIVATE ${ARCH_DEFINITIONS})
479
 
480
- if (GGML_BACKEND_DL)
481
- if (GGML_NATIVE)
482
- # the feature check relies on ARCH_DEFINITIONS, but it is not set with GGML_NATIVE
483
- message(FATAL_ERROR "GGML_NATIVE is not compatible with GGML_BACKEND_DL, consider using GGML_CPU_ALL_VARIANTS")
484
- endif()
485
-
486
- # The feature detection code is compiled as a separate target so that
487
- # it can be built without the architecture flags
488
- # Since multiple variants of the CPU backend may be included in the same
489
- # build, using set_source_files_properties() to set the arch flags is not possible
490
- set(GGML_CPU_FEATS_NAME ${GGML_CPU_NAME}-feats)
491
- add_library(${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/cpu-feats-x86.cpp)
492
- target_include_directories(${GGML_CPU_FEATS_NAME} PRIVATE . .. ../include)
493
- target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE ${ARCH_DEFINITIONS})
494
- target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED)
495
- set_target_properties(${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
496
- target_link_libraries(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_FEATS_NAME})
497
- endif()
498
-
499
  if (EMSCRIPTEN)
500
  set_target_properties(${GGML_CPU_NAME} PROPERTIES COMPILE_FLAGS "-msimd128")
501
  endif()
 
299
  endif()
300
  endif()
301
  endif()
302
+
303
+ if (GGML_BACKEND_DL)
304
+ if (GGML_NATIVE)
305
+ # the feature check relies on ARCH_DEFINITIONS, but it is not set with GGML_NATIVE
306
+ message(FATAL_ERROR "GGML_NATIVE is not compatible with GGML_BACKEND_DL, consider using GGML_CPU_ALL_VARIANTS")
307
+ endif()
308
+
309
+ # The feature detection code is compiled as a separate target so that
310
+ # it can be built without the architecture flags
311
+ # Since multiple variants of the CPU backend may be included in the same
312
+ # build, using set_source_files_properties() to set the arch flags is not possible
313
+ set(GGML_CPU_FEATS_NAME ${GGML_CPU_NAME}-feats)
314
+ add_library(${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/cpu-feats-x86.cpp)
315
+ target_include_directories(${GGML_CPU_FEATS_NAME} PRIVATE . .. ../include)
316
+ target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE ${ARCH_DEFINITIONS})
317
+ target_compile_definitions(${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED)
318
+ set_target_properties(${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
319
+ target_link_libraries(${GGML_CPU_NAME} PRIVATE ${GGML_CPU_FEATS_NAME})
320
+ endif()
321
  elseif ("${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "ppc64le " OR "${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "powerpc ")
322
  message(STATUS "PowerPC detected")
323
  if (GGML_NATIVE)
 
496
  target_compile_options(${GGML_CPU_NAME} PRIVATE ${ARCH_FLAGS})
497
  target_compile_definitions(${GGML_CPU_NAME} PRIVATE ${ARCH_DEFINITIONS})
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  if (EMSCRIPTEN)
500
  set_target_properties(${GGML_CPU_NAME} PROPERTIES COMPILE_FLAGS "-msimd128")
501
  endif()