Skip to content

Makefile

Nolan Baker edited this page Apr 4, 2022 · 6 revisions

Makefile

We have created a Makefile to compile and run our tests. Here is how it works.

USE

make CC=ccompiler CXX=cppcompiler FC=fortrancompiler [OPTIONS] [RULE]

If no CC and CXX compilers are specified, gcc will be used by default, as this compiler is widely available in most of the systems. However, this assumes that gcc has openMP and offloading support.

OPTIONS

Option Explanation
VERBOSE=1 Enables output of the commands that the make process executes
VERBOSE_TESTS=1 Enables extra information display in the tests
LOG=1 Enables dump of the make process output into logs.txt
LOG_ALL=1 Enables dump of the make process output, errors, and binary execution outputs into logs.txt
SYSTEM=sys_name Includes the definitions for the requires modules and batch schedulers in the different systems. This definitions must be in sys/SYSTEM.def. (Do not include the .def extension)
DEVICE_TYPE=dev_name Specifies device type being used, either nvidia or amd, to change compiler flags as needed
MODULE_LOAD=1 Before compiling or running, module load is called
NO_OFFLOADING=1 Turn off offloading
SOURCES=file.(c,cpp,F90) Specify the source file(s) that you want to apply the rule to. rule could be compile, run or all. Wildcards can be use to select many

MAKE RULES

The different make rules allows to select what operation you want to perform. Run, compile the code, or compile results in different formats.

Option Explanation
all Build and run SOURCES file(s). If none is specified build and run all the OpenMP test files
run run tests previously built. Filter by using the SOURCE variable list, or all the OpenMP tests that are available within bin/ directory
compile Compile the specific SOURCES file(s). If none is specified compile all the OpenMP test files
clean Remove all executables from bin/ directory
compilers Shows available compiler configuration

EXAMPLES

Command What it does
make CC=gcc CXX=g++ FC=gfortran all ==> compile and run all test cases with GCC
make CC=gcc SOURCES=a.c all ==> compile and run a.c with gcc
make CXX=g++ SOURCES=tests/target/* all ==> compile and run all tests/target/* tests with def compilers
make CC=xlc CXX=xlc++ FC=xlf compile ==> compile all test cases with XL
make run ==> run all the cases that exist inside bin/
make SOURCES=myTestSource run ==> run myTestSource if it was previously compiled
make CC=gcc SYSTEM=summit DEVICE_TYPE=nvidia SOURCES=tests/offloading_success.c VERBOSE=1 VERBOSE_TESTS=1 ADD_BATCH_SCHED=1 MODULE_LOAD=1 all ==> includes the sys/summit.def file which contains the modules and batch scheduler. Runs with offloading using Nvidia GPU. Compiles and run tests/offloading_success.c. Verbose make output and verbose tests. Adds modules and batck scheduler

Running it all

This is an example on how to run all the tests with all the compilers at once. This example is for summitdev, and you will need to change the values of the Ccomp, CPPcomp arrays (they must match), as well as the value of SYSTEM= to match the one under sys/SYSTEM.def

Ccomp=(clang xlc gcc); CPPcomp=(clang++ xlc++ g++);\
for (( i=0; i<${#Ccomp[@]}; i++)); \
  do make clean; make CC=${Ccomp[$i]} CXX=${CPPcomp[$i]} \
       SYSTEM=summitdev VERBOSE=1 LOG=1 LOG_ALL=1\
       ADD_BATCH_SCHED=1 VERBOSE_TESTS=1 MODULE_LOAD=1 all;\
done;

Here is for summit:

Ccomp=(clang xlc); CPPcomp=(clang++ xlc++);\
for (( i=0; i<${#Ccomp[@]}; i++)); \
  do make clean; make CC=${Ccomp[$i]} CXX=${CPPcomp[$i]} \
       SYSTEM=summit VERBOSE=1 LOG=1 LOG_ALL=1\
       ADD_BATCH_SCHED=1 VERBOSE_TESTS=1 MODULE_LOAD=1 all;\
done;

Here is for titan (MODULE_LOAD is not working as it should right now):

module swap PrgEnv-pgi PrgEnv-cray
module swap cce cce/8.6.5
module load craype-accel-nvidia35
module load cudatoolkit
module swap craype craype/2.5.13 
module swap cray-mpich cray-mpich/7.7.0
 make clean; make CC=cc CXX=CC \
       SYSTEM=titan VERBOSE=1 LOG=1 LOG_ALL=1\
       ADD_BATCH_SCHED=1 VERBOSE_TESTS=1 all;\

Notes and unspported features

  • If your environmental modules do not support automatic switch of modules (e.g. module load gcc will not work if other compiler module is loaded), the MODULE_LOAD feature will not work.
  • SOURCES_C, SOURCSE_CPP, and SOURCES_F where once used instead of SOURCE. This is now depreciated
  • TESTS_TO_RUN was once used instead of SOURCES. This is now depreciated.
  • Multiple CC flags at once.
  • LOG_ALL does not imply LOG option
  • NO_OFFLOADING might result in unexpected tests results, as not all the tests work well if executed on the hosts (e.g. target if tests requires the device to be availabe)