hpcgarage/spatter

CMake Updates to Replace Configure Files

Closed this issue · 2 comments

We had debated updating the configure scripts and simplifying them but Patrick pointed out that it would be best to just update our CMakeLists and minimize the usage of additional scripts. In some sense, this is because the configure scripts have a limited amount of information including 1) debug/release build 2) Spatter backends 3) compiler to use and possibly some related flags 4) the inclusion of additional features like PAPI.

Note that this issue would also address concerns raised in #28.

Requirements:

  • [] Users should call CMake explicitly with Debug/Release flags and this should be documented in the README.
  • [] CMakeLists should check for the possible backends: serial, openmp, and cuda (adding opencl/sycl at a later date)
  • [] CMakeLists should check for one specified compiler: gnu, clang, intel, IBM XL, Cray, NVCC/NVHPC
  • [] PAPI also needs to be added as an option with -DUSE_PAPI

Based on this StackOverflow post (https://stackoverflow.com/a/39671055), I understand one way to do this is as follows:

for backends:

set(spatterBackends SERIAL OPENMP CUDA)

if(NOT backend IN_LIST spatterBackends)
    message(FATAL_ERROR "backend must be one of ${spatterBackends}")
endif()

And for compiler checking:

set(spatterCompilers Cray GNU Intel XL NVIDIA)

if(NOT compiler IN_LIST spatterCompilers)
    message(FATAL_ERROR "compiler must be one of ${compilerBackends}")
endif()

Some examples of how we think users might use the updated CMakeLists.txt:

We note that the user woudl need to specify their build directory name. Here we use the syntax "build_[backend]_[compiler]" just as a way to denote different build types.

To do a debug build with the serial backend and the gnu compiler

cmake -D CMAKE_BUILD_TYPE=Debug -DBACKEND=serial -DCOMPILER=gnu -B build_serial_gnu 

To do a release build with the CUDA backend; note that release build is the default choice when not specified

cmake -DBACKEND=cuda -DCOMPILER=nvcc -B build_cuda_nvcc

To do an MPI build with GNU

cmake -DBACKEND=openmp -DCOMPILER=mpicc -DUSE_MPI=1 -B build_openmp_mpicc

To use PAPI

cmake -DCMAKE_BUILD_TYPE=Debug -DBACKEND=CUDA -DCOMPILER=NVCC -DUSE_PAPI=1 -B build_cuda_papi

To do a release build with the CUDA backend; note that release build is the default choice when not specified

cmake -DBACKEND=cuda -DCOMPILER=nvcc -B build_cuda_nvcc

Note that the default choice build type is actually Debug when using syntax -B build_[backend]_[compiler] .
For default build type to be Release, please use syntax -B build_[backend]_[compiler] -S .