@@ -274,47 +274,22 @@ if (BUILD_CPU)
274274 if (OpenMP_CXX_FOUND)
275275 target_link_libraries (bitsandbytes PRIVATE OpenMP::OpenMP_CXX)
276276 add_definitions (-DHAS_OPENMP)
277- else ()
278- add_definitions (-DNO_OPENMP)
279277 endif ()
280278
281- if (HOST_ARCH MATCHES "x86_64|amd64" )
279+ if (( HOST_ARCH MATCHES "x86_64|amd64" ) AND ( NOT MSVC ) )
282280 include (CheckCXXCompilerFlag)
283281 check_cxx_compiler_flag(-mavx512f HAS_AVX512F_FLAG)
284282 check_cxx_compiler_flag(-mavx512bf16 HAS_AVX512BF16_FLAG)
285283 if (HAS_AVX512F_FLAG)
286284 target_compile_options (bitsandbytes PRIVATE -mavx512f)
287- add_definitions (-DHAS_AVX512F)
288285 endif ()
289286 if (HAS_AVX512BF16_FLAG)
290287 target_compile_options (bitsandbytes PRIVATE -mavx512bf16)
291- add_definitions (-DHAS_AVX512BF16)
292- else ()
293- add_definitions (-DNO_AVX512BF16)
294288 endif ()
289+ target_compile_options (bitsandbytes PRIVATE -mprefer-vector-width=256)
295290 endif ()
296291endif ()
297292
298- # --- Windows MSVC specific AVX512BF16 probe (after add_library) ---
299- if (MSVC AND BUILD_CPU)
300- include (CheckCXXSourceCompiles)
301- set (_AVX512BF16_TEST "
302- #include <immintrin.h>
303- int main(){
304- __m512bh a{}, b{};
305- auto c = _mm512_dpbf16_ps(_mm512_setzero_ps(), a, b);
306- (void)c;
307- return 0;
308- }" )
309- check_cxx_source_compiles("${_AVX512BF16_TEST} " MSVC_HAS_AVX512BF16)
310- if (MSVC_HAS_AVX512BF16)
311- # /arch:AVX512;
312- target_compile_options (bitsandbytes PRIVATE /arch:AVX512)
313- add_definitions (-DHAS_AVX512BF16)
314- else ()
315- add_definitions (-DNO_AVX512BF16)
316- endif ()
317- endif ()
318293
319294if (BUILD_CUDA)
320295 target_include_directories (bitsandbytes PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} )
0 commit comments