Skip to content

Commit

Permalink
Merge pull request #65 from LBL-EESA/develop
Browse files Browse the repository at this point in the history
updates for TECA 5
  • Loading branch information
burlen authored Jul 5, 2022
2 parents 7e62d0a + d50fb5d commit 60a5f0c
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 8 deletions.
111 changes: 104 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(TECA_DEPS_URL "https://sourceforge.net/projects/teca/files/TECA_deps"
CACHE STRING "URL to the dependency tarballs")

set(LIBXLSXWRITER_URL http://github.com/burlen/libxlsxwriter.git)
set(SHAPELIB_URL https://github.com/OSGeo/shapelib.git)

# The following versions of each library are installed by this script:
set(MPICH_SOURCE mpich-3.3.1)
Expand All @@ -36,7 +37,8 @@ set(CYTHON_SOURCE Cython-0.29.21)
set(NUMPY_SOURCE numpy-1.19.1)
set(MPI4PY_SOURCE mpi4py-3.0.3)
set(LIBXLSXWRITER_SOURCE cmake_configure)
set(TECA_SOURCE 4.0.0 CACHE STRING
set(SHAPELIB_SOURCE 21ae8fc16)
set(TECA_SOURCE 5.0.0 CACHE STRING
"branch to checkout from the TECA git repository")

# extract version numbers
Expand All @@ -60,11 +62,17 @@ get_package_version(${CYTHON_SOURCE} Cython CYTHON)
get_package_version(${NUMPY_SOURCE} numpy NUMPY)
get_package_version(${MPI4PY_SOURCE} mpi4py MPI4PY)
set(MATPLOTLIB_VERSION 3.3.4)
set(PYTORCH_VERSION 1.7.0+cpu)
set(TCPYPI_VERSION 1.3.4)
set(TORCH_VERSION 1.10.0)
set(TORCHAUDIO_VERSION 0.10.0)
set(TORCHVISION_VERSION 0.11.1)
set(CUPY_VERSION cuda113)

# enable/disable each piece, all on by default
option(ENABLE_CUDA "configures for use with CUDA" OFF)
option(ENABLE_BOOST "builds and installs Boost" ON)
option(ENABLE_LIBXLSXWRITER "builds and installs libxlsxwriter" ON)
option(ENABLE_SHAPELIB "builds and installs OSGeo shapelib" ON)
option(ENABLE_MPICH "builds and installs MPICH MPI" OFF)
option(ENABLE_OPENMPI "builds and installs OpenMPI MPI" ON)
option(ENABLE_CRAY_MPICH "Auto detect MPICH configuration for Cray systems" OFF)
Expand All @@ -73,6 +81,7 @@ option(ENABLE_NETCDF "builds and installs NetCDF group" ON)
option(ENABLE_PYTHON "builds and installs Python group" ON)
option(ENABLE_READLINE "builds and installs readline" OFF)
option(ENABLE_MATPLOTLIB "installs matplotlib via pip" ON)
option(ENABLE_TCPYPI "installs tcpyPI via pip" ON)
option(ENABLE_PYTORCH "installs pytorch via pip" ON)
option(ENABLE_TECA "builds and installs TECA" ON)
option(ENABLE_TECA_TEST "runs the TECA regression tests" ON)
Expand Down Expand Up @@ -574,23 +583,76 @@ if (ENABLE_PYTHON)
endif()

if (ENABLE_PYTORCH)
if (ENABLE_CUDA)
set(PYTORCH_DEV cu113)
else()
set(PYTORCH_DEV cpu)
endif()
# install pytorch
build_status(pytorch ${PYTORCH_VERSION} Enabled)
build_status(pytorch "${TORCH_VERSION}+${PYTORCH_DEV}" Enabled)
list(APPEND teca_deps pytorch)
ExternalProject_Add(pytorch
DEPENDS Python numpy
DOWNLOAD_COMMAND ""
SOURCE_DIR ${PROJECT_BINARY_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND env ${env} ${CMAKE_INSTALL_PREFIX}/bin/python3
-mpip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0
-f https://download.pytorch.org/whl/torch_stable.html
-mpip install torch==${TORCH_VERSION}+${PYTORCH_DEV}
torchvision==${TORCHVISION_VERSION}+${PYTORCH_DEV}
torchaudio==${TORCHAUDIO_VERSION}+${PYTORCH_DEV}
-f https://download.pytorch.org/whl/${PYTORCH_DEV}/torch_stable.html
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1 LOG_DOWNLOAD 1 LOG_BUILD 1)
else()
build_status(pytorch ${TORCH_VERSION} Disabled)
endif()

if (ENABLE_TCPYPI)
# install tcpyPI
build_status(tcpyPI ${TCPYPI_VERSION} Enabled)
list(APPEND teca_deps tcpyPI)

# numba
ExternalProject_Add(numba
DEPENDS Python numpy
DOWNLOAD_COMMAND ""
SOURCE_DIR ${PROJECT_BINARY_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND env ${env} ${CMAKE_INSTALL_PREFIX}/bin/python3
-mpip install numba==0.53.1
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1 LOG_DOWNLOAD 1 LOG_BUILD 1)

# tcpyPI
ExternalProject_Add(tcpyPI
DEPENDS Python numpy numba
DOWNLOAD_COMMAND ""
SOURCE_DIR ${PROJECT_BINARY_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND env ${env} ${CMAKE_INSTALL_PREFIX}/bin/python3
-mpip install tcpyPI==${TCPYPI_VERSION} --no-dependencies
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1 LOG_DOWNLOAD 1 LOG_BUILD 1)
else()
build_status(pytorch ${PYTORCH_VERSION} Disabled)
build_status(tcpyPI ${TCPYPI_VERSION} Disabled)
endif()

if (ENABLE_CUDA)
# install cupy
build_status(cupy ${CUPY_VERSION} Enabled)
list(APPEND teca_deps cupy)
ExternalProject_Add(cupy
DEPENDS Python numpy
DOWNLOAD_COMMAND ""
SOURCE_DIR ${PROJECT_BINARY_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND env ${env} ${CMAKE_INSTALL_PREFIX}/bin/python3
-mpip install cupy-${CUPY_VERSION}
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1 LOG_DOWNLOAD 1 LOG_BUILD 1)
else()
build_status(cupy ${CUPY_VERSION} Disabled)
endif()

else()
build_status(ncurses ${NCURSES_VERSION} Disabled)
Expand All @@ -604,6 +666,8 @@ else()
build_status(mpi4py ${MPI4PY_VERSION} Disabled)
build_status(matplotlib ${MATPLOTLIB_VERSION} Disabled)
build_status(pytorch ${PYTORCH_VERSION} Disabled)
build_status(tcpyPI ${TCPYPI_VERSION} Disabled)
build_status(cupy ${CUPY_VERSION} Disabled)
endif()

# Build libxlsxwriter.
Expand Down Expand Up @@ -635,6 +699,34 @@ else()
message(STATUS "LIBXLSXWRITER .......... Disabled")
endif()

# Build libxlsxwriter.
if (ENABLE_SHAPELIB)
message(STATUS "shapelib ............... Enabled")
list(APPEND teca_deps shapelib)
list(APPEND teca_flags "-DREQUIRE_SHAPELIB=TRUE")
ExternalProject_Add(shapelib
DOWNLOAD_DIR ${PROJECT_BINARY_DIR}
#URL ${TECA_DEPS_URL}/${SHAPELIB_SOURCE}.tar.gz
GIT_REPOSITORY ${SHAPELIB_URL}
GIT_TAG ${SHAPELIB_SOURCE}
UPDATE_COMMAND ""
SOURCE_DIR ${PROJECT_BINARY_DIR}/${SHAPELIB_SOURCE}
CMAKE_COMMAND env ${env} ${CMAKE_COMMAND}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
"-DCMAKE_C_FLAGS=${c_flags}"
"-DCMAKE_C_FLAGS_DEBUG=${c_flags}"
"-DCMAKE_C_FLAGS_RELEASE=${c_flags}"
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
"-DCMAKE_CXX_FLAGS=${cxx_flags}"
"-DCMAKE_CXX_FLAGS_DEBUG=${cxx_flags}"
"-DCMAKE_CXX_FLAGS_RELEASE=${cxx_flags}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1)
else()
message(STATUS "shapelib ............... Disabled")
endif()

# TECA proper
if (ENABLE_TECA)
build_status(TECA ${TECA_SOURCE} Enabled)
Expand All @@ -660,10 +752,14 @@ if (ENABLE_TECA)
set(TECA_UPDATE "")
set(TECA_DATA_REV "-r101")
set(TECA_DATA_UPDATE "")
elseif (TECA_SOURCE STREQUAL "4.1.0" OR TECA_SOURCE STREQUAL "master")
elseif (TECA_SOURCE STREQUAL "4.1.0")
set(TECA_UPDATE "")
set(TECA_DATA_REV "-r117")
set(TECA_DATA_UPDATE "")
elseif (TECA_SOURCE STREQUAL "5.0.0" OR TECA_SOURCE STREQUAL "master")
set(TECA_UPDATE "")
set(TECA_DATA_REV "-r137")
set(TECA_DATA_UPDATE "")
endif()
set(tmp)
if (ENABLE_TECA_DATA)
Expand Down Expand Up @@ -712,6 +808,7 @@ if (ENABLE_TECA)
${teca_flags} ${MPI_FLAGS} -DTECA_HAS_VTK=OFF
-DTECA_PYTHON_VERSION=3 -DTECA_DATA_ROOT=${TECA_DATA_ROOT}
-DBUILD_TESTING=${ENABLE_TECA_TEST}
-DREQUIRE_CUDA=${ENABLE_CUDA}
-DTECA_ENABLE_PROFILER=${ENABLE_TECA_PROFILER}
${PROJECT_BINARY_DIR}/TECA
TEST_AFTER_INSTALL ${ENABLE_TECA_TEST}
Expand Down
8 changes: 8 additions & 0 deletions modulefiles/teca.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ if {[string compare "@ENABLE_CRAY_MPICH@" "ON"] == 0} {
# make sure we have the GNU programming environment on NERSC systems
prereq PrgEnv-gnu

# make sure we have CUDA gcc compiler modules loaded
if {[string compare "@ENABLE_CUDA@" "ON"] == 0} {

prereq cudatoolkit
prereq cpe-cuda

}

# this tells cmake it is OK to build/use shared libraries, otherwise
# it errors out
setenv CRAYPE_LINK_TYPE dynamic
Expand Down
22 changes: 22 additions & 0 deletions mpi4py.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,25 @@ runtime_library_dirs = @CMAKE_INSTALL_PREFIX@/lib
extra_compile_args = @CMAKE_C_FLAGS@ @MPI4PY_CFLAGS@
extra_link_args = @MPI4PY_LDFLAGS@
extra_objects =

[perlmutter]
mpicc = @CMAKE_C_COMPILER@
mpicxx = @CMAKE_CXX_COMPILER@
include_dirs = @CMAKE_INSTALL_PREFIX@/include
libraries =
library_dirs =
runtime_library_dirs = @CMAKE_INSTALL_PREFIX@/lib
extra_compile_args = @CMAKE_C_FLAGS@ @MPI4PY_CFLAGS@
extra_link_args = @MPI4PY_LDFLAGS@
extra_objects =

[bigred200]
mpicc = @CMAKE_C_COMPILER@
mpicxx = @CMAKE_CXX_COMPILER@
include_dirs = @CMAKE_INSTALL_PREFIX@/include
libraries =
library_dirs =
runtime_library_dirs = @CMAKE_INSTALL_PREFIX@/lib
extra_compile_args = @CMAKE_C_FLAGS@ @MPI4PY_CFLAGS@
extra_link_args = @MPI4PY_LDFLAGS@
extra_objects =
2 changes: 1 addition & 1 deletion site/make_install_cori_m1517.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -e

# get the root of the install
TECA_REV=`git ls-remote git@github.com:LBL-EESA/TECA.git | grep ${TECA_SOURCE} | cut -c1-8`
: ${TECA_PREFIX:=/global/common/software/m1517/teca}
: ${TECA_PREFIX:=/global/common/software/m1517/teca/cori}
: ${PREFIX:=${TECA_PREFIX}/${TECA_SOURCE}-${TECA_REV}}

# mark as dependency only
Expand Down
142 changes: 142 additions & 0 deletions site/make_install_perlmutter_m1517.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/bash

# show what the script is doing and error out if any command fails
set -e
#set -x

# is this for the CPU partition or GPU ?
: ${ENABLE_CUDA:=ON}
if [[ "${ENABLE_CUDA}" == "ON" ]]
then
PARTITION=gpu
else
PARTITION=cpu
fi

# load the gcc environment
module load PrgEnv-gnu
if [[ "${ENABLE_CUDA}" == "ON" ]]
then
module load cudatoolkit
module load cpe-cuda
fi
module load cmake

# mpich is not in the pkg-config path on Cori
export PKG_CONFIG_PATH=${CRAY_MPICH_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}

# choose the branch or tag to compile.
: ${TECA_SOURCE:=develop}

# turn TECA off for a develoment install
: ${ENABLE_TECA:=ON}

# get the root of the install
TECA_REV=`git ls-remote git@github.com:LBL-EESA/TECA.git | grep ${TECA_SOURCE} | cut -c1-8`
: ${TECA_PREFIX:=/global/common/software/m1517/teca/perlmutter_${PARTITION}}
: ${PREFIX:=${TECA_PREFIX}/${TECA_SOURCE}-${TECA_REV}}

# mark as dependency only
if [[ "${ENABLE_TECA}" != "ON" ]]
then
echo "build and install dependencies only"
PREFIX=${PREFIX}-deps
fi

BUILD_DIR=build-${PARTITION}-${TECA_SOURCE}-${TECA_REV}

echo "TECA is ${ENABLE_TECA}"
echo "building ${TECA_SOURCE}"
echo "CUDA is ${ENABLE_CUDA}"
echo "build in ${BUILD_DIR}"
echo "install to ${PREFIX}"

# clone and checkout the corresponding superbuild
if [[ ! -d TECA_superbuild ]]
then
echo "cloning the superbuild ... "
git clone https://github.com/LBL-EESA/TECA_superbuild.git
fi
echo "updating the superbuild to ${TECA_SOURCE} ... "
cd TECA_superbuild
git checkout ${TECA_SOURCE}
git pull --rebase

# prompt to clean out the previous build and install
rm_build=n
if [[ -d ${BUILD_DIR} ]]
then
read -p "Question: Do you want me to rm -rf ${BUILD_DIR} before ? " rm_build
if [[ "${rm_build}" != "y" ]]
then
echo "WARNING: I will not rm -rf ${BUILD_DIR} before. this may lead to later build failures."
fi
fi

rm_build_post=n
read -p "Question: Do you want me to rm -rf ${BUILD_DIR} after ? " rm_build_post
if [[ "${rm_build_post}" != "y" ]]
then
echo "WARNING: I will not rm -rf ${BUILD_DIR} after. this may waste disk space."
fi

rm_install=n
if [[ -d ${PREFIX} ]]
then
read -p "Question: Do you want me to rm -rf ${PREFIX} ? " rm_install
if [[ "${rm_install}" != "y" ]]
then
echo "WARNING: I will not rm -rf ${PREFIX}. this may lead to later build failures."
fi
fi

# clean out the previous build and install
if [[ "${rm_build}" == "y" ]]
then
echo "cleaning out the old build in ${BUILD_DIR} ... "
rm -rf ${BUILD_DIR}
fi

if [[ "${rm_install}" == "y" ]]
then
echo "cleaning out the old install in ${PREFIX} ... "
rm -rf ${PREFIX}
fi

# make a new build directory
echo "configuring the build in ${BUILD_DIR} ... "
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}

# Configure TECA superbuild
cmake \
-DCMAKE_CXX_COMPILER=`which g++` \
-DCMAKE_C_COMPILER=`which gcc` \
-DCMAKE_BUILD_TYPE=Release \
-DTECA_SOURCE=${TECA_SOURCE} \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DENABLE_CUDA=${ENABLE_CUDA} \
-DENABLE_MPICH=OFF \
-DENABLE_OPENMPI=OFF \
-DENABLE_CRAY_MPICH=ON \
-DENABLE_TECA_TEST=OFF \
-DENABLE_TECA_DATA=ON \
-DENABLE_TECA=${ENABLE_TECA} \
-DENABLE_TECA_PROFILER=OFF \
..

# do the build and install
echo "build and install ... "
make -j16 install

# open the install to other users
echo "opening permissions for m1517 ... "
fix_perms -g m1517 ${PREFIX}

# clean out the previous build
cd ..
if [[ "${rm_build_post}" == "y" ]]
then
echo "cleaning out the build in ${BUILD_DIR} ... "
rm -rf ${BUILD_DIR}
fi
3 changes: 3 additions & 0 deletions version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function(build_status component version status)
string(LENGTH ${component} comp_len)
string(LENGTH ${version} ver_len)
math(EXPR n_dots "24 - ${comp_len} - ${ver_len} - 4")
if (n_dots LESS 0)
set(n_dots 2)
endif()
string(SUBSTRING "........................" 0 ${n_dots} dots)
message(STATUS "${component} (${version}) ${dots} ${status}")
endfunction()

0 comments on commit 60a5f0c

Please sign in to comment.