Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: TiledArray CI

on: [push]

env:
CMAKE_BUILD_PARALLEL_LEVEL : 2

jobs:

MacOS-Build:

strategy:
fail-fast: false
matrix:
os : [ macos-latest ]
cxx : [ clang++, /usr/local/bin/g++-10 ]
build_type : [ Release, Debug ]
prerequisites : [ gcc@10 boost eigen open-mpi ]

name: "${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
runs-on: ${{ matrix.os }}
env:
CXX : ${{ matrix.cxx }}
BUILD_CONFIG : >
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DTA_BUILD_UNITTEST=ON
-DMPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'

steps:
- uses: actions/checkout@v2

- name: Host system info
shell: bash
run: cmake -P ${{github.workspace}}/ci/host_system_info.cmake

- name: Install ${{matrix.prerequisites}}
run: brew install ${{matrix.prerequisites}}

- name: "Configure build: ${{ env.BUILD_CONFIG }}"
shell: bash
run: |
set -x;
cmake -B${{github.workspace}}/build $BUILD_CONFIG

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake --build . --target tiledarray
cmake --build . --target examples

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
#run: ctest -C $${{matrix.build_type}}
run: |
source ${{github.workspace}}/ci/openmpi.env
cmake --build . --target ta_test
cmake --build . --target check
54 changes: 23 additions & 31 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,21 @@ default:

variables:
MAD_NUM_THREADS : 2
TA_CI_TARGETS : "tiledarray examples ta_test check"
TA_CI_CONFIG : >
TA_BUILD_UNITTEST=TRUE
CMAKE_BUILD_TYPE=${BUILD_TYPE}
${TA_PYTHON}
${ENABLE_CUDA}
${BLA_VENDOR}
${ENABLE_SCALAPACK}
TA_TARGETS : "tiledarray examples ta_test check"
TA_CONFIG : >
TA_BUILD_UNITTEST=TRUE
CMAKE_BUILD_TYPE=${BUILD_TYPE}
${TA_PYTHON}
${ENABLE_CUDA}
${BLA_VENDOR}
${ENABLE_SCALAPACK}

before_script:
- echo 'localhost slots=2' > /etc/openmpi/openmpi-default-hostfile
# NB: below tag parsing is not robust
- echo "CI_RUNNER_TAGS=$CI_RUNNER_TAGS"
# NB: tag parsing below is not robust
- CMAKE_BUILD_PARALLEL_LEVEL=$(echo $CI_RUNNER_TAGS | sed -n 's/CMAKE_BUILD_PARALLEL_LEVEL=\([0-9]\+\).*/\1/p')
- export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:=1}
- echo "CMAKE_BUILD_PARALLEL_LEVEL=$CMAKE_BUILD_PARALLEL_LEVEL"
- |-
if [[ "$BLA_VENDOR" == "BLA_VENDOR=Intel10"* ]]; then
# apt-get install -yq intel-mkl-core-c-2020.4-304
# source /opt/intel/compilers_and_libraries_2020.4.304/linux/mkl/bin/mklvars.sh intel64
make -C /home/ValeevGroup install/intel-mkl
source /opt/intel/mkl/bin/mklvars.sh intel64
echo "MKLROOT=$MKLROOT"
fi
- |-
if [[ "$ENABLE_CUDA" == "ENABLE_CUDA=ON" ]]; then
make -C /home/ValeevGroup install/cuda
export CUDACXX=/usr/local/cuda/bin/nvcc
fi

ubuntu:
stage: build
Expand All @@ -46,17 +32,23 @@ ubuntu:
TA_PYTHON : "TA_PYTHON=ON"
ENABLE_SCALAPACK : "ENABLE_SCALAPACK=OFF"
script:
- mkdir build
- cd build
# !!! Unset env vars that may conflict with build, eg FindBLAS uses $ENV{BLA_VENDOR}
- unset BUILD_TYPE TA_PYTHON BLA_VENDOR ENABLE_SCALAPACK ENABLE_CUDA
- ../bin/gitlab-ci.sh ..
${TA_CI_TARGETS}
${TA_CI_CONFIG}
- ./ci/.build-project
--build ./build
--metrics ./build/metrics.txt
${TA_CONFIG}
${TA_TARGETS}
MPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'
blacs_LIBRARIES=scalapack-openmpi
scalapack_LIBRARIES=scalapack-openmpi
#lapack_LIBRARIES=lapack
artifacts:
paths:
- build/metrics.txt
- build/CMakeCache.txt
- build/CMakeFiles/CMakeOutput.log
- build/CMakeFiles/CMakeError.log
reports:
metrics: build/metrics.txt
parallel:
matrix:
- IMAGE : [ "ubuntu:18.04", "ubuntu:20.04" ]
Expand All @@ -73,4 +65,4 @@ ubuntu:
CXX: [ g++ ]
BUILD_TYPE : [ "Release", "Debug" ]
ENABLE_CUDA : [ "ENABLE_CUDA=ON" ]
TA_CI_TARGETS : [ "tiledarray examples" ]
TA_TARGETS : [ "tiledarray examples" ]
41 changes: 0 additions & 41 deletions bin/gitlab-ci.sh

This file was deleted.

97 changes: 97 additions & 0 deletions ci/.build-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash

set -e

build_dir=""
metrics=""

var=" "
targets=" "

while [ $# -gt 0 ]; do
case $1 in
--build) shift; build_dir=$1 ;;
--metrics) shift; metrics=$1 ;;
-*) echo "Invalid option $arg"; exit 1 ;;
CXX=*) eval "export $1" ;;
*=*) vars+="\"-D$1\" "
# NB unset vars from s.t. CMake doesn't see env vars, eg BLA_VENDOR
unset $(echo "$1" | cut -d= -f1)
;;
*) targets+="$1 ";;
esac
shift
done

if [ -z "$build_dir" ]; then
echo "--build <build-dir> is required"
exit 1
fi

xtime="/usr/bin/time"

if [ -n "$metrics" ]; then
#sudo apt install time
if [ ! -x $xtime ]; then
echo >&2 "${xtime} is not executable, metrics disabled"
metrics=""
fi
rm -f "${metrics}"
fi

function time_cmd {
step=$1; shift
cmd="$@"
echo "+ $cmd"
if [ -n "$metrics" ]; then
format="'${step}.memory %Mk\n${step}.time %E\n'"
cmd="${xtime} -f ${format} -a -o $metrics $cmd"
#echo "$cmd"
fi
eval "$cmd"
}

function cmd {
echo "+ $@"
eval "$@"
}

# NB Gitlab section: https://docs.gitlab.com/ee/ci/jobs/#custom-collapsible-sections
function section_start {
echo -e "section_start:`date +%s`:$1\r\e[0K$2"
}

function section_end {
echo -e "section_end:`date +%s`:$1\r\e[0K"
}

echo ""
section_start "host_system_info[collapsed=true]" "Host system info"
cmd "cmake -P ci/host_system_info.cmake"
section_end host_system_info

section_start "preparing_system_section[collapsed=true]" "Preparing system"
cmd "source ci/openmpi.env"
cmd "echo 'localhost slots=2' > /etc/openmpi/openmpi-default-hostfile"
if [[ "$vars" =~ \"-DBLA_VENDOR=Intel ]]; then
cmd "make -C /home/ValeevGroup install/intel-mkl"
cmd "source /opt/intel/mkl/bin/mklvars.sh intel64"
cmd "echo MKLROOT=\$MKLROOT"
fi
if [[ "$vars" =~ \"-D([a-zA-Z]+_)?ENABLE_CUDA=(ON|TRUE|1|YES)\" ]]; then
cmd "make -C /home/ValeevGroup install/cuda"
cmd "export CUDACXX=/usr/local/cuda/bin/nvcc"
fi
section_end preparing_system_section

section_start configure_section "Configure"
cmd mkdir -p ${build_dir}
time_cmd configure "cmake -B${build_dir} $vars"
section_end configure_section

for target in ${targets}; do
section_start build_${target}_section "Build ${target}"
time_cmd ${target} "cmake --build ${build_dir} --target ${target}"
section_end build_${target}_section
done

14 changes: 14 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
To run CI in docker use `docker-run-ci` and give build parameters, eg:

```
$ ./ci/docker-run-ci TA_PYTHON=OFF ENABLE_CUDA=ON all check
Removing previous build container: andrey.tiledarray.build

Running new build of /home/andrey/github/tiledarray on andrey.tiledarray.build
* Use CTRL-p CTRL-q to dettach
* To reattach use: docker start -a -i andrey.tiledarray.build
...
```

This builds targets `all check` on current Git branch in a docker container named `${USER}.$(basename $PWD).build`

39 changes: 39 additions & 0 deletions ci/docker-run-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# build project via docker run, eg
# usage: docker-run-ci <build-dir> [ VAR=VALUE ... ] [ target ... ]
# example: ./ci/docker-run-ci ./build-dir MPQC_BUILD_DEPENDENCIES_FROM_SOURCE=OFF ENABLE_CUDA=ON all check

project=$(basename $PWD)
image=valeevgroup/ubuntu
name=$USER.${project}.build
project_source_dir=$PWD

script="cd /builds/ValeevGroup/${project}

echo '# git checkout .'
git checkout .
echo

echo '# git log -1'
git log -1
echo

./ci/.build-project --build ./build --metrics ./build/metrics.txt $@;

bash
"

echo -n "Removing previous build container: "
docker rm -f ${name}

echo "
Running new build of ${project_source_dir} on ${name}
* Use CTRL-p CTRL-q to dettach
* To reattach use: docker start -a -i ${name}
"
#sleep 1

docker run --name ${name} -ti \
-v ${project_source_dir}/.git:/builds/ValeevGroup/${project}/.git \
${image} bash -c "$script"
22 changes: 22 additions & 0 deletions ci/host_system_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(
keys

OS_NAME
OS_RELEASE
OS_VERSION
OS_PLATFORM


PROCESSOR_DESCRIPTION
NUMBER_OF_PHYSICAL_CORES

TOTAL_VIRTUAL_MEMORY
AVAILABLE_VIRTUAL_MEMORY
TOTAL_PHYSICAL_MEMORY
AVAILABLE_PHYSICAL_MEMORY
)

foreach (key ${keys})
cmake_host_system_information(RESULT result QUERY ${key})
message(STATUS "${key}: ${result}")
endforeach()
5 changes: 5 additions & 0 deletions ci/openmpi.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# to run OpenMPI in docker as root
export OMPI_ALLOW_RUN_AS_ROOT=1
export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
export OMPI_MCA_btl_vader_single_copy_mechanism="none"