Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFlynt committed May 19, 2021
1 parent c517604 commit cbf1169
Show file tree
Hide file tree
Showing 12 changed files with 659 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
downloads/*.gz
downloads/*.bz2
downloads/*.zip
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

include config.mk
include rules.mk
7 changes: 7 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#export PWD=$(shell pwd)
export BUILD_DIR=${PWD}/build
export INSTALL_DIR=${PWD}/apps
export TAR_DIR=${PWD}/downloads
export SRC_DIR=${PWD}/src
export LOG_DIR=${PWD}/log
export MODULE_DIR=${PWD}/modulefiles
19 changes: 19 additions & 0 deletions downloads/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

wget "https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-linux-x86_64.tar.gz"
wget "https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-macos-universal.tar.gz"

wget "https://mirrors.kernel.org/gnu/gcc/gcc-11.1.0/gcc-11.1.0.tar.gz"

wget "https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.1.tar.bz2"

wget "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2"
mv boost_1_76_0.tar.bz2 boost-1.76.0.tar.bz2

wget "https://github.com/xianyi/OpenBLAS/releases/download/v0.3.15/OpenBLAS-0.3.15.tar.gz"
mv OpenBLAS-0.3.15.tar.gz openblas-0.3.15.tar.gz

wget "https://github.com/flame/blis/archive/refs/tags/0.8.1.tar.gz"
mv 0.8.1.tar.gz blis-0.8.1.tar.gz

wget "https://github.com/llvm/llvm-project/archive/llvmorg-9.0.0.zip"
81 changes: 81 additions & 0 deletions rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

all : cmake gcc openmpi boost openblas

clean :
rm -rf log
rm -rf build

cleanall : clean
rm -rf opt
rm -rf modulefiles

# -----------------------------------------------
# CMake
# -----------------------------------------------

cmake : cmake-3.20.2

cmake-3.20.2 : ${MODULE_DIR}/base/cmake/3.20.2.lua

${MODULE_DIR}/base/cmake/3.20.2.lua:
${SRC_DIR}/build.sh cmake 3.20.2

# -----------------------------------------------
# GCC
# -----------------------------------------------

gcc : gcc-11.1.0

gcc-11.1.0 : ${MODULE_DIR}/base/gcc/11.1.0.lua

${MODULE_DIR}/base/gcc/11.1.0.lua:
${SRC_DIR}/build.sh gcc 11.1.0

# -----------------------------------------------
# OpenMPI
# -----------------------------------------------

openmpi : openmpi-4.1.1-gcc-11.1.0

openmpi-4.1.1-gcc-11.1.0 : ${MODULE_DIR}/compiler/gcc/11.1.0/openmpi/4.1.1.lua

${MODULE_DIR}/compiler/gcc/11.1.0/openmpi/4.1.1.lua :
${SRC_DIR}/build.sh openmpi 4.1.1 gcc 11.1.0

# -----------------------------------------------
# Boost
# -----------------------------------------------

boost : boost-1.76.0-gcc-11.1.0 boost-1.76.0-openmpi-4.1.1-gcc-11.1.0

boost-1.76.0-gcc-11.1.0 : ${MODULE_DIR}/compiler/gcc/11.1.0/boost/1.76.0.lua

${MODULE_DIR}/compiler/gcc/11.1.0/boost/1.76.0.lua :
${SRC_DIR}/build.sh boost 1.76.0 gcc 11.1.0

boost-1.76.0-openmpi-4.1.1-gcc-11.1.0 : ${MODULE_DIR}/mpi/openmpi/4.1.1/gcc/11.1.0/boost/1.76.0.lua

${MODULE_DIR}/mpi/openmpi/4.1.1/gcc/11.1.0/boost/1.76.0.lua :
${SRC_DIR}/build.sh boost 1.76.0 gcc 11.1.0 openmpi 4.1.1

# -----------------------------------------------
# OpenBLAS
# -----------------------------------------------

openblas : openblas-0.3.15-gcc-11.1.0

openblas-0.3.15-gcc-11.1.0 : ${MODULE_DIR}/compiler/gcc/11.1.0/openblas/0.3.15.lua

${MODULE_DIR}/compiler/gcc/11.1.0/openblas/0.3.15.lua :
${SRC_DIR}/build.sh openblas 0.3.15 gcc 11.1.0

# -----------------------------------------------
# BLIS
# -----------------------------------------------

blis : blis-0.8.1-gcc-11.1.0

blis-0.8.1-gcc-11.1.0 : ${MODULE_DIR}/compiler/gcc/11.1.0/blis/0.8.1.lua

${MODULE_DIR}/compiler/gcc/11.1.0/blis/0.8.1.lua :
${SRC_DIR}/build.sh blis 0.8.1 gcc 11.1.0
63 changes: 63 additions & 0 deletions src/blis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash -l

# Abort if any command returns an error
set -e

# Record what we're doing
set -x

# Set the package name
export PKG=blis
export PKG_VERSION=$1
export COMPILER=$2
export COMPILER_VERSION=$3

# Load build environment
module purge
module load ${COMPILER}/${COMPILER_VERSION}

# Make full path names to locations
LIB_BUILD_DIR=${BUILD_DIR}/${PKG}/${PKG_VERSION}/${COMPILER}/${COMPILER_VERSION}
LIB_INSTALL_DIR=${INSTALL_DIR}/${PKG}/${PKG_VERSION}/${COMPILER}/${COMPILER_VERSION}

# Clean if they already exist
rm -rf ${LIB_BUILD_DIR}
rm -rf ${LIB_INSTALL_DIR}

# Make the build directory and cd into it
mkdir -p ${LIB_BUILD_DIR}
cd ${LIB_BUILD_DIR}

# Unpack the Source
tar --strip-components 1 -xzvf ${TAR_DIR}/${PKG}-${PKG_VERSION}.tar.gz

# Configure
./configure --prefix=${LIB_INSTALL_DIR} auto

# Build it
make -j 8
make install

# Create Module File
mkdir -p ${MODULE_DIR}/compiler/${COMPILER}/${COMPILER_VERSION}/${PKG}
cat << EOF > ${MODULE_DIR}/compiler/${COMPILER}/${COMPILER_VERSION}/${PKG}/${PKG_VERSION}.lua
help([[ ${PKG} version ${PKG_VERSION} ]])
family("blis")
-- Conflicts
-- Dependencies
prereq("${COMPILER}/${COMPILER_VERSION}")
-- Modulepath for packages built with this library
-- Environment Paths
prepend_path("CPATH", "${LIB_INSTALL_DIR}/include")
prepend_path("LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib")
prepend_path("LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib64")
prepend_path("LD_LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib")
prepend_path("LD_LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib64")
-- Environment Variables
setenv("BLIS_ROOT", "${LIB_INSTALL_DIR}")
EOF
112 changes: 112 additions & 0 deletions src/boost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash -l

# Abort if any command returns an error
set -e

# Record what we're doing
set -x

# Set the package name
export PKG=boost
export PKG_VERSION=$1
export COMPILER=$2
export COMPILER_VERSION=$3
export MPI_COMPILER=$4
export MPI_COMPILER_VERSION=$5

# Load build environment
module purge
module load ${COMPILER}/${COMPILER_VERSION}
if [ ! -z "${MPI_COMPILER}" ]; then
module load ${MPI_COMPILER}/${MPI_COMPILER_VERSION}
fi

# Make full path names to locations
LIB_BUILD_DIR=$(readlink -m ${BUILD_DIR}/${PKG}/${PKG_VERSION}/${MPI_COMPILER}/${MPI_COMPILER_VERSION}/${COMPILER}/${COMPILER_VERSION})
LIB_INSTALL_DIR=$(readlink -m ${INSTALL_DIR}/${PKG}/${PKG_VERSION}/${MPI_COMPILER}/${MPI_COMPILER_VERSION}/${COMPILER}/${COMPILER_VERSION})

# Clean if they already exist
rm -rf ${LIB_BUILD_DIR}
rm -rf ${LIB_INSTALL_DIR}

# Make the build directory and cd into it
mkdir -p ${LIB_BUILD_DIR}
cd ${LIB_BUILD_DIR}

# Unpack the Source
tar --strip-components 1 -xjvf ${TAR_DIR}/${PKG}-${PKG_VERSION}.tar.bz2

# Build the boot strap builder
toolset=none
case ${COMPILER} in
"gcc" )
toolset=gcc
;;
"intel" )
toolset=intel-linux
;;
"pgi" )
toolset=pgi
;;
*)
echo "Unsupported compiler: ${COMPILER}"
exit 1
;;
esac
./bootstrap.sh --with-toolset=${toolset} --prefix=${LIB_INSTALL_DIR}
#./bootstrap.sh --show-libraries

#
# Insert specifics about the MPI compiler
# Note: The space before and after : and before ; are required
#
if [ ! -z "${MPI_COMPILER}" ]; then
printf "\n# MPI Compiler Details\n" >> project-config.jam
printf "using mpi : %s ;\n" "${MPI_CXX_COMPILER}" >> project-config.jam
fi

# Compile Boost (turn off/on abort since it never compiles everything)
set +e
./b2 -j8 install --layout=system --target=shared,static
set -e

# Create the module path and filename
family=compiler
if [ ! -z "${MPI_COMPILER}" ]; then
family=mpi
fi
location_of_module=$(readlink -m ${MODULE_DIR}/${family}/${MPI_COMPILER}/${MPI_COMPILER_VERSION}/${COMPILER}/${COMPILER_VERSION}/${PKG})
name_of_module=${location_of_module}/${PKG_VERSION}.lua

# Create Module File
mkdir -p ${location_of_module}
cat << EOF > ${name_of_module}
help([[ ${PKG} version ${PKG_VERSION} ]])
family("boost")
-- Conflicts
-- Dependencies
prereq("${COMPILER}/${COMPILER_VERSION}")
EOF

if [ ! -z "${MPI_COMPILER}" ]; then
cat << EOF >> ${name_of_module}
prereq("${MPI_COMPILER}/${MPI_COMPILER_VERSION}")
EOF
fi

cat << EOF >> ${name_of_module}
-- Modulepath for packages built with this library
-- Environment Paths
prepend_path("CPATH", "${LIB_INSTALL_DIR}/include")
prepend_path("LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib")
prepend_path("LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib64")
prepend_path("LD_LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib")
prepend_path("LD_LIBRARY_PATH", "${LIB_INSTALL_DIR}/lib64")
-- Environment Variables
setenv("BOOST_ROOT", "${LIB_INSTALL_DIR}")
EOF
71 changes: 71 additions & 0 deletions src/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash -l
#
# =========================================
#
# Script is always called as:
# > build.sh <package> <package_version> <compiler> <compiler_version> <mpi> <mpi_version>
#
# Constructs a log file name which looks like:
# ${LOG_DIR}/<package>_<package_version>_<compiler>_<compiler_version>_<mpi>_<mpi_version>.log
#
# Calls the package script as
# ${SRC_DIR}/<package>.sh <package_version> <compiler> <compiler_version> <mpi> <mpi_version>
#
# =========================================

# Abort if any command returns an error
set -e

# Record what we're doing
set -x

# Set the package name and version
export PKG=$1
export PKG_VERSION=$2

# Get Compiler and version
export COMPILER=$3
export COMPILER_VERSION=$4

# Get MPI and version
export MPI=$5
export MPI_VERSION=$6

# Create log directory if not exist
mkdir -p ${LOG_DIR}

# Construct a log file name
logfile=${LOG_DIR}/${PKG}
if [ -n "${PKG_VERSION}" ]; then
logfile="${logfile}_${PKG_VERSION}"
fi
if [ -n "${COMPILER}" ]; then
logfile="${logfile}_${COMPILER}"
fi
if [ -n "${COMPILER_VERSION}" ]; then
logfile="${logfile}_${COMPILER_VERSION}"
fi
if [ -n "${MPI}" ]; then
logfile="${logfile}_${MPI}"
fi
if [ -n "${MPI_VERSION}" ]; then
logfile="${logfile}_${MPI_VERSION}"
fi
logfile="${logfile}.log"

# Start a shell block with redirected IO to log file
{

# Make sure the stacksize is something reasonable
ulimit -s 8192

# Create the log directory if necessary
mkdir -p ${LOG_DIR}

echo "Building ${PKG}-${PKG_VERSION}"

eval ${SRC_DIR}/${PKG}.sh ${PKG_VERSION} ${COMPILER} ${COMPILER_VERSION} ${MPI} ${MPI_VERSION}

} 2>&1 | tee ${logfile} # End of shell block with redirected IO

exit "${PIPESTATUS[0]}"
Loading

0 comments on commit cbf1169

Please sign in to comment.