Compare commits

...

29 commits

Author SHA1 Message Date
70f6f88802 Add ZLIB package 2025-03-11 14:26:57 -04:00
736531e9fd Add towncrier experimental 2024-05-09 09:55:02 +03:00
fb51ffd35e Fixup for sph 2024-04-26 08:53:38 +02:00
924047de22 Add possibility to have an external state 2024-04-25 18:11:06 +02:00
be64c7fd7a Remove support for old python 2024-04-25 17:06:15 +02:00
guilhem.lavaux@iap.fr
47d63a25ce Bump version 2024-02-13 10:47:28 +01:00
guilhem.lavaux@iap.fr
4bcc5f3270 Add missing numpy_adaptors 2024-02-13 10:37:52 +01:00
guilhem.lavaux@iap.fr
1d59533b17 Add python in search path 2024-02-13 10:28:58 +01:00
guilhem.lavaux@iap.fr
1548fd8450 Add missing pyx in MANIFEST 2024-02-13 09:15:36 +01:00
guilhem.lavaux@iap.fr
1151d0c8b6 Add cython back to dependency 2024-02-13 08:25:14 +01:00
guilhem.lavaux@iap.fr
1db266b4ea Add pyproject.toml 2024-02-13 08:19:54 +01:00
guilhem.lavaux@iap.fr
f2a5092cf1 Fix MANIFEST 2024-02-13 07:53:12 +01:00
guilhem.lavaux@iap.fr
54a59b5246 Fix manifest 2024-02-13 07:53:12 +01:00
883c338c08 Fixed building 2024-01-17 14:00:09 +01:00
guilhem.lavaux@iap.fr
b8e60a7d33 Updating to 1.3.5 2024-01-16 07:50:50 +01:00
guilhem.lavaux@iap.fr
751d8a19a0 Remove pyfftw from requirements 2024-01-16 07:49:08 +01:00
guilhem.lavaux@iap.fr
97a1e34132 Strip mandatory pyfftw support 2024-01-16 07:33:45 +01:00
guilhem.lavaux@iap.fr
26e095fc71 Fix for default MacOS build with python 2024-01-16 07:21:56 +01:00
6adf02b287 Attempt to fix linkage errors 2023-12-07 08:56:24 +01:00
b878efb8b1 Fix requirements 2023-12-06 22:35:55 +01:00
Guilhem Lavaux
7c7ccd6f87 Changed to use configure and not CMake for hdf5. 2023-12-06 21:21:11 +00:00
7a81120977 Fix setPeriodic 2023-12-06 18:40:06 +01:00
c88f91ba80 Bump to 1.3.4 2023-12-06 09:29:58 +01:00
0093a6aa0f Fix cython syntax and port to more recent numpy.pxd 2023-12-06 09:28:43 +01:00
4afc982dfc Cache downloads 2023-12-06 09:28:43 +01:00
d4b1742cbf Add periodic argument 2023-12-05 16:35:54 +01:00
guilhem.lavaux@iap.fr
d2cd6bb650 Merge remote-tracking branch 'origin/master' 2023-12-03 20:30:25 +01:00
guilhem.lavaux@iap.fr
2aa7c96e48 Update for macmini 2023-12-03 20:29:56 +01:00
d8b58bd8f1 Update version 2023-04-23 12:44:12 +02:00
19 changed files with 151 additions and 86 deletions

View file

@ -42,6 +42,18 @@ ENDIF(BUILD_PYTHON)
MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module")
find_package(ZLIB)
find_library(ZLIB_LIBRARY z)
find_library(DL_LIBRARY dl)
find_library(RT_LIBRARY rt)
if (RT_LIBRARY)
SET(RT_DEP rt)
message(STATUS "RT found, linking against it")
else()
SET(RT_DEP)
endif()
find_library(MATH_LIBRARY m)
include(${CMAKE_SOURCE_DIR}/external/external_build.cmake)
IF(YORICK_SUPPORT)
@ -55,9 +67,6 @@ IF(YORICK_SUPPORT)
ENDIF(YORICK_SUPPORT)
find_program(CYTHON NAMES cython3 cython)
find_library(ZLIB_LIBRARY z)
find_library(DL_LIBRARY dl)
find_library(MATH_LIBRARY m)
set(NETCDF_FIND_REQUIRED ${YORICK_SUPPORT})
set(GSL_FIND_REQUIRED TRUE)
@ -71,10 +80,10 @@ SET(CPACK_PACKAGE_VENDOR "Guilhem Lavaux")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENCE_CeCILL_V2")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "1${EXTRA_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "4${EXTRA_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_STRIP_FILES "lib/libCosmoTool.so")
SET(CPACK_SOURCE_IGNORE_FILES
SET(CPACK_SOURCE_IGNORE_FILES
"/CVS/;/\\\\.git/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;/CMakeFiles/;.*\\\\.cmake;Makefile")
add_subdirectory(src)

View file

@ -1,4 +1,5 @@
include .gitignore
include pyproject.toml
include CMakeLists.txt
include FindNumPy.cmake
include FindPyLibs.cmake
@ -16,14 +17,17 @@ include doc/source/cpplibrary.rst
include doc/source/index.rst
include doc/source/intro.rst
include doc/source/pythonmodule.rst
include external/config.guess
include external/config.sub
include external/external_build.cmake
include external/libsharp-6077806.tar.gz
include external/libsharp-8d51946.tar.gz
include external/omptl-20120422.tar.bz2
include external/patch-omptl
include python/CMakeLists.txt
include python/_cosmo_bispectrum.cpp
include python/_cosmo_cic.pyx
include python/_cosmo_power.pyx
include python/_cosmomath.pyx
include python/_cosmotool.pyx
include python/_fast_interp.pyx
include python/_project.pyx
@ -93,6 +97,7 @@ include sample/testkd3.cpp
include setup.py
include src/CMakeLists.txt
include src/algo.hpp
include src/numpy_adaptors.hpp
include src/bqueue.hpp
include src/bqueue.tcc
include src/bsp_simple.hpp

View file

@ -16,7 +16,7 @@ ln -fs /usr/bin/cmake3 /usr/bin/cmake
test -d /io/wheelhouse || mkdir /io/wheelhouse
test -d /io/wheelhouse/fix || mkdir /io/wheelhouse/fix
ALL_PYTHON="cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310"
ALL_PYTHON="cp39-cp39 cp310-cp310"
# Compile wheels
for pkg in $ALL_PYTHON; do
@ -24,11 +24,11 @@ for pkg in $ALL_PYTHON; do
# "${PYBIN}/pip" install -r /io/dev-requirements.txt
"${PYBIN}/pip" install setuptools wheel Cython
"${PYBIN}/pip" install -r /io/requirements.txt
"${PYBIN}/pip" wheel -vvv /io/ -w wheelhouse/
"${PYBIN}/pip" wheel -vvv /io/ -w /io/wheelhouse/
done
# Bundle external shared libraries into the wheels
for whl in /io/wheelhouse/cosmotool*.whl; do
for whl in /io/wheelhouse/cosmotool*linux*.whl; do
auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/fix
done

View file

@ -9,4 +9,4 @@ if ! [ -e ${d}/setup.py ] ; then
exit 1
fi
podman run -ti --rm -e PLAT=manylinux2010_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2010_x86_64 /io/builder/build-wheels.sh
podman run -ti --rm -e PLAT=manylinux2014_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2014_x86_64 /io/builder/build-wheels.sh

View file

@ -2,6 +2,7 @@ include(FindOpenMP)
OPTION(ENABLE_OPENMP "Set to Yes if Healpix and/or you need openMP" OFF)
SET(SOURCE_PREFIX ${CMAKE_SOURCE_DIR})
SET(FFTW_URL "http://www.fftw.org/fftw-3.3.3.tar.gz" CACHE STRING "URL to download FFTW from")
SET(EIGEN_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.bz2" CACHE STRING "URL to download Eigen from")
SET(GENGETOPT_URL "ftp://ftp.gnu.org/gnu/gengetopt/gengetopt-2.22.5.tar.gz" CACHE STRING "URL to download gengetopt from")
@ -12,6 +13,8 @@ SET(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/
SET(GSL_URL "https://ftpmirror.gnu.org/gsl/gsl-2.7.tar.gz" CACHE STRING "URL to download GSL from ")
mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL)
file(MAKE_DIRECTORY ${SOURCE_PREFIX}/downloads)
SET(all_deps)
MACRO(CHECK_CHANGE_STATE VAR)
@ -36,12 +39,13 @@ CHECK_CHANGE_STATE(INTERNAL_DLIB DLIB_INCLUDE_DIR DLIB_LIBRARIES)
IF(ENABLE_OPENMP)
IF (NOT OPENMP_FOUND)
MESSAGE(ERROR "No known compiler option for enabling OpenMP")
MESSAGE(NOTICE "No known compiler option for enabling OpenMP")
ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
ENDIF(NOT OPENMP_FOUND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
ENDIF(ENABLE_OPENMP)
@ -55,21 +59,25 @@ if (ENABLE_SHARP)
SET(DEP_BUILD ${BUILD_PREFIX}/sharp-prefix/src/sharp/auto)
IF(NOT ENABLE_OPENMP)
SET(SHARP_OPENMP --disable-openmp)
ELSE()
SET(SHARP_OPENMP)
ENDIF()
SET(CUTILS_LIBRARY ${DEP_BUILD}/lib/libc_utils.a)
SET(FFTPACK_LIBRARY ${DEP_BUILD}/lib/libfftpack.a)
SET(SHARP_LIBRARY ${DEP_BUILD}/lib/libsharp.a)
SET(SHARP_LIBRARIES ${SHARP_LIBRARY} ${FFTPACK_LIBRARY} ${CUTILS_LIBRARY})
SET(SHARP_INCLUDE_PATH ${DEP_BUILD}/include)
message(STATUS "Flags: ${CMAKE_C_FLAGS}")
ExternalProject_Add(sharp
URL ${CMAKE_SOURCE_DIR}/external/libsharp-6077806.tar.gz
URL ${CMAKE_SOURCE_DIR}/external/libsharp-8d51946.tar.gz
PREFIX ${BUILD_PREFIX}/sharp-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND
cp -f ${CMAKE_SOURCE_DIR}/external/config.guess . &&
cp -f ${CMAKE_SOURCE_DIR}/external/config.sub . &&
autoconf &&
./configure "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" --prefix=${DEP_BUILD} ${SHARP_OPENMP}
./configure "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" "CFLAGS=${CMAKE_C_FLAGS}" "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}" --prefix=${DEP_BUILD} ${SHARP_OPENMP}
INSTALL_COMMAND echo "No install"
BUILD_BYPRODUCTS ${SHARP_LIBRARIES}
)
@ -87,22 +95,17 @@ if (INTERNAL_HDF5)
PREFIX ${BUILD_PREFIX}/hdf5-prefix
URL ${HDF5_URL}
URL_HASH MD5=30172c75e436d7f2180e274071a4ca97
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${EXT_INSTALL}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DHDF5_BUILD_CPP_LIB=ON
-DHDF5_BUILD_TOOLS=ON
-DHDF5_BUILD_HL_LIB=ON
-DBUILD_SHARED_LIBS=OFF
-DHDF5_ENABLE_Z_LIB_SUPPORT=ON
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
CONFIGURE_COMMAND
${HDF5_SOURCE_DIR}/configure "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" "CFLAGS=${CMAKE_C_FLAGS}" "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}" --prefix=${HDF5_BIN_DIR} --disable-shared --enable-cxx --enable-hl --enable-tools --with-pic
INSTALL_COMMAND make install
)
SET(cosmotool_DEPS ${cosmotool_DEPS} hdf5)
SET(hdf5_built hdf5)
SET(ENV{HDF5_ROOT} ${HDF5_BIN_DIR})
SET(HDF5_ROOTDIR ${HDF5_BIN_DIR})
SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${HDF5_BIN_DIR}/lib")
SET(CONFIGURE_LIBS "${CONFIGURE_LIBS} -ldl")
SET(CONFIGURE_LIBS "${CONFIGURE_LIBS} -ldl ${RT_LIBRARY}")
set(HDF5_C_STATIC_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5.a)
set(HDF5_HL_STATIC_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl.a)
set(HDF5_LIBRARIES ${HDF5_BIN_DIR}/lib/libhdf5.a CACHE STRING "HDF5 lib" FORCE)
@ -172,37 +175,45 @@ if (INTERNAL_NETCDF)
string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}")
ExternalProject_Add(netcdf
DEPENDS ${hdf5_built}
URL_HASH MD5=f48ee01534365006934f0c63d4055ea0
PREFIX ${BUILD_PREFIX}/netcdf-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
URL ${NETCDF_URL}
LIST_SEPARATOR |
CMAKE_ARGS
LIST_SEPARATOR |
CMAKE_ARGS
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DNC_EXTRA_DEPS=${RT_DEP}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
-DENABLE_NETCDF4=ON
-DENABLE_BYTERANGE=FALSE
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DENABLE_DAP=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DENABLE_DAP=OFF
-DCMAKE_INSTALL_PREFIX=${NETCDF_BIN_DIR}
-DHDF5_C_LIBRARY=${HDF5_C_STATIC_LIBRARY}
-DHDF5_HL_LIBRARY=${HDF5_HL_STATIC_LIBRARY}
-DHDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIRS}
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_INSTALL_LIBDIR=lib
)
SET(NETCDFCXX_SOURCE_DIR ${BUILD_PREFIX}/netcdf-c++-prefix/src/netcdf-c++)
ExternalProject_Add(netcdf-c++
DEPENDS ${hdf5_built} netcdf
PREFIX ${BUILD_PREFIX}/netcdf-c++-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
URL ${NETCDFCXX_URL}
CMAKE_ARGS
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DHDF5_C_LIBRARY=${HDF5_C_STATIC_LIBRARY}
-DHDF5_HL_LIBRARY=${HDF5_HL_STATIC_LIBRARY}
-DHDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIRS}
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${NETCDF_BIN_DIR}
@ -240,6 +251,7 @@ if (INTERNAL_BOOST)
ExternalProject_Add(boost
URL ${BOOST_URL}
PREFIX ${BUILD_PREFIX}/boost-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
URL_HASH MD5=f7050f554a65f6a42ece221eaeec1660
CONFIGURE_COMMAND
${BOOST_SOURCE_DIR}/bootstrap.sh --prefix=${CMAKE_BINARY_DIR}/ext_build/boost
@ -283,6 +295,7 @@ IF(INTERNAL_GSL)
ExternalProject_Add(gsl
URL ${GSL_URL}
PREFIX ${BUILD_PREFIX}/gsl-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
CONFIGURE_COMMAND ${GSL_SOURCE_DIR}/configure
--prefix=${EXT_INSTALL} --disable-shared
--with-pic
@ -335,6 +348,7 @@ IF(INTERNAL_FFTW)
ExternalProject_Add(fftw
URL ${FFTW_URL}
PREFIX ${BUILD_PREFIX}/fftw-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
CONFIGURE_COMMAND
${FFTW_SOURCE}/configure
--prefix=${EXT_INSTALL}
@ -364,6 +378,7 @@ IF (INTERNAL_EIGEN)
ExternalProject_Add(eigen
URL ${EIGEN_URL}
URL_HASH MD5=b9e98a200d2455f06db9c661c5610496
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
PREFIX ${BUILD_PREFIX}/eigen-prefix
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXT_INSTALL}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
@ -396,6 +411,7 @@ SET(cosmotool_DEPS ${cosmotool_DEPS} omptl)
SET(OMPTL_BUILD_DIR ${BUILD_PREFIX}/omptl-prefix/src/omptl)
ExternalProject_Add(omptl
PREFIX ${BUILD_PREFIX}/omptl-prefix
DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads
URL ${CMAKE_SOURCE_DIR}/external/omptl-20120422.tar.bz2
CONFIGURE_COMMAND echo "No configure"
BUILD_COMMAND echo "No build"

BIN
external/libsharp-8d51946.tar.gz vendored Normal file

Binary file not shown.

8
pyproject.toml Normal file
View file

@ -0,0 +1,8 @@
[build-system]
requires = ["setuptools","wheel","cython"]
build-backend = "setuptools.build_meta"
[tool.towncrier]
directory = "changes"

View file

@ -2,7 +2,7 @@ set(CMAKE_SHARED_MODULE_PREFIX)
set(PYTHON_INCLUDES ${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/python)
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
IF(CYTHON)
add_custom_command(
@ -69,13 +69,10 @@ target_link_libraries(_fast_interp PRIVATE ${CosmoTool_local} )
SET(ct_TARGETS _cosmotool _project _cosmo_power _cosmo_cic _fast_interp _cosmomath)
if (Boost_FOUND)
message(STATUS "Building bispectrum support (path = ${Boost_INCLUDE_DIRS})")
message(STATUS "Building bispectrum support")
include_directories(${Boost_INCLUDE_DIRS})
add_library(_cosmo_bispectrum MODULE _cosmo_bispectrum.cpp)
target_link_libraries(_cosmo_bispectrum ${MATH_LIBRARY})
if(ENABLE_OPENMP)
set_target_properties(_cosmo_bispectrum PROPERTIES COMPILE_FLAGS "${OpenMP_CXX_FLAGS}" LINK_FLAGS "${OpenMP_CXX_FLAGS}")
endif()
if (Boost_DEP)
add_dependencies(_cosmo_bispectrum ${Boost_DEP})
endif()

View file

@ -12,7 +12,7 @@ cdef extern from "numpy/npy_common.h":
ctypedef npy_intp
cdef extern from "special_math.hpp" namespace "CosmoTool":
T log_modified_bessel_first_kind[T](T v, T z) nogil except +
T log_modified_bessel_first_kind[T](T v, T z) except + nogil
cdef extern from "numpy_adaptors.hpp" namespace "CosmoTool":
void parallel_ufunc_dd_d[T,IT](char **args, IT* dimensions, IT* steps, void *func)

View file

@ -39,7 +39,7 @@ cdef extern from "loadSimu.hpp" namespace "CosmoTool":
cdef extern from "loadGadget.hpp" namespace "CosmoTool":
SimuData *loadGadgetMulti(const char *fname, int id, int flags, int gformat) nogil except +
SimuData *loadGadgetMulti(const char *fname, int id, int flags, int gformat) except + nogil
void cxx_writeGadget "CosmoTool::writeGadget" (const char * s, SimuData *data) except +
cdef extern from "safe_gadget.hpp":
@ -313,6 +313,13 @@ tries to get an array from the object."""
references to the object are gone. """
pass
cdef extern from "numpy/arrayobject.h":
# a little bit awkward: the reference to obj will be stolen
# using PyObject* to signal that Cython cannot handle it automatically
int PyArray_SetBaseObject(np.ndarray arr, PyObject *obj) except -1 # -1 means there was an error
cdef object wrap_array(void *p, np.uint64_t s, int typ):
cdef np.ndarray ndarray
cdef ArrayWrapper wrapper
@ -320,7 +327,8 @@ cdef object wrap_array(void *p, np.uint64_t s, int typ):
wrapper = ArrayWrapper()
wrapper.set_data(s, typ, p)
ndarray = np.array(wrapper, copy=False)
ndarray.base = <PyObject*> wrapper
#ndarray.base = <PyObject*> wrapper
PyArray_SetBaseObject(ndarray, <PyObject*> wrapper)
Py_INCREF(wrapper)
return ndarray

View file

@ -727,7 +727,7 @@ cdef DTYPE_t C_line_of_sight_projection(DTYPE_t[:,:,:] density,
cdef int iu0[3]
cdef int i
cdef int N = density.shape[0]
cdef int half_N = density.shape[0]/2
cdef int half_N = density.shape[0]//2
cdef int completed
cdef DTYPE_t I0, d, dist2, delta, s, max_distance2
cdef int jumper[1]

View file

@ -1,5 +1,4 @@
numpy<1.22
cffi
numexpr
pyfftw
cython
cython<3

View file

@ -1,4 +1,8 @@
SET(tolink ${CosmoTool_local} ${CosmoTool_LIBS} ${GSL_LIBRARIES} ${DL_LIBRARY})
if (RT_LIBRARY)
SET(tolink ${tolink} ${RT_LIBRARY})
endif()
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${FFTW3_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${GSL_INCLUDE_PATH})
if(YORICK_SUPPORT)

View file

@ -84,6 +84,7 @@ int main(int argc, char **argv) {
char *fname1, *outFile;
double rLimit, boxsize, rLimit2, cx, cy, cz;
int Nres;
int periodic;
MiniArgDesc args[] = {{"INPUT DATA1", &fname1, MINIARG_STRING},
{"RADIUS LIMIT", &rLimit, MINIARG_DOUBLE},
@ -93,6 +94,7 @@ int main(int argc, char **argv) {
{"CY", &cy, MINIARG_DOUBLE},
{"CZ", &cz, MINIARG_DOUBLE},
{"OUTPUT FILE", &outFile, MINIARG_STRING},
{"PERIODIC", &periodic, MINIARG_INT},
{0, 0, MINIARG_NULL}};
if (!parseMiniArgs(argc, argv, args))
@ -148,6 +150,7 @@ int main(int argc, char **argv) {
cout << "Building trees..." << endl;
MyTree tree1(allCells_1, N1_points);
tree1.setPeriodic(periodic != 0, boxsize);
cout << "Creating smoothing filter..." << endl;

View file

@ -2,6 +2,7 @@ import stat
import os
import sys
import shutil
from sysconfig import get_config_var
from distutils.command.install_data import install_data
import pathlib
from setuptools import find_packages, setup, Extension
@ -76,9 +77,9 @@ class InstallCMakeLibs(install_lib):
# # your files are moved to the appropriate location when the installation
# # is run
#
# libs = [os.path.join(bin_dir, _lib) for _lib in
# os.listdir(bin_dir) if
# os.path.isfile(os.path.join(bin_dir, _lib)) and
# libs = [os.path.join(bin_dir, _lib) for _lib in
# os.listdir(bin_dir) if
# os.path.isfile(os.path.join(bin_dir, _lib)) and
# os.path.splitext(_lib)[1] in [".dll", ".so"]
# and not (_lib.startswith("python") or _lib.startswith(PACKAGE_NAME))]
#
@ -87,16 +88,16 @@ class InstallCMakeLibs(install_lib):
# shutil.move(lib, os.path.join(self.build_dir,
# os.path.basename(lib)))
#
# # Mark the libs for installation, adding them to
# # distribution.data_files seems to ensure that setuptools' record
# # Mark the libs for installation, adding them to
# # distribution.data_files seems to ensure that setuptools' record
# # writer appends them to installed-files.txt in the package's egg-info
# #
# # Also tried adding the libraries to the distribution.libraries list,
# # but that never seemed to add them to the installed-files.txt in the
# # egg-info, and the online recommendation seems to be adding libraries
# # into eager_resources in the call to setup(), which I think puts them
# # in data_files anyways.
# #
# # Also tried adding the libraries to the distribution.libraries list,
# # but that never seemed to add them to the installed-files.txt in the
# # egg-info, and the online recommendation seems to be adding libraries
# # into eager_resources in the call to setup(), which I think puts them
# # in data_files anyways.
# #
# # What is the best way?
#
# # These are the additional installation files that should be
@ -104,7 +105,7 @@ class InstallCMakeLibs(install_lib):
# # step; depending on the files that are generated from your cmake
# # build chain, you may need to modify the below code
#
# self.distribution.data_files = [os.path.join(self.install_dir,
# self.distribution.data_files = [os.path.join(self.install_dir,
# os.path.basename(lib))
# for lib in libs]
# print(self.distribution.data_files)
@ -167,17 +168,24 @@ class BuildCMakeExt(build_ext):
# Change your cmake arguments below as necessary
# Below is just an example set of arguments for building Blender as a Python module
c_compiler=os.environ.get('CC', get_config_var("CC"))
cxx_compiler=os.environ.get('CXX', get_config_var("CXX"))
compilers=[]
fill_up_settings=[
("CMAKE_C_COMPILER", "CC"),
("CMAKE_CXX_COMPILER", "CXX"),
("CMAKE_C_FLAGS", "CFLAGS"),
("CMAKE_EXE_LINKER_FLAGS_INIT", "LDFLAGS"),
("CMAKE_SHARED_LINKER_FLAGS_INIT", "LDFLAGS"),
("CMAKE_MODULE_LINKER_FLAGS_INIT", "LDFLAGS")]
for cmake_flag, os_flag in fill_up_settings:
if os_flag in os.environ:
compilers.append(f"-D{cmake_flag}={os.environ[os_flag]}")
("CMAKE_C_COMPILER", "CC", get_config_var("CC")),
("CMAKE_CXX_COMPILER", "CXX", get_config_var("CXX")),
("CMAKE_C_FLAGS", "CFLAGS", None),
("CMAKE_CXX_FLAGS", "CXXFLAGS", None),
("CMAKE_EXE_LINKER_FLAGS_INIT", "LDFLAGS", None),
("CMAKE_SHARED_LINKER_FLAGS_INIT", "LDFLAGS", None),
("CMAKE_MODULE_LINKER_FLAGS_INIT", "LDFLAGS", None)]
for cmake_flag, os_flag, default_flag in fill_up_settings:
if os_flag in os.environ or default_flag is not None:
c = os.environ.get(os_flag, default_flag)
if not c is None:
compilers.append(f"-D{cmake_flag}={c}")
print(compilers)
self.spawn(['cmake', '-H'+SOURCE_DIR, '-B'+self.build_temp,
'-DENABLE_OPENMP=ON','-DINTERNAL_BOOST=ON','-DINTERNAL_EIGEN=ON',
@ -213,7 +221,7 @@ class BuildCMakeExt(build_ext):
if _pyd_top[0].startswith(PACKAGE_NAME):
if os.path.splitext(_pyd)[1] in [".pyd", ".so"] or _pyd_top[-1] == 'config.py':
pyd_path.append((_pyd_top,_pyd))
for top,p in pyd_path:
_,n = os.path.split(p)
@ -229,10 +237,10 @@ class BuildCMakeExt(build_ext):
CosmoTool_extension = CMakeExtension(name="cosmotool")
setup(name='cosmotool',
version='1.3.2',
version='1.3.6',
packages=["cosmotool"],
package_dir={'cosmotool': 'python/cosmotool'},
install_requires=['numpy','cffi','numexpr','pyfftw','h5py'],
install_requires=['cython','numpy','cffi','numexpr','h5py'],
setup_requires=['cython','cffi','numpy','numexpr'],
ext_modules=[CosmoTool_extension],
description='A small cosmotool box of useful functions',

View file

@ -426,7 +426,7 @@ namespace CosmoTool {
#define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \
{ \
::CosmoTool::get_hdf5_data_type<BOOST_PP_TUPLE_ELEM(2, 0, element)> t; \
long position = HOFFSET(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \
long position = offsetof(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \
const char *field_name = BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, element)); \
type.insertMember(field_name, position, t.type()); \
}

View file

@ -157,6 +157,7 @@ const Interpolate& Interpolate::operator=(const Interpolate& a)
gsl_spline_init(spline, a.spline->x, a.spline->y, a.spline->size);
logx = a.logx;
logy = a.logy;
return *this;
}
double Interpolate::getMaxX() const

View file

@ -72,7 +72,9 @@ namespace CosmoTool {
void
fetchNeighbours(const typename SPHTree::coords &c, SPHState *state = 0);
void fetchNeighbours(const typename SPHTree::coords &c, uint32_t newNsph);
void fetchNeighbours(
const typename SPHTree::coords &c, uint32_t newNsph,
SPHState *state = 0);
void fetchNeighboursOnVolume(
const typename SPHTree::coords &c, ComputePrecision radius);
const typename SPHTree::coords &getCurrentCenter() const {

View file

@ -35,32 +35,38 @@ namespace CosmoTool {
template <typename ValType, int Ndims>
void SPHSmooth<ValType, Ndims>::fetchNeighbours(
const typename SPHTree::coords &c, uint32_t newNngb) {
const typename SPHTree::coords &c, uint32_t newNngb, SPHState *state) {
ComputePrecision d2, max_dist = 0;
uint32_t requested = newNngb;
if (requested > maxNgb) {
maxNgb = requested;
internal.ngb = boost::shared_ptr<P_SPHCell[]>(new P_SPHCell[maxNgb]);
internal.distances =
boost::shared_ptr<CoordType[]>(new CoordType[maxNgb]);
if (state != 0) {
state->distances = boost::shared_ptr<CoordType[]>(new CoordType[newNngb]);
state->ngb = boost::shared_ptr<SPHCell *[]>(new SPHCell *[newNngb]);
} else {
state = &internal;
if (requested > maxNgb) {
maxNgb = requested;
internal.ngb = boost::shared_ptr<P_SPHCell[]>(new P_SPHCell[maxNgb]);
internal.distances =
boost::shared_ptr<CoordType[]>(new CoordType[maxNgb]);
}
}
memcpy(internal.currentCenter, c, sizeof(c));
memcpy(state->currentCenter, c, sizeof(c));
tree->getNearestNeighbours(
c, requested, (SPHCell **)internal.ngb.get(),
(CoordType *)internal.distances.get());
c, requested, (SPHCell **)state->ngb.get(),
(CoordType *)state->distances.get());
internal.currentNgb = 0;
for (uint32_t i = 0; i < requested && (internal.ngb)[i] != 0;
i++, internal.currentNgb++) {
internal.distances[i] = sqrt(internal.distances[i]);
d2 = internal.distances[i];
state->currentNgb = 0;
for (uint32_t i = 0; i < requested && (state->ngb)[i] != 0;
i++, state->currentNgb++) {
state->distances[i] = sqrt(state->distances[i]);
d2 = state->distances[i];
if (d2 > max_dist)
max_dist = d2;
}
internal.smoothRadius = max_dist / 2;
state->smoothRadius = max_dist / 2;
}
template <typename ValType, int Ndims>
@ -206,7 +212,7 @@ namespace CosmoTool {
ComputePrecision d = state->distances[i];
SPHCell &cell = *(state->ngb[i]);
double kernel_value = getKernel(d / state->smoothRadius) / r3;
#pragma omp atomic
#pragma omp atomic update
cell.val.weight += kernel_value;
}
}
@ -241,5 +247,4 @@ namespace CosmoTool {
const SPHSmooth<ValType2, Ndims> &s2) {
return (s1.getSmoothingLen() < s2.getSmoothingLen());
}
}; // namespace CosmoTool