Skip to content

Commit

Permalink
Changes to enable compilation with NumPy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-pavlyk committed Sep 11, 2024
1 parent cad9701 commit 2cc4dd6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ find_package(Cython REQUIRED)

set(MKL_ARCH intel64)
set(MKL_LINK sdl)
set(MKL_THREADING intel_thread)
set(MKL_INTERFACE ilp64)
find_package(MKL REQUIRED)

if(WIN32)
Expand Down Expand Up @@ -101,16 +99,16 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(_linker_options ${MKL_UMATH_LINKER_OPTIONS})

set(_trgt mkl_umath_loops)
add_library(${_trgt} SHARED "mkl_umath/src/mkl_umath_loops.c")
add_library(${_trgt} SHARED mkl_umath/src/mkl_umath_loops.c)
set_target_properties(${_trgt} PROPERTIES
CMAKE_POSITION_INDEPENDENT_CODE ON
C_STANDARD 99
)
target_include_directories(${_trgt} PRIVATE "mkl_umath/src/" ${NumPy_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR})
target_link_libraries(${_trgt} PRIVATE mkl_rt ${Python_LIBRARIES})
target_link_options(${_trgt} PRIVATE ${_linker_options})
target_compile_options(${_trgt} PRIVATE -fveclib=SVML)
target_compile_options(${_trgt} PRIVATE -fvectorize)
target_include_directories(${_trgt} PUBLIC mkl_umath/src/ ${NumPy_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR})
target_link_libraries(${_trgt} PUBLIC MKL::MKL ${Python_LIBRARIES})
target_link_options(${_trgt} PUBLIC ${_linker_options})
target_compile_options(${_trgt} PUBLIC -fveclib=SVML)
target_compile_options(${_trgt} PUBLIC -fvectorize)
if(OPTIMIZATION_REPORT)
target_compile_options(${_trgt} PRIVATE -qopt-report=3)
endif()
Expand All @@ -120,11 +118,12 @@ install(TARGETS ${_trgt}
RUNTIME DESTINATION mkl_umath
)

Python_add_library(_ufuncs MODULE WITH_SOABI "mkl_umath/src/ufuncsmodule.c" "mkl_umath/src/__umath_generated.c")
python_add_library(_ufuncs MODULE WITH_SOABI "mkl_umath/src/ufuncsmodule.c" "mkl_umath/src/__umath_generated.c")
target_include_directories(_ufuncs PRIVATE "mkl_umath/src" ${NumPy_INCLUDE_DIR} ${MKL_INCLUDE_DIR})
target_compile_definitions(_ufuncs PUBLIC NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
target_link_options(_ufuncs PRIVATE ${_linker_options})
target_link_libraries(_ufuncs PRIVATE mkl_umath_loops)
set_target_properties(_ufuncs PROPERTIES C_STANDARD 99)
if (UNIX)
set_target_properties(_ufuncs PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
Expand All @@ -135,6 +134,7 @@ Python_add_library(_patch MODULE WITH_SOABI ${_generated_src})
target_include_directories(_patch PRIVATE "mkl_umath/src/" ${NumPy_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR})
target_compile_definitions(_patch PUBLIC NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
target_link_libraries(_patch PRIVATE mkl_umath_loops)
set_target_properties(_patch PROPERTIES C_STANDARD 99)
if (UNIX)
set_target_properties(_patch PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
Expand Down
1 change: 1 addition & 0 deletions mkl_umath/src/mkl_umath_loops.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Python.h"

#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#define NP_IMPORT_ARRAY

#include "numpy/npy_common.h"
#include "numpy/ndarraytypes.h"
Expand Down
1 change: 1 addition & 0 deletions mkl_umath/src/ufuncsmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Python.h"
#define PY_ARRAY_UNIQUE_SYMBOL mkl_umath_ufunc_ext
#include "numpy/arrayobject.h"
#include "numpy/ndarraytypes.h"
#include "numpy/ufuncobject.h"
Expand Down

0 comments on commit 2cc4dd6

Please sign in to comment.