Skip to content

Commit

Permalink
[Smoke]-Added debug support to flags test (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
estewart08 authored Oct 7, 2019
1 parent 56e66c3 commit a174cd3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/smoke/flags/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/smoke/flags/options.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
67 changes: 44 additions & 23 deletions test/smoke/flags/run_options.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"

0 comments on commit a174cd3

Please sign in to comment.