Tons of build updates

This commit is contained in:
Guilhem Lavaux 2016-11-26 21:30:44 +01:00
parent 9ef2b008b0
commit c61daed876
8 changed files with 81 additions and 44 deletions

View File

@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_STANDARD 11)
cmake_policy(SET CMP0012 OLD)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
project(CosmoToolbox) project(CosmoToolbox)

View File

@ -5,9 +5,9 @@ OPTION(ENABLE_OPENMP "Set to Yes if Healpix and/or you need openMP" OFF)
SET(FFTW_URL "http://www.fftw.org/fftw-3.3.3.tar.gz" CACHE URL "URL to download FFTW from") SET(FFTW_URL "http://www.fftw.org/fftw-3.3.3.tar.gz" CACHE URL "URL to download FFTW from")
SET(EIGEN_URL "http://bitbucket.org/eigen/eigen/get/3.1.4.tar.gz" CACHE URL "URL to download Eigen from") SET(EIGEN_URL "http://bitbucket.org/eigen/eigen/get/3.1.4.tar.gz" CACHE URL "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") SET(GENGETOPT_URL "ftp://ftp.gnu.org/gnu/gengetopt/gengetopt-2.22.5.tar.gz" CACHE STRING "URL to download gengetopt from")
SET(HDF5_URL "http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.15/src/hdf5-1.8.15.tar.gz" CACHE STRING "URL to download HDF5 from") SET(HDF5_URL "https://support.hdfgroup.org/ftp/HDF5/current18/src/hdf5-1.8.18.tar.bz2" CACHE STRING "URL to download HDF5 from")
SET(NETCDF_URL "http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.1.3.tar.gz" CACHE STRING "URL to download NetCDF from") SET(NETCDF_URL "http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.1.3.tar.gz" CACHE STRING "URL to download NetCDF from")
SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz/download" CACHE STRING "URL to download Boost from") SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download" CACHE STRING "URL to download Boost from")
SET(GSL_URL "ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz" CACHE STRING "URL to download GSL from ") SET(GSL_URL "ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz" CACHE STRING "URL to download GSL from ")
mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL) mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL)
@ -27,7 +27,8 @@ ENDIF(ENABLE_OPENMP)
SET(BUILD_PREFIX ${CMAKE_BINARY_DIR}/external_build) SET(BUILD_PREFIX ${CMAKE_BINARY_DIR}/external_build)
SET(EXT_INSTALL ${CMAKE_BINARY_DIR}/ext_install) SET(EXT_INSTALL ${CMAKE_BINARY_DIR}/ext_install)
SET(CONFIGURE_LIBS ) SET(CONFIGURE_LIBS )
SET(CONFIGURE_CPP_FLAGS) SET(CONFIGURE_CPP_FLAGS "")
SET(CONFIGURE_LDFLAGS "")
if (ENABLE_SHARP) if (ENABLE_SHARP)
SET(SHARP_SOURCE ${CMAKE_SOURCE_DIR}/external/sharp) SET(SHARP_SOURCE ${CMAKE_SOURCE_DIR}/external/sharp)
@ -71,16 +72,26 @@ if (INTERNAL_HDF5)
SET(HDF5_ROOTDIR ${HDF5_BIN_DIR}) SET(HDF5_ROOTDIR ${HDF5_BIN_DIR})
SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${HDF5_BIN_DIR}/lib") SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${HDF5_BIN_DIR}/lib")
SET(CONFIGURE_LIBS "${CONFIGURE_LIBS} -ldl") SET(CONFIGURE_LIBS "${CONFIGURE_LIBS} -ldl")
MESSAGE("Internal HDF5 directory: $ENV{HDF5_ROOT}") set(HDF5_LIBRARIES ${HDF5_BIN_DIR}/lib/libhdf5.a CACHE STRING "HDF5 lib" FORCE)
set(HDF5_HL_LIBRARIES ${HDF5_BIN_DIR}/lib/libhdf5_hl.a CACHE STRING "HDF5 HL lib" FORCE)
set(HDF5_CXX_LIBRARIES ${HDF5_BIN_DIR}/lib/libhdf5_cpp.a CACHE STRING "HDF5 C++ lib" FORCE)
SET(HDF5_INCLUDE_DIR ${HDF5_BIN_DIR}/include CACHE STRING "HDF5 include path" FORCE)
mark_as_advanced(HDF5_LIBRARIES HDF5_CXX_LIBRARIES HDF5_INCLUDE_DIR)
MESSAGE(STATUS "Internal HDF5 directory: $ENV{HDF5_ROOT}")
MESSAGE(STATUS "Libs: ${HDF5_LIBRARIES}")
SET(HDF5_FOUND TRUE)
else (INTERNAL_HDF5) else (INTERNAL_HDF5)
mark_as_advanced(CLEAR HDF5_LIBRARIES HDF5_CXX_LIBRARIES HDF5_INCLUDE_DIR)
if(HDF5_ROOTDIR) if(HDF5_ROOTDIR)
SET(ENV{HDF5_ROOT} ${HDF5_ROOTDIR}) SET(ENV{HDF5_ROOT} ${HDF5_ROOTDIR})
endif(HDF5_ROOTDIR) endif(HDF5_ROOTDIR)
endif (INTERNAL_HDF5)
find_package(HDF5 COMPONENTS C CXX HL) find_package(HDF5 COMPONENTS C CXX HL)
mark_as_advanced(HDF5_INCLUDE_DIR HDF5_LIBRARY HDF5_HL_LIBRARY) endif (INTERNAL_HDF5)
SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${HDF5_INCLUDE_DIR}") foreach(include_dir ${HDF5_INCLUDE_DIR})
SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${include_dir}")
endforeach(include_dir)
############### ###############
# Build NetCDF # Build NetCDF
@ -90,24 +101,25 @@ SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${HDF5_INCLUDE_DIR}")
if (INTERNAL_NETCDF) if (INTERNAL_NETCDF)
SET(NETCDF_SOURCE_DIR ${BUILD_PREFIX}/netcdf-prefix/src/netcdf) SET(NETCDF_SOURCE_DIR ${BUILD_PREFIX}/netcdf-prefix/src/netcdf)
SET(NETCDF_BIN_DIR ${EXT_INSTALL}) SET(NETCDF_BIN_DIR ${EXT_INSTALL})
SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_BIN_DIR}/include") # SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_BIN_DIR}/include")
SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${NETCDF_BIN_DIR}/lib") SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${NETCDF_BIN_DIR}/lib")
SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LIBS=${CONFIGURE_LIBS} LDFLAGS=${CONFIGURE_LDFLAGS}) SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LIBS=${CONFIGURE_LIBS} LDFLAGS=${CONFIGURE_LDFLAGS})
ExternalProject_Add(netcdf SET(NETCDF_CONFIG_COMMAND ${NETCDF_SOURCE_DIR}/configure
DEPENDS ${hdf5_built}
PREFIX ${BUILD_PREFIX}/netcdf-prefix
URL ${NETCDF_URL}
CONFIGURE_COMMAND ${NETCDF_SOURCE_DIR}/configure
--prefix=${NETCDF_BIN_DIR} --libdir=${NETCDF_BIN_DIR}/lib --prefix=${NETCDF_BIN_DIR} --libdir=${NETCDF_BIN_DIR}/lib
--enable-netcdf-4 --with-pic --disable-shared --disable-dap --enable-netcdf-4 --with-pic --disable-shared --disable-dap
--disable-cdmremote --disable-rpc --enable-cxx-4 --disable-cdmremote --disable-rpc --enable-cxx-4
--disable-examples ${EXTRA_NC_FLAGS} CC=${CMAKE_C_COMPILER} --disable-examples ${EXTRA_NC_FLAGS} CC=${CMAKE_C_COMPILER}
CXX=${CMAKE_CXX_COMPILER} CXX=${CMAKE_CXX_COMPILER})
ExternalProject_Add(netcdf
DEPENDS ${hdf5_built}
PREFIX ${BUILD_PREFIX}/netcdf-prefix
URL ${NETCDF_URL}
CONFIGURE_COMMAND ${NETCDF_CONFIG_COMMAND}
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
) )
SET(CONFIGURE_CPP_LDFLAGS "${CONFIGURE_LDFLAGS}") # SET(CONFIGURE_CPP_LDFLAGS "${CONFIGURE_LDFLAGS}")
SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LDFLAGS=${CONFIGURE_CPP_LDFLAGS}) # SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LDFLAGS=${CONFIGURE_CPP_LDFLAGS})
SET(cosmotool_DEPS ${cosmotool_DEPS} netcdf) SET(cosmotool_DEPS ${cosmotool_DEPS} netcdf)
SET(NETCDF_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf.a CACHE STRING "NetCDF lib" FORCE) SET(NETCDF_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf.a CACHE STRING "NetCDF lib" FORCE)
SET(NETCDFCPP_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf_c++4.a CACHE STRING "NetCDF-C++ lib" FORCE) SET(NETCDFCPP_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf_c++4.a CACHE STRING "NetCDF-C++ lib" FORCE)
@ -120,8 +132,7 @@ ELSE(INTERNAL_NETCDF)
find_library(NETCDF_LIBRARY netcdf) find_library(NETCDF_LIBRARY netcdf)
find_library(NETCDFCPP_LIBRARY NAMES netcdf_c++ netcdf_c++4) find_library(NETCDFCPP_LIBRARY NAMES netcdf_c++ netcdf_c++4)
SET(CONFIGURE_CPP_FLAGS ${CONFIGURE_CPP_FLAGS} SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_INCLUDE_PATH} -I${NETCDFCPP_INCLUDE_PATH}")
-I${NETCDF_INCLUDE_PATH} -I${NETCDFCPP_INCLUDE_PATH})
endif (INTERNAL_NETCDF) endif (INTERNAL_NETCDF)
mark_as_advanced(NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH NETCDFCPP_INCLUDE_PATH) mark_as_advanced(NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH NETCDFCPP_INCLUDE_PATH)
@ -130,6 +141,7 @@ mark_as_advanced(NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH NETCDFCPP_
################## ##################
if (INTERNAL_BOOST) if (INTERNAL_BOOST)
message(STATUS "Building Boost")
SET(BOOST_SOURCE_DIR ${BUILD_PREFIX}/boost-prefix/src/boost) SET(BOOST_SOURCE_DIR ${BUILD_PREFIX}/boost-prefix/src/boost)
ExternalProject_Add(boost ExternalProject_Add(boost
URL ${BOOST_URL} URL ${BOOST_URL}

View File

@ -36,7 +36,8 @@ add_library(_cosmo_power MODULE ${CMAKE_CURRENT_BINARY_DIR}/_cosmo_power.cpp)
add_library(_cosmo_cic MODULE ${CMAKE_CURRENT_BINARY_DIR}/_cosmo_cic.cpp) add_library(_cosmo_cic MODULE ${CMAKE_CURRENT_BINARY_DIR}/_cosmo_cic.cpp)
add_library(_fast_interp MODULE ${CMAKE_CURRENT_BINARY_DIR}/_fast_interp.cpp) add_library(_fast_interp MODULE ${CMAKE_CURRENT_BINARY_DIR}/_fast_interp.cpp)
add_library(_project MODULE ${CMAKE_CURRENT_BINARY_DIR}/_project.cpp) add_library(_project MODULE ${CMAKE_CURRENT_BINARY_DIR}/_project.cpp)
add_library(_cosmo_bispectrum MODULE _cosmo_bispectrum.cpp)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Bsymbolic-functions") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Bsymbolic-functions")
@ -45,7 +46,17 @@ target_link_libraries(_cosmo_power ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_
target_link_libraries(_cosmo_cic ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES}) target_link_libraries(_cosmo_cic ${CosmoTool_local} ${PYTHON_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(_project ${PYTHON_LIBRARIES}) target_link_libraries(_project ${PYTHON_LIBRARIES})
target_link_libraries(_fast_interp ${CosmoTool_local} ${PYTHON_LIBRARIES}) target_link_libraries(_fast_interp ${CosmoTool_local} ${PYTHON_LIBRARIES})
SET(ct_TARGETS _cosmotool _project _cosmo_power _cosmo_cic _fast_interp )
if (Boost_FOUND)
message(STATUS "Building bispectrum support (path = ${Boost_INCLUDE_DIRS})")
include_directories(${Boost_INCLUDE_DIRS})
add_library(_cosmo_bispectrum MODULE _cosmo_bispectrum.cpp)
target_link_libraries(_cosmo_bispectrum ${MATH_LIBRARY}) target_link_libraries(_cosmo_bispectrum ${MATH_LIBRARY})
add_dependencies(_cosmo_bispectrum boost)
SET(ct_TARGETS ${ct_TARGETS} _cosmo_bispectrum)
endif()
# Discover where to put packages # Discover where to put packages
if (NOT PYTHON_SITE_PACKAGES) if (NOT PYTHON_SITE_PACKAGES)
@ -71,7 +82,8 @@ if (WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(_cosmotool PROPERTIES SUFFIX ".pyd") SET_TARGET_PROPERTIES(_cosmotool PROPERTIES SUFFIX ".pyd")
endif (WIN32 AND NOT CYGWIN) endif (WIN32 AND NOT CYGWIN)
INSTALL(TARGETS _cosmotool _project _cosmo_power _cosmo_cic _fast_interp _cosmo_bispectrum INSTALL(TARGETS
${ct_TARGETS}
LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}/cosmotool LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}/cosmotool
) )

View File

@ -1,7 +1,8 @@
import timeit
import numpy as np import numpy as np
import cosmotool as ct import cosmotool as ct
N=32 def myfun(N):
f=0.10 f=0.10
d=np.random.normal(size=(N,)*3) d=np.random.normal(size=(N,)*3)
rho = d + f *(d*d - np.average(d*d)) rho = d + f *(d*d - np.average(d*d))
@ -16,4 +17,9 @@ BB = B[1]/B[0]/N**6
y = BB/x y = BB/x
np.savez("bispec_%d.npy" % N, y=y, B=B, P=P, rho=rho);
print( timeit.timeit('from __main__ import myfun; myfun(16)', number=1) )
print( timeit.timeit('from __main__ import myfun; myfun(32)', number=1) )
print( timeit.timeit('from __main__ import myfun; myfun(64)', number=1) )

View File

@ -43,9 +43,6 @@ if (HDF5_FOUND)
add_executable(testHDF5 testHDF5.cpp) add_executable(testHDF5 testHDF5.cpp)
target_link_libraries(testHDF5 ${tolink}) target_link_libraries(testHDF5 ${tolink})
add_executable(gadgetToArray gadgetToArray.cpp)
target_link_libraries(gadgetToArray ${tolink})
add_executable(graficToDensity graficToDensity.cpp) add_executable(graficToDensity graficToDensity.cpp)
target_link_libraries(graficToDensity ${tolink}) target_link_libraries(graficToDensity ${tolink})
endif (HDF5_FOUND) endif (HDF5_FOUND)
@ -94,6 +91,10 @@ if (Boost_FOUND)
add_executable(simple3DFilter simple3DFilter.cpp) add_executable(simple3DFilter simple3DFilter.cpp)
target_link_libraries(simple3DFilter ${tolink}) target_link_libraries(simple3DFilter ${tolink})
ENDIF (YORICK_SUPPORT) ENDIF (YORICK_SUPPORT)
if (HDF5_FOUND)
add_executable(gadgetToArray gadgetToArray.cpp)
target_link_libraries(gadgetToArray ${tolink})
endif()
endif (Boost_FOUND) endif (Boost_FOUND)
IF (ENABLE_OPENMP AND YORICK_SUPPORT) IF (ENABLE_OPENMP AND YORICK_SUPPORT)

View File

@ -33,6 +33,7 @@ The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms. knowledge of the CeCILL license and that you accept its terms.
+*/ +*/
#include <cmath> #include <cmath>
#include <algorithm>
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include "cic.hpp" #include "cic.hpp"

View File

@ -33,8 +33,8 @@ The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms. knowledge of the CeCILL license and that you accept its terms.
+*/ +*/
#include <iostream> #include <iostream>
#include <H5Cpp.h>
#include "hdf5_array.hpp" #include "hdf5_array.hpp"
#include <H5Cpp.h>
using namespace std; using namespace std;

View File

@ -68,16 +68,19 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS}
growthFactor.hpp growthFactor.hpp
) )
include_directories(${Boost_INCLUDE_DIRS} ${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) include_directories(${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src)
set(CosmoTool_LIBS ${GSL_LIBRARIES}) set(CosmoTool_LIBS ${GSL_LIBRARIES})
if(YORICK_SUPPORT) if(YORICK_SUPPORT)
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES}) set(CosmoTool_LIBS ${CosmoTool_LIBS} ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES})
include_directories(${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH}) include_directories(${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH})
endif(YORICK_SUPPORT) endif(YORICK_SUPPORT)
message(STATUS "HDF5 ? ${HDF5_FOUND}")
if (HDF5_FOUND) if (HDF5_FOUND)
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_LIBRARIES} ${HDF5_C_LIBRARY} ${ZLIB}) set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${ZLIB})
include_directories(${HDF5_INCLUDE_DIRS}) include_directories(${HDF5_INCLUDE_DIRS})
message(STATUS "CosmoTool_LIBS: ${CosmoTool_LIBS}")
endif (HDF5_FOUND) endif (HDF5_FOUND)
set(CosmoTool_LIBS ${CosmoTool_LIBS} PARENT_SCOPE) set(CosmoTool_LIBS ${CosmoTool_LIBS} PARENT_SCOPE)