Skip to content

Commit

Permalink
[Examples]-Added scripts to cloc and fortran examples, updated build_…
Browse files Browse the repository at this point in the history
…fixups.sh to remove scripts for release
  • Loading branch information
amd-ethan committed Sep 16, 2019
1 parent 52fc012 commit 3b8b874
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bin/build_fixups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ $SUDO rm -f $AOMP/examples/hip/*.txt
$SUDO rm -f $AOMP/examples/hip/*.sh
$SUDO rm -f $AOMP/examples/openmp/*.txt
$SUDO rm -f $AOMP/examples/openmp/*.sh
$SUDO rm -f $AOMP/examples/cloc/*.txt
$SUDO rm -f $AOMP/examples/cloc/*.sh
$SUDO rm -f $AOMP/examples/fortran/*.txt
$SUDO rm -f $AOMP/examples/fortran/*.sh

#Clean libexec, share
$SUDO rm -rf $AOMP/libexec
Expand Down
37 changes: 37 additions & 0 deletions examples/cloc/check_cloc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#/bin/bash
#
# Checks all tests in examples/cloc directory using make check. Programs return 0 for success or a number > 0 for failure.
#
echo ""
echo ""
path=$(pwd)
base=$(basename $path)
echo ""
echo "RUNNING ALL TESTS IN: $path "
echo ""

echo "" > check-cloc.txt
echo "" >> check-cloc.txt
echo "*******A non-zero exit code means a failure occured.*******" >> check-cloc.txt
echo "***********************************************************" >> check-cloc.txt

#Loop over all directories and make run / make check depending on directory name
for directory in ./*/; do
(cd "$directory" && path=$(pwd) && base=$(basename $path)
make clean
make
make run
echo " Return Code for $base: $?" >> ../check-cloc.txt
make clean

)

done

#Print run.log for all tests that need visual inspection
for directory in ./*/; do
(cd "$directory" && path=$(pwd) && base=$(basename $path)
)
done
cat check-cloc.txt
rm check-cloc.txt
5 changes: 5 additions & 0 deletions examples/cloc/vector_copy/vector_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static hsa_status_t get_device_memory_region(hsa_region_t region, void* data) {
}

int main() {
int errors = 0;
// Initialize hsa runtime.
hsa_status_t hsa_status = hsa_init();
assert(HSA_STATUS_SUCCESS == hsa_status);
Expand Down Expand Up @@ -326,6 +327,7 @@ int main() {
if (valid) {
printf("passed validation\n");
} else {
errors = 1;
printf("VALIDATION FAILED!\nBad index: %d, ref(in):%d, computed(out):%d\n", failIndex, in[failIndex], out[failIndex]);
}

Expand All @@ -348,5 +350,8 @@ int main() {
free(in);
free(out);

if(errors)
return EXIT_FAILURE;

return EXIT_SUCCESS;
}
5 changes: 5 additions & 0 deletions examples/cloc/vector_copy_cuda/vector_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static hsa_status_t get_device_memory_region(hsa_region_t region, void* data) {
}

int main() {
int errors = 0;
// Initialize hsa runtime.
hsa_status_t hsa_status = hsa_init();
assert(HSA_STATUS_SUCCESS == hsa_status);
Expand Down Expand Up @@ -326,6 +327,7 @@ int main() {
if (valid) {
printf("passed validation\n");
} else {
errors = 1;
printf("VALIDATION FAILED!\nBad index: %d, ref(in):%d, computed(out):%d\n", failIndex, in[failIndex], out[failIndex]);
}

Expand All @@ -348,5 +350,8 @@ int main() {
free(in);
free(out);

if(errors)
return EXIT_FAILURE;

return EXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion examples/cloc/vector_copy_hip/vector_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ int main() {
std::cout << "PASSED!\n";
} else {
std::cout << "FAILED!\n";
return EXIT_FAILURE;
};

return 0;
return EXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion examples/cloc/vector_copy_hip_omp/vector_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ int main() {
std::cout << "PASSED!\n";
} else {
std::cout << "FAILED!\n";
return EXIT_FAILURE;
};

return 0;
return EXIT_SUCCESS;
}
39 changes: 39 additions & 0 deletions examples/fortran/check_fortran.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#/bin/bash
#
# Checks all tests in examples/fortran directory using make check. Programs return 0 for success or a number > 0 for failure.
# Tests that need to be visually inspected: helloworld
#
echo ""
echo ""
path=$(pwd)
base=$(basename $path)
echo ""
echo "RUNNING ALL TESTS IN: $path "
echo ""

echo "" > check-fortran.txt
echo "" >> check-fortran.txt
echo "*******A non-zero exit code means a failure occured.*******" >> check-fortran.txt
echo "*******Tests that need visual inspection: helloworld********" >> check-fortran.txt
echo "***********************************************************" >> check-fortran.txt

#Loop over all directories and make run / make check depending on directory name
for directory in ./*/; do
(cd "$directory" && path=$(pwd) && base=$(basename $path)
make clean
make
make run
echo " Return Code for $base: $?" >> ../check-fortran.txt
make clean

)

done

#Print run.log for all tests that need visual inspection
for directory in ./*/; do
(cd "$directory" && path=$(pwd) && base=$(basename $path)
)
done
cat check-fortran.txt
rm check-fortran.txt
3 changes: 2 additions & 1 deletion examples/fortran/simple_offload/simple_offload.f95
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ program main

write(6,*)"a(1)=", a(1), " a(2)=", a(2)
if (a(1).ne.11 .or. a(2).ne.22) then
stop "ERROR: wrong answers"
write(6,*)"ERROR: wrong answers"
stop 2
endif
write(6,*)"Success: if a diagnostic line starting with DEVID was output"
return
Expand Down

0 comments on commit 3b8b874

Please sign in to comment.