Skip to content

Commit

Permalink
[actions] in .github/workflows, first complete basic prototype of reu…
Browse files Browse the repository at this point in the history
…sable workflows (add testsuite_allprocesses.yml orchestrating a matrix of testsuite_oneprocess tests)

** NB: runTest.exe sometimes fails (core dump, illegal instruction), this must be debugged
  • Loading branch information
valassi committed Nov 4, 2023
1 parent 5d6fa4b commit 3eec519
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 79 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/testsuite_allprocesses.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2020-2023 CERN and UCLouvain.
# Licensed under the GNU Lesser General Public License (version 3 or later).
# Created by: A. Valassi (Nov 2023) for the MG5aMC CUDACPP plugin.
# Further modified by: A. Valassi (2023) for the MG5aMC CUDACPP plugin.

name: Test suite for all processes

#----------------------------------------------------------------------------------------------------------------------------------

on:

push:
paths:
- '.github/workflows/testsuite*'

#----------------------------------------------------------------------------------------------------------------------------------

jobs:

# See https://stackoverflow.com/a/75337311
process-matrix:
strategy:
fail-fast: false # important to see all results even if one fails (fail-fast is true by default)
matrix:
process: [gg_tt.mad, gg_ttg.mad]
uses: ./.github/workflows/testsuite_oneprocess.yml
with:
process: ${{ matrix.process }}

#----------------------------------------------------------------------------------------------------------------------------------
162 changes: 111 additions & 51 deletions .github/workflows/testsuite_oneprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,32 @@ topdir=$(cd $(dirname $0)/../..; pwd)

# Code generation stage
function codegen() {
if [ "$1" == "" ] || [ "$2" != "" ]; then echo "Usage: $(basename $0) <process>"; exit 1; fi
proc=$1
if [ "${proc%.mad}" == "${proc}" ] && [ "${proc%.sa}" == "${proc}" ]; then echo "Usage: $(basename $0) <process.mad|process.sa>"; exit 1; fi
# Generate code and check clang formatting
cd ${topdir}/epochX/cudacpp
echo "Current directory is $(pwd)"
###processes="$(git ls-tree --name-only HEAD *.mad *.sa)"
processes="gg_tt.mad" # FOR QUICK TESTS
for proc in $processes; do
echo
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "Code generation for ${proc}"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
if [ "${proc%.mad}" != "${proc}" ]; then
# Generate code and check clang formatting
./CODEGEN/generateAndCompare.sh -q ${proc%.mad} --mad
elif [ "${proc%.sa}" != "${proc}" ]; then
# Generate code and check clang formatting
./CODEGEN/generateAndCompare.sh -q ${proc%.sa}
else
echo "WARNING! SKIP process directory '${proc}' because it does not end in .mad or .sa"
fi
# Check if there are any differences to the current repo
git checkout HEAD ${proc}/CODEGEN*.txt
if [ "${proc%.mad}" != "${proc}" ]; then
git checkout HEAD ${proc}/Cards/me5_configuration.txt
###sed -i 's/DEFAULT_F2PY_COMPILER=f2py.*/DEFAULT_F2PY_COMPILER=f2py3/' ${proc}/Source/make_opts
git checkout HEAD ${proc}/Source/make_opts
fi
echo
echo "git diff (start)"
git diff --exit-code
echo "git diff (end)"
done
echo
echo "*******************************************************************************"
echo "*** code generation for ${proc}"
echo "*******************************************************************************"
if [ "${proc%.mad}" != "${proc}" ]; then
./CODEGEN/generateAndCompare.sh -q ${proc%.mad} --mad
else
./CODEGEN/generateAndCompare.sh -q ${proc%.sa}
fi
# Check if there are any differences to the current repo
git checkout HEAD ${proc}/CODEGEN*.txt
if [ "${proc%.mad}" != "${proc}" ]; then
git checkout HEAD ${proc}/Cards/me5_configuration.txt
###sed -i 's/DEFAULT_F2PY_COMPILER=f2py.*/DEFAULT_F2PY_COMPILER=f2py3/' ${proc}/Source/make_opts
git checkout HEAD ${proc}/Source/make_opts
fi
echo
echo "git diff (start)"
git diff --exit-code
echo "git diff (end)"
}

#----------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -61,7 +57,8 @@ function setup_ccache {

#----------------------------------------------------------------------------------------------------------------------------------

function tput_ini() {
# Before-build stage (analyse data retrieved from cache, download ccache executable and googletest if not retrieved from cache)
function before_build() {
# Install and configure ccache
if [ -d ${topdir}/DOWNLOADS ]; then
echo "Directory ${topdir}/DOWNLOADS already exists (retrieved from cache)"
Expand Down Expand Up @@ -115,26 +112,44 @@ function tput_ini() {

#----------------------------------------------------------------------------------------------------------------------------------

# Tput test stage (build, runTest.exe, check.exe, gcheck.exe)
function tput_run() {
cd ${topdir}/epochX/cudacpp
echo "Current directory is $(pwd)"
# Set up ccache environment
# Build stage
function build() {
if [ "$1" == "" ] || [ "$2" != "" ]; then echo "Usage: $(basename $0) <process>"; exit 1; fi
proc=$1
if [ "${proc%.mad}" == "${proc}" ] && [ "${proc%.sa}" == "${proc}" ]; then echo "Usage: $(basename $0) <process.mad|process.sa>"; exit 1; fi
# Set up build environment
setup_ccache
# Dump g++ environment
echo
echo "g++ --version"
g++ --version
# Build and test
export CXX=g++ # set up CXX that is needed by cudacpp.mk
export USECCACHE=1 # enable ccache in madgraph4gpu builds
echo "./tput/teeThroughputX.sh -makej -ggtt -makeclean"
./tput/teeThroughputX.sh -makej -ggtt -makeclean
export CXX=g++ # set up CXX that is needed by cudacpp.mk
###echo; echo "$CXX --version"; $CXX --version
export USEBUILDDIR=1
# Iterate over P* directories and build
cd ${topdir}/epochX/cudacpp/${proc}
echo "Current directory is $(pwd)"
gtestlibs=0
pdirs="$(ls -d SubProcesses/P*_*)"
for pdir in ${pdirs}; do
pushd $pdir >& /dev/null
echo
echo "*******************************************************************************"
echo "*** build ${proc} ($(basename $(pwd)))"
echo "*******************************************************************************"
echo
echo "Building in $(pwd)"
if [ "${gtestlibs}" == "0" ]; then
# Build googletest once and for all to avoid issues in parallel builds
gtestlibs=1
make -f cudacpp.mk gtestlibs
fi
make -j avxall
popd >& /dev/null
done
}

#----------------------------------------------------------------------------------------------------------------------------------

function tput_fin() {
# After-build stage (analyse data to be saved in updated cache)
function after_build() {
# Set up ccache environment
setup_ccache
# Dump ccache status after the builds
Expand All @@ -150,45 +165,90 @@ function tput_fin() {
echo "ls ${topdir}/test/googletest (start)"
ls ${topdir}/test/googletest
echo "ls ${topdir}/test/googletest (end)"
# Check contents of build directories
echo
echo "ls -d ${topdir}/epochX/cudacpp/*.*/SubProcesses/P*_*/build* (start)"
ls -d ${topdir}/epochX/cudacpp/*.*/SubProcesses/P*_*/build*
echo "ls -d ${topdir}/epochX/cudacpp/*.*/SubProcesses/P*_*/build* (end)"
}

#----------------------------------------------------------------------------------------------------------------------------------

function runExe() {
echo
echo "Execute $*"
if [ -f $1 ]; then $*; else echo "(SKIP missing $1)"; fi
}

# Tput-test stage (runTest.exe, check.exe, gcheck.exe)
function tput_test() {
if [ "$1" == "" ] || [ "$2" != "" ]; then echo "Usage: $(basename $0) <process>"; exit 1; fi
proc=$1
if [ "${proc%.mad}" == "${proc}" ] && [ "${proc%.sa}" == "${proc}" ]; then echo "Usage: $(basename $0) <process.mad|process.sa>"; exit 1; fi
# Iterate over P* directories and run tests
cd ${topdir}/epochX/cudacpp/${proc}
echo "Current directory is $(pwd)"
pdirs="$(ls -d SubProcesses/P*_*)"
for pdir in ${pdirs}; do
pushd $pdir >& /dev/null
echo
echo "*******************************************************************************"
echo "*** tput-test ${proc} ($(basename $(pwd)))"
echo "*******************************************************************************"
echo
echo "Testing in $(pwd)"
# FIXME1: this is just a quick test, eventually port here tput tests from throughputX.sh
# (could move some throughputX.sh functions to a separate script included both here and there)
# FIXME2: properly iterate over all simd modes
# FIXME3: enable FPEs
# FIXME4: handle all d/f/m, inl0/1, hrd0/1 etc...
bdirs="$(ls -d build.*)"
for bdir in ${bdirs}; do
runExe ${bdir}/runTest.exe
runExe ${bdir}/check.exe -p 1 32 1
runExe ${bdir}/gcheck.exe -p 1 32 1
done
popd >& /dev/null
done
}

#----------------------------------------------------------------------------------------------------------------------------------

# Usage
function usage() {
echo "Usage: $(basename $0) <${stages// /|}>"
echo "Usage: $(basename $0) <${stages// /|}> <proc.sa|proc.mad>"
exit 1
}

#----------------------------------------------------------------------------------------------------------------------------------

# Valid stages
stages="codegen tput_ini tput_run tput_fin"
stages="codegen before_build build after_build tput_test"

# Check input arguments
for astage in $stages; do
if [ "$1" == "$astage" ]; then
stage=$1; shift; break
stage=$1; proc=$2; shift; shift; break
fi
done
if [ "$stage" == "" ] || [ "$1" != "" ]; then usage; fi
if [ "$stage" == "" ] || [ "$proc" == "" ] || [ "$1" != "" ]; then usage; fi

# Start
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "[testsuite_oneprocess.sh] $stage starting at $(date)"
echo "[testsuite_oneprocess.sh] $stage ($proc) starting at $(date)"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

# Execute stage
( set -e; $stage ) # execute this within a subprocess and fail immediately on error
( set -e; $stage $proc) # execute this within a subprocess and fail immediately on error
status=$?

# Finish
echo
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
if [ $status -eq 0 ]; then
echo "[testsuite_oneprocess.sh] $stage finished with status=$status (OK) at $(date)"
echo "[testsuite_oneprocess.sh] $stage ($proc) finished with status=$status (OK) at $(date)"
else
echo "[testsuite_oneprocess.sh] $stage finished with status=$status (NOT OK) at $(date)"
echo "[testsuite_oneprocess.sh] $stage ($proc) finished with status=$status (NOT OK) at $(date)"
fi
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
exit $status
62 changes: 34 additions & 28 deletions .github/workflows/testsuite_oneprocess.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ name: Test suite for one process
#----------------------------------------------------------------------------------------------------------------------------------

on:

push:
paths:
- '.github/workflows/testsuite_oneprocess.*'

workflow_dispatch:
#inputs:
# name:
# description: 'Person to greet'
# default: 'World'
# required: true
# type: string
# See https://stackoverflow.com/a/75337311
workflow_call:
inputs:
process: # this variable is provided by the matrix in testsuite_allprocesses.yml
required: true
type: string

#FIXME: add ALSO the possibility of running only one process on request...

# From the default github manual workflow example
#workflow_dispatch:
# inputs:
# process:
# description: 'Physics process'
# default: 'gg_tt.mad'
# required: true
# type: string

#----------------------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -66,7 +71,7 @@ jobs:

- name: WELCOME
run: |
echo "WELCOME! $(date)"
echo "WELCOME ${{ inputs.process }}! $(date)"
echo "Current directory is $(pwd)"
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)"
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
Expand All @@ -88,23 +93,23 @@ jobs:
CCACHE_DIR
DOWNLOADS
test/googletest
key: cache-${{ runner.os }}-${{ github.run_id }}
key: cache-${{ runner.os }}-${{ inputs.process }}-${{ github.run_id }}
restore-keys:
cache-${{ runner.os }}
cache-${{ runner.os }}-${{ inputs.process }}

- name: codegen
run: .github/workflows/testsuite_oneprocess.sh codegen
run: .github/workflows/testsuite_oneprocess.sh codegen ${{ inputs.process }}

- name: tput_ini
run: .github/workflows/testsuite_oneprocess.sh tput_ini
- name: before_build
run: .github/workflows/testsuite_oneprocess.sh before_build ${{ inputs.process }}

- name: tput_run
run: .github/workflows/testsuite_oneprocess.sh tput_run
- name: build
run: .github/workflows/testsuite_oneprocess.sh build ${{ inputs.process }}

- name: tput_fin
run: .github/workflows/testsuite_oneprocess.sh tput_fin
- name: after_build
run: .github/workflows/testsuite_oneprocess.sh after_build ${{ inputs.process }}

- name: update_cache
- name: update_cache # update caches after the builds but before the tests (which may fail even if builds succeed)
id: cache-update
# See https://github.com/actions/cache
uses: actions/cache/save@v3
Expand All @@ -113,21 +118,22 @@ jobs:
CCACHE_DIR
DOWNLOADS
test/googletest
key: cache-${{ runner.os }}-${{ github.run_id }}
key: cache-${{ runner.os }}-${{ inputs.process }}-${{ github.run_id }}

- name: tput_test
run: .github/workflows/testsuite_oneprocess.sh tput_test ${{ inputs.process }}

- name: GOODBYE
run: |
echo "GOODBYE! $(date)"
echo "GOODBYE ${{ inputs.process }}! $(date)"
echo "Current directory is $(pwd)"
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)"
REPO=${{ github.repository }}
echo "List cache keys (start)"
# FIXME list only cache for ${{ inputs.process }}
gh actions-cache list -R $REPO --sort created-at --order asc
echo "List cache keys (end)"
env:
GH_TOKEN: ${{ github.token }}

#- name: Send greeting
# run: echo "Hello ${{ inputs.name }}"

#----------------------------------------------------------------------------------------------------------------------------------

0 comments on commit 3eec519

Please sign in to comment.