From ea9cbca1e1dbbb8474e60c02a7a24b29927ce46f Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Fri, 30 Aug 2024 10:04:12 -0400 Subject: [PATCH 1/8] Update the upstream version of finufft --- CMakeLists.txt | 7 ++++--- pyproject.toml | 1 + vendor/finufft | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b12ee5..b076bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15...3.27) +cmake_minimum_required(VERSION 3.19...3.30) project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX) message(STATUS "Using CMake version: " ${CMAKE_VERSION}) @@ -19,6 +19,7 @@ if(JAX_FINUFFT_USE_OPENMP) set(FINUFFT_USE_OPENMP OFF) endif() else() + message(STATUS "jax_finufft: OpenMP support was not requested") set(FINUFFT_USE_OPENMP OFF) endif() @@ -58,7 +59,7 @@ endif() # Build the CPU XLA bindings nanobind_add_module(jax_finufft_cpu ${CMAKE_CURRENT_LIST_DIR}/lib/jax_finufft_cpu.cc) -target_link_libraries(jax_finufft_cpu PRIVATE finufft_static) +target_link_libraries(jax_finufft_cpu PRIVATE finufft) install(TARGETS jax_finufft_cpu LIBRARY DESTINATION .) if(FINUFFT_USE_OPENMP) @@ -85,6 +86,6 @@ if(FINUFFT_USE_CUDA) ${CMAKE_CURRENT_LIST_DIR}/lib/kernels.cc.cu) target_include_directories(jax_finufft_gpu PUBLIC ${CUFINUFFT_INCLUDE_DIRS}) target_include_directories(jax_finufft_gpu PUBLIC ${CUFINUFFT_VENDORED_INCLUDE_DIRS}) - target_link_libraries(jax_finufft_gpu PRIVATE cufinufft_static) + target_link_libraries(jax_finufft_gpu PRIVATE cufinufft) install(TARGETS jax_finufft_gpu LIBRARY DESTINATION .) endif() diff --git a/pyproject.toml b/pyproject.toml index c9f81da..9052343 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ version_file = "src/jax_finufft/jax_finufft_version.py" [tool.cibuildwheel] skip = "pp* *-musllinux_* *-manylinux_i686" build-verbosity = 1 +config-settings = {"cmake.define.FINUFFT_ARCH_FLAGS" = ""} [tool.cibuildwheel.linux] before-all = "yum install -y fftw-devel" diff --git a/vendor/finufft b/vendor/finufft index 5189205..fddad84 160000 --- a/vendor/finufft +++ b/vendor/finufft @@ -1 +1 @@ -Subproject commit 51892059a4b457a99a2569ac11e9e91cd2e289e7 +Subproject commit fddad8441a630660dc6966b2fa95ef130984ad55 From 05260a3a7fc668721bfe13ffce1d24cbefbb269d Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Mon, 2 Sep 2024 11:58:45 -0400 Subject: [PATCH 2/8] fpic --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b076bed..882e323 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ endif() # Add the FINUFFT project using the vendored version add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/vendor/finufft") +set(JAX_FINUFFT_EXTRA_FLAGS -fPIC) +filter_supported_compiler_flags(JAX_FINUFFT_EXTRA_FLAGS JAX_FINUFFT_EXTRA_FLAGS) +target_compile_options(finufft PRIVATE JAX_FINUFFT_EXTRA_FLAGS) # Find Python and nanobind find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) From de272a1c584bebcda84a049c420e4581ef8ae4e0 Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Mon, 2 Sep 2024 12:33:41 -0400 Subject: [PATCH 3/8] typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 882e323..cceec6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ endif() add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/vendor/finufft") set(JAX_FINUFFT_EXTRA_FLAGS -fPIC) filter_supported_compiler_flags(JAX_FINUFFT_EXTRA_FLAGS JAX_FINUFFT_EXTRA_FLAGS) -target_compile_options(finufft PRIVATE JAX_FINUFFT_EXTRA_FLAGS) +target_compile_options(finufft PRIVATE ${JAX_FINUFFT_EXTRA_FLAGS}) # Find Python and nanobind find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) From 7c4fade12d80b10d46e3fcc1c6dd93445ad62f22 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Tue, 3 Sep 2024 09:11:33 -0400 Subject: [PATCH 4/8] cmake: set POSITION_INDEPENDENT_CODE on finufft libraries and their dependencies --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cceec6a..affa8b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,9 +47,9 @@ endif() # Add the FINUFFT project using the vendored version add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/vendor/finufft") -set(JAX_FINUFFT_EXTRA_FLAGS -fPIC) -filter_supported_compiler_flags(JAX_FINUFFT_EXTRA_FLAGS JAX_FINUFFT_EXTRA_FLAGS) -target_compile_options(finufft PRIVATE ${JAX_FINUFFT_EXTRA_FLAGS}) +set_property(TARGET finufft PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET finufft_f32 PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET finufft_f64 PROPERTY POSITION_INDEPENDENT_CODE ON) # Find Python and nanobind find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) @@ -73,6 +73,9 @@ endif() if(FINUFFT_USE_CUDA) enable_language(CUDA) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) + set_property(TARGET cufinufft_common_objects PROPERTY POSITION_INDEPENDENT_CODE ON) + set_property(TARGET cufinufft_objects PROPERTY POSITION_INDEPENDENT_CODE ON) + set_property(TARGET cufinufft PROPERTY POSITION_INDEPENDENT_CODE ON) # TODO(dfm): The ${CUFINUFFT_INCLUDE_DIRS} variable doesn't seem to get set # properly when FINUFFT is included as a submodule (maybe because of the use From db882ceab4ea8ce74c6eab0aa8552045ae3ed7b7 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Tue, 3 Sep 2024 09:15:14 -0400 Subject: [PATCH 5/8] cufinufft: update binsize to new default value --- src/jax_finufft/options.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/jax_finufft/options.py b/src/jax_finufft/options.py index ec08f77..55c4f60 100644 --- a/src/jax_finufft/options.py +++ b/src/jax_finufft/options.py @@ -40,6 +40,9 @@ class GpuMethod(IntEnum): @dataclass(frozen=True) class Opts: + + # These correspond to the default cufinufft options + # set in vendor/finufft/src/cuda/cufinufft.cu modeord: bool = False chkbnds: bool = True debug: DebugLevel = DebugLevel.Silent @@ -59,12 +62,12 @@ class Opts: gpu_upsampfac: float = 2.0 gpu_method: GpuMethod = 0 gpu_sort: bool = True - gpu_binsizex: int = -1 - gpu_binsizey: int = -1 - gpu_binsizez: int = -1 - gpu_obinsizex: int = -1 - gpu_obinsizey: int = -1 - gpu_obinsizez: int = -1 + gpu_binsizex: int = 0 + gpu_binsizey: int = 0 + gpu_binsizez: int = 0 + gpu_obinsizex: int = 0 + gpu_obinsizey: int = 0 + gpu_obinsizez: int = 0 gpu_maxsubprobsize: int = 1024 gpu_kerevalmeth: bool = True gpu_spreadinterponly: bool = False From cd5d7843ef3859f039862d249d15c6e5aefbb7e0 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Thu, 5 Sep 2024 16:58:23 -0400 Subject: [PATCH 6/8] cmake: use FINUFFT_POSITION_INDEPENDENT_CODE, update vendored finufft to flatironinstitute/finufft#551 --- CMakeLists.txt | 8 ++------ vendor/finufft | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index affa8b7..381b6be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,10 @@ else() set(FINUFFT_USE_CUDA OFF) endif() +set(FINUFFT_POSITION_INDEPENDENT_CODE ON) + # Add the FINUFFT project using the vendored version add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/vendor/finufft") -set_property(TARGET finufft PROPERTY POSITION_INDEPENDENT_CODE ON) -set_property(TARGET finufft_f32 PROPERTY POSITION_INDEPENDENT_CODE ON) -set_property(TARGET finufft_f64 PROPERTY POSITION_INDEPENDENT_CODE ON) # Find Python and nanobind find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) @@ -73,9 +72,6 @@ endif() if(FINUFFT_USE_CUDA) enable_language(CUDA) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) - set_property(TARGET cufinufft_common_objects PROPERTY POSITION_INDEPENDENT_CODE ON) - set_property(TARGET cufinufft_objects PROPERTY POSITION_INDEPENDENT_CODE ON) - set_property(TARGET cufinufft PROPERTY POSITION_INDEPENDENT_CODE ON) # TODO(dfm): The ${CUFINUFFT_INCLUDE_DIRS} variable doesn't seem to get set # properly when FINUFFT is included as a submodule (maybe because of the use diff --git a/vendor/finufft b/vendor/finufft index fddad84..6aa4176 160000 --- a/vendor/finufft +++ b/vendor/finufft @@ -1 +1 @@ -Subproject commit fddad8441a630660dc6966b2fa95ef130984ad55 +Subproject commit 6aa4176374cf1ceaa111d0f18bc804a889796bb1 From c036df0721fbdb4db647ec70783c1c9ba2c4684d Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Fri, 6 Sep 2024 13:09:00 -0400 Subject: [PATCH 7/8] cmake: use FFTW_INCLUDE_DIRS as discovered by finufft --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 381b6be..d91fe66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ endif() # Build the CPU XLA bindings nanobind_add_module(jax_finufft_cpu ${CMAKE_CURRENT_LIST_DIR}/lib/jax_finufft_cpu.cc) target_link_libraries(jax_finufft_cpu PRIVATE finufft) +target_include_directories(jax_finufft_cpu PRIVATE ${FFTW_INCLUDE_DIRS}) install(TARGETS jax_finufft_cpu LIBRARY DESTINATION .) if(FINUFFT_USE_OPENMP) From ad414896b3d9ce82c404c165adfc4e9cb4f2bcd2 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Mon, 9 Sep 2024 18:14:06 -0400 Subject: [PATCH 8/8] vendor: update finufft to tagged v2.3.0 release --- vendor/finufft | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/finufft b/vendor/finufft index 6aa4176..fffdaea 160000 --- a/vendor/finufft +++ b/vendor/finufft @@ -1 +1 @@ -Subproject commit 6aa4176374cf1ceaa111d0f18bc804a889796bb1 +Subproject commit fffdaeacb10d5d055ce5b313868a7e981cea594b