diff --git a/test/smoke/flags/Makefile b/test/smoke/flags/Makefile index d6ba9a378..21f150b75 100644 --- a/test/smoke/flags/Makefile +++ b/test/smoke/flags/Makefile @@ -20,7 +20,7 @@ compile: ifdef nvidia_targets $(CC) $(make_options) $(nvidia_targets) $(march) $(cuda) -o $(TESTNAME) else ifdef march - $(CC) $(make_options) $(march) -o $(TESTNAME) + $(SETENV) $(CC) $(make_options) $(march) -o $(TESTNAME) else ifdef make_options $(CC) $(make_options) -o $(TESTNAME) else diff --git a/test/smoke/flags/options.txt b/test/smoke/flags/options.txt index 556d604ad..07a33acb5 100644 --- a/test/smoke/flags/options.txt +++ b/test/smoke/flags/options.txt @@ -1,4 +1,5 @@ -flags.c -isystem/home/estewart/rocm/aomp/include -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 +OFFLOAD_DEBUG=1 flags.c -isystem/home/estewart/rocm/aomp/include -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 +flags.c -isystem/home/estewart/rocm/aomp/include -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 flags.c -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 flags.c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 flags.c -fopenmp -save-temps -target x86_64-pc-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu diff --git a/test/smoke/flags/run_options.sh b/test/smoke/flags/run_options.sh index 0bf5ba3b2..9f27a6c44 100755 --- a/test/smoke/flags/run_options.sh +++ b/test/smoke/flags/run_options.sh @@ -1,21 +1,28 @@ #!/bin/bash # -# Runs each command in the optionst.txt file and returns error code. -# +# Runs each command in the options.txt file and returns error code. +# The Makefile will run this script twice when using 'make run' +# First run is to compile, second is to run for output in run.log. +#Input file file="options.txt" #Regex to search for "march=gfxXXX or sm_XX" march_regex="(march=[a-z]+[0-9]*_?[0-9]+)" +#Regex to search for OFFLOAD_DEBUG +debug_regex="(OFFLOAD_DEBUG=([0-9]))" +#Regex to search for Nvidia cards +target_regex="(-fopenmp-[a-z]*=[a-z,-]*).*(-Xopenmp-[a-z]*=[a-z,-]*)" + path=$(pwd) && base=$(basename $path) -#Read file and replace march with correct GPU and keep track of execution number +#Read file, replace march with correct GPU, add Nvidia options if necessary and keep track of execution number test_num=0; while read -r line; do ((test_num++)) - #if GPU is involved + #GPU is involved if [[ "$line" =~ $march_regex ]]; then march_match=${BASH_REMATCH[1]} - #remove march from command and replace with correct version - temp_line=${line/"-$march_match"} + #Remove march from command and replace with correct version + line=${line/"-$march_match"} mygpu=$AOMP_GPU if [ -z $mygpu ]; then echo -e "$RED"AOMP_GPU NOT SET, USING MYGPU UTILITY!"$BLK" @@ -27,38 +34,52 @@ while read -r line; do fi fi - #If NVIDIA system, add nvptx targets, cuda, and remove amdgcn targets. This is done for testing purpose to avoid rewriting original amd command. + #Check for OFFLOAD_DEBUG + if [[ "$line" =~ $debug_regex ]]; then + debug_match=${BASH_REMATCH[1]} + line=${line/"$debug_match"} + export $debug_match + fi + + #NVIDIA system, add nvptx targets, cuda, and remove amdgcn targets. This is done for testing purpose to avoid rewriting original amd command. if [[ "$mygpu" == *"sm"* ]]; then - target_regex="(-fopenmp-[a-z]*=[a-z,-]*).*(-Xopenmp-[a-z]*=[a-z,-]*)" if [[ "$line" =~ $target_regex ]]; then target_match="${BASH_REMATCH[1]} ${BASH_REMATCH[2]}" - temp_line=${temp_line/"$target_match"} + line=${line/"$target_match"} nvidia_args="-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda" cuda_args="-L/usr/local/cuda/targets/x86_64-linux/lib -lcudart" fi fi - #send variables to make + #GPU compilation or run, send variables to make if [[ $1 != "run" ]]; then - make --no-print-directory make_options="$temp_line" nvidia_targets="$nvidia_args" march="-march=$mygpu" cuda="$cuda_args" compile + make --no-print-directory make_options="$line" nvidia_targets="$nvidia_args" march="-march=$mygpu" cuda="$cuda_args" compile fi if [[ $1 == "run" ]]; then - make --no-print-directory make_options="$temp_line" nvidia_targets="$nvidia_args" march="-march=$mygpu" cuda="$cuda_args" test_num=$test_num check + make --no-print-directory make_options="$line" nvidia_targets="$nvidia_args" march="-march=$mygpu" cuda="$cuda_args" test_num=$test_num check fi if [ $? -ne 0 ]; then echo "$base $test_num: Make Failed" >> ../make-fail.txt fi - else - if [[ $1 != "run" ]]; then - make --no-print-directory make_options="$line" compile - fi - if [[ $1 == "run" ]]; then - make --no-print-directory make_options="$line" test_num=$test_num check - fi + else #Host compilation or run, GPU not detected on input line, no need to pass other variables to make + if [[ $1 != "run" ]]; then + make --no-print-directory make_options="$line" compile + fi + if [[ $1 == "run" ]]; then + make --no-print-directory make_options="$line" test_num=$test_num check fi - if [ $? -ne 0 ]; then - echo "$base $test_num: Make Failed" >> ../make-fail.txt - else - rm flags + fi + #Host not successfull + if [ $? -ne 0 ]; then + echo "$base $test_num: Make Failed" >> ../make-fail.txt + else + rm flags fi echo "" + + #reset OFFLOAD_DEBUG + reset_debug=$OFFLOAD_DEBUG + if [ -z $reset_Debug ]; then + export OFFLOAD_DEBUG=0 + fi + done < "$file"