Skip to content

Commit

Permalink
add cscs-ci ext (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpintarelli committed Feb 23, 2024
1 parent 85331eb commit cde8084
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.DS_Store*
*.swp
__pycache__
build*
exports
doc
.idea*
Expand Down
63 changes: 63 additions & 0 deletions ci/baseimage.cuda.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:22.04 as builder

ARG CUDA_ARCH=60

ENV DEBIAN_FRONTEND noninteractive

ENV FORCE_UNSAFE_CONFIGURE 1

ENV PATH="/spack/bin:${PATH}"

ENV MPICH_VERSION=3.4.3

ENV CMAKE_VERSION=3.27.9

RUN apt-get -y update

RUN apt-get install -y apt-utils

# install basic tools
RUN apt-get install -y --no-install-recommends gcc g++ gfortran clang libomp-14-dev git make unzip file \
vim wget pkg-config python3-pip python3-dev cython3 python3-pythran curl tcl m4 cpio automake meson \
xz-utils patch patchelf apt-transport-https ca-certificates gnupg software-properties-common perl tar bzip2 \
liblzma-dev libbz2-dev

# install CMake
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz -O cmake.tar.gz && \
tar zxvf cmake.tar.gz --strip-components=1 -C /usr

# get latest version of spack
RUN git clone -b v0.21.0 https://github.com/spack/spack.git

# set the location of packages built by spack
RUN spack config add config:install_tree:root:/opt/local
# set cuda_arch for all packages
RUN spack config add packages:all:variants:cuda_arch=${CUDA_ARCH}

# find all external packages
RUN spack external find --all --exclude python

# find compilers
RUN spack compiler find

# install yq (utility to manipulate the yaml files)
RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_386 && chmod a+x /usr/local/bin/yq

# change the fortran compilers: for gcc the gfortran is already properly set and the change has no effect; add it for clang
RUN yq -i '.compilers[0].compiler.paths.f77 = "/usr/bin/gfortran"' /root/.spack/linux/compilers.yaml && \
yq -i '.compilers[0].compiler.paths.fc = "/usr/bin/gfortran"' /root/.spack/linux/compilers.yaml && \
yq -i '.compilers[1].compiler.paths.f77 = "/usr/bin/gfortran"' /root/.spack/linux/compilers.yaml && \
yq -i '.compilers[1].compiler.paths.fc = "/usr/bin/gfortran"' /root/.spack/linux/compilers.yaml

# install MPICH
RUN spack install mpich@${MPICH_VERSION} %gcc

# for the MPI hook
RUN echo $(spack find --format='{prefix.lib}' mpich) > /etc/ld.so.conf.d/mpich.conf
RUN ldconfig

# create environments for several configurations and install dependencies
RUN spack env create -d /tiledmm-env-cuda && \
spack -e /tiledmm-env-cuda add "tiled-mm@master %gcc +cuda +tests +shared " && \
spack -e /tiledmm-env-cuda develop -p /src tiled-mm@master && \
spack -e /tiledmm-env-cuda install --only=dependencies --fail-fast
17 changes: 17 additions & 0 deletions ci/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE

ARG ENVPATH

# copy source files of the pull request into container
COPY . /src

# build tiled-mm
RUN spack -e $ENVPATH install

# # show the spack's spec
RUN spack -e $ENVPATH find -lcdv

# we need a fixed name for the build directory
# here is a hacky workaround to link ./spack-build-{hash} to ./spack-build
RUN cd /src && ln -s $(spack -e $ENVPATH location -b tiled-mm) spack-build
58 changes: 58 additions & 0 deletions ci/cscs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
include:
- remote: 'https://gitlab.com/cscs-ci/recipes/-/raw/master/templates/v2/.ci-ext.yml'

stages:
- baseimage
- build
- test

build base image:
extends: .container-builder-dynamic-name
stage: baseimage
timeout: 2h
variables:
DOCKERFILE: ci/baseimage.cuda.Dockerfile
WATCH_FILECHANGES: ci/baseimage.cuda.Dockerfile
PERSIST_IMAGE_NAME: $CSCS_REGISTRY_PATH/base/tiledmm-ci

build tiled-mm:
extends: .container-builder
needs: ["build base image"]
stage: build
variables:
DOCKERFILE: ci/build.Dockerfile
PERSIST_IMAGE_NAME: $CSCS_REGISTRY_PATH/tiledmm/tiledmm-ci:$CI_COMMIT_SHA
ENVPATH: "/tiledmm-env-cuda"
DOCKER_BUILD_ARGS: '["BASE_IMAGE=${BASE_IMAGE}", "ENVPATH=$ENVPATH"]'

.run_tests:
extends: .container-runner-daint-gpu
needs: ["build tiled-mm"]
stage: test
image: $CSCS_REGISTRY_PATH/tiledmm/tiledmm-ci:$CI_COMMIT_SHA
variables:
GIT_STRATEGY: none
MPICH_MAX_THREAD_SAFETY: multiple
CSCS_REGISTRY_LOGIN: 'YES'
PULL_IMAGE: 'YES'
SLURM_HINT: nomultithread
SLURM_UNBUFFEREDIO: ''
SLURM_WAIT: 0

test1:
extends: .run_tests
stage: test
script: /src/spack-build/tests/test-multiply -m 50 -n 200 -k 21 --tile_m 4 --tile_n 4 --tile_k 4 --beta 0 --n_streams 2
variables:
SLURM_JOB_NUM_NODES: 1
SLURM_NTASKS: 1
USE_MPI: 'YES'

test2:
extends: .run_tests
stage: test
script: /src/spack-build/tests/test-multiply -m 5 -n 2 -k 2 --tile_m 4 --tile_n 4 --tile_k 4 --beta 0 --n_streams 2
variables:
SLURM_JOB_NUM_NODES: 1
SLURM_NTASKS: 1
USE_MPI: 'YES'

0 comments on commit cde8084

Please sign in to comment.