Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# build artifacts
*_test
*~
*.a
Expand Down Expand Up @@ -32,8 +33,14 @@ __pycache__*
docs/_build

build/
.vscode/

cufinufft/python/cufinufft/docs/_build
cufinufft/python/cufinufft/docs/_static
cufinufft/python/cufinufft/docs/_templates

# ides and editors
.vscode/
.vs/
/CMakeSettings.json
/CMakeUserPresets.json
.~*
4 changes: 2 additions & 2 deletions cmake/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ if(FINUFFT_ARCH_FLAGS STREQUAL "native")
set(FINUFFT_ARCH_FLAGS -mtune=native CACHE STRING "" FORCE)
filter_supported_compiler_flags(FINUFFT_ARCH_FLAGS FINUFFT_ARCH_FLAGS)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(MSVC)
# -march=native emulation for MSVC
check_arch_support()
check_msvc_arch_support()
endif()
if(NOT FINUFFT_ARCH_FLAGS)
message(WARNING "No architecture flags are supported by the compiler.")
Expand Down
14 changes: 11 additions & 3 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ include(CheckCXXCompilerFlag)

# Define the function
function(filter_supported_compiler_flags input_flags_var output_flags_var)
string(MD5 input_hash "${${input_flags_var}}")
if(DEFINED SUPPORTED_FLAGS_${input_hash})
message(STATUS "Using cached flags for ${input_flags_var}: ${SUPPORTED_FLAGS_${input_hash}}")
set(${output_flags_var} ${SUPPORTED_FLAGS_${input_hash}} PARENT_SCOPE)
return()
endif()

# Create an empty list to store supported flags
set(supported_flags)
# Iterate over each flag in the input list
Expand All @@ -23,11 +30,12 @@ function(filter_supported_compiler_flags input_flags_var output_flags_var)
# remove last flag from CMAKE_EXE_LINKER_FLAGS using substring
set(CMAKE_EXE_LINKER_FLAGS ${ORIGINAL_LINKER_FLAGS})
endforeach()
# Set the output variable to the list of supported flags
# Set the output variable to the list of supported flags and cache them
set(SUPPORTED_FLAGS_${input_hash} "${supported_flags}" CACHE INTERNAL "")
set(${output_flags_var} ${supported_flags} PARENT_SCOPE)
endfunction()

function(check_arch_support)
function(check_msvc_arch_support)
message(STATUS "Checking for AVX, AVX512 and SSE support")
try_run(
RUN_RESULT_VAR
Expand Down Expand Up @@ -89,7 +97,7 @@ endif()

function(enable_asan target)
target_compile_options(${target} PRIVATE ${FINUFFT_SANITIZER_FLAGS})
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
if(NOT MSVC)
target_link_options(${target} PRIVATE ${FINUFFT_SANITIZER_FLAGS})
endif()
endfunction()
Expand Down
Loading