Skip to content

Commit

Permalink
ci: sync; rename examples; update make test
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Aug 8, 2023
1 parent 532f5bc commit 488a18d
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 71 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ mydir=$(dirname $0)
source ${mydir}/setup_env.sh

print "======================================== Environment"
env
# Show environment variables, excluding functions.
(set -o posix; set)

print "======================================== Modules"
quiet module list -l

print "======================================== Query GPUs"
if [ "${device}" = "gpu_nvidia" ]; then
nvidia-smi
elif [ "${device}" = "gpu_amd" ]; then
rocm-smi
elif [ "${device}" = "gpu_intel" ]; then
clinfo
sycl-ls
fi

print "======================================== Setup build"
# Note: set all env variables in setup_env.sh,
Expand All @@ -23,8 +37,8 @@ if [ "${maker}" = "make" ]; then
make distclean
make config prefix=${top}/install \
|| exit 10
fi
if [ "${maker}" = "cmake" ]; then

elif [ "${maker}" = "cmake" ]; then
( # Build blaspp first
git clone https://github.com/icl-utk-edu/blaspp
mkdir blaspp/build && cd blaspp/build
Expand All @@ -43,5 +57,7 @@ if [ "${maker}" = "cmake" ]; then
|| exit 12
fi

cat include/lapack/defines.h

print "======================================== Finished configure"
exit 0
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
icl_lapackpp:
timeout-minutes: 120
strategy:
matrix:
maker: [make, cmake]
device: [cpu, gpu_nvidia, gpu_amd, gpu_intel]
exclude: # cmake config net yet implemented for gpu_intel
- maker: cmake
device: gpu_intel
fail-fast: false
runs-on: ${{ matrix.device }}
steps:
Expand Down
52 changes: 33 additions & 19 deletions .github/workflows/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export top=$(pwd)

shopt -s expand_aliases


print "======================================== Load compiler"
quiet module load [email protected]
quiet which g++
g++ --version

quiet module load intel-oneapi-mkl
echo "MKLROOT=${MKLROOT}"
print "MKLROOT=${MKLROOT}"

quiet module load python
quiet which python
quiet which python3
python --version
python3 --version

quiet module load pkgconf
quiet which pkg-config
Expand All @@ -59,37 +59,51 @@ else
export blas_int=int32
fi

#----------------------------------------------------------------- Compiler
if [ "${device}" = "gpu_intel" ]; then
print "======================================== Load Intel oneAPI compiler"
quiet module load intel-oneapi-compilers
else
print "======================================== Load GNU compiler"
quiet module load [email protected]
fi
print "---------------------------------------- Verify compiler"
print "CXX = $CXX"
print "CC = $CC"
print "FC = $FC"
${CXX} --version
${CC} --version
${FC} --version

#----------------------------------------------------------------- GPU
if [ "${device}" = "gpu_nvidia" ]; then
print "======================================== Load CUDA"
export CUDA_HOME=/usr/local/cuda/
quiet module load cuda
print "CUDA_HOME=${CUDA_HOME}"
export PATH=${PATH}:${CUDA_HOME}/bin
export gpu_backend=cuda
quiet which nvcc
nvcc --version
fi

if [ "${device}" = "gpu_amd" ]; then
elif [ "${device}" = "gpu_amd" ]; then
print "======================================== Load ROCm"
export PATH=${PATH}:/opt/rocm/bin
export ROCM_PATH=/opt/rocm
# Some hip utilities require /usr/sbin/lsmod
export PATH=${PATH}:${ROCM_PATH}/bin:/usr/sbin
export gpu_backend=hip
quiet which hipcc
hipcc --version
fi

if [ "${device}" = "gpu_intel" ]; then
print "======================================== Load Intel oneAPI"
elif [ "${device}" = "gpu_intel" ]; then
# Intel oneAPI SYCL compiler loaded above
export gpu_backend=sycl
quiet module load intel-oneapi-compilers
quiet which icpx
icpx --version
fi

#----------------------------------------------------------------- CMake
if [ "${maker}" = "cmake" ]; then
print "======================================== Load cmake"
quiet module load cmake
quiet which cmake
cmake --version
cd build
fi

quiet module list
42 changes: 23 additions & 19 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,42 @@ export OMP_NUM_THREADS=8
print "======================================== Tests"
cd test

TESTER="./run_tests.py --quick"
args="--quick"
if [ "${device}" = "gpu_intel" ]; then
TESTER+=" --type s,c"
# Our Intel GPU supports only single precision.
args+=" --type s,c"
fi

${TESTER} --host --xml ${top}/report-${maker}.xml
./run_tests.py ${args} --host
(( err += $? ))

# CUDA or HIP
${TESTER} --device --xml ${top}/report-${maker}-device.xml
# CUDA, HIP, or SYCL. These fail gracefully when GPUs are absent.
./run_tests.py ${args} --device
(( err += $? ))

print "======================================== Smoke tests"
cd ${top}/example

if [ "${maker}" = "make" ]; then
export PKG_CONFIG_PATH=${top}/install/lib/pkgconfig
make clean
fi
if [ "${maker}" = "cmake" ]; then
rm -rf build && mkdir build && cd build
cmake "-DCMAKE_PREFIX_PATH=${top}/install" ..
fi
cd ${top}/examples

# Makefile or CMakeLists.txt picks up ${test_args}.
if [ "${device}" = "gpu_intel" ]; then
TESTS="s c"
# Our Intel GPU supports only single precision.
export test_args="s c"
else
TESTS="s d c z"
export test_args="s d c z"
fi

if [ "${maker}" = "make" ]; then
export PKG_CONFIG_PATH+=:${top}/install/lib/pkgconfig
make clean || exit 20

elif [ "${maker}" = "cmake" ]; then
rm -rf build && mkdir build && cd build
cmake "-DCMAKE_PREFIX_PATH=${top}/install" .. || exit 30
fi

make
./example_potrf ${TESTS}
# ARGS=-V causes CTest to print output. Makefile doesn't use it.
make -j8 || exit 40
make test ARGS=-V
(( err += $? ))

print "======================================== Finished test"
Expand Down
21 changes: 0 additions & 21 deletions example/CMakeLists.txt

This file was deleted.

55 changes: 55 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) 2017-2022, University of Tennessee. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# This program is free software: you can redistribute it and/or modify it under
# the terms of the BSD 3-Clause license. See the accompanying LICENSE file.

# CXX compiler must match the one used to compiler LAPACK++.
# Set it in your environment.

cmake_minimum_required( VERSION 3.8 )

project(
lapackpp_example
LANGUAGES CXX
)

#-------------------------------------------------------------------------------
# Enforce out-of-source build
string( TOLOWER "${CMAKE_CURRENT_SOURCE_DIR}" source_dir )
string( TOLOWER "${CMAKE_CURRENT_BINARY_DIR}" binary_dir )
if ("${source_dir}" STREQUAL "${binary_dir}")
message( FATAL_ERROR
"Compiling with CMake requires an out-of-source build. To proceed:
rm -rf CMakeCache.txt CMakeFiles/ # delete files in ${CMAKE_CURRENT_SOURCE_DIR}
mkdir build
cd build
cmake ..
make" )
endif()

#-------------------------------------------------------------------------------
find_package( lapackpp REQUIRED )

#--------------------
add_executable(
example_potrf
example_potrf.cc
)

target_link_libraries(
example_potrf
lapackpp
)

#-------------------------------------------------------------------------------
# CTest

# Get precisions to test. See .github/workflows/test.sh
set( test_args $ENV{test_args} )
if (NOT test_args)
set( test_args "s d c z" )
endif()
string( REPLACE " " ";" test_args ${test_args} ) # convert to list

enable_testing()
add_test( NAME example_gemm COMMAND ./example_potrf ${test_args} )
20 changes: 17 additions & 3 deletions example/Makefile → examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ endif
# Rules

exe = example_potrf
run = ${addsuffix .run, ${exe}}
txt = ${addsuffix .txt, ${exe}}

.DELETE_ON_ERROR:
.SECONDARY:
.SUFFIXES:
.DEFAULT_GOAL := all
.PRECIOUS: ${txt}

# Serialize everything so that `make test` runs in serial.
.NOTPARALLEL:

all: ${exe}

Expand All @@ -50,11 +55,19 @@ all: ${exe}
clean:
-rm -f ${exe} ${txt} *.o *.d

run: ${txt}
# CMake uses `make test`, GNU autotools uses `make check`; allow both.
test: check
check: ${run}

# Run example, but don't save results; %.run is dummy filename.
%.run: %
@echo "----------------------------------------------------------------------"
./$< ${test_args}

# run examples
# Run example and save result in .txt file.
txt: ${txt}
%.txt: %
./$< > $@
./$< ${test_args} > $@

#-------------------------------------------------------------------------------
# Debugging
Expand All @@ -66,4 +79,5 @@ echo:
@echo "LIBS $(LIBS)"
@echo
@echo "exe $(exe)"
@echo "run $(run)"
@echo "txt $(txt)"
10 changes: 7 additions & 3 deletions example/README.md → examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ in /opt/slate:

b. Hard-code CXXFLAGS and LIBS for LAPACK++ in the Makefile.

Then, to build `example_potrf` using the Makefile, run:
Then, to build and run `example_potrf` using the
Makefile, run:

make
make test

## Option 2: CMake

CMake must know the compiler used to compile LAPACK++. Set CXX to the
compiler, in your environment.

It's best (but not required) to compile out-of-source in a build directory:
Create a build directory:

mkdir build && cd build

Expand All @@ -44,6 +46,8 @@ Otherwise, simply run:

cmake ..

Then, to build `example_potrf` using the resulting Makefile, run:
Then, to build and run `example_potrf` using the
resulting Makefile, run:

make
make test
File renamed without changes.
File renamed without changes.

0 comments on commit 488a18d

Please sign in to comment.