From 5fc7a8d201304026dacc917f879e6646e9f80977 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 22 Aug 2016 02:50:08 -0400 Subject: [PATCH 1/4] Add OpenMP test --- cryptest.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/cryptest.sh b/cryptest.sh index bdcaff2b..bb403496 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -432,6 +432,36 @@ if [[ (-z "$HAVE_UBSAN") ]]; then fi fi +rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 +if [[ (-z "$HAVE_OMP") ]]; then + HAVE_OMP=0 + if [[ "$GCC_COMPILER" -ne "0" ]]; then + "$CXX" -DCRYPTOPP_ADHOC_MAIN -fopenmp -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_OMP=1 + OMP_FLAG=(-fopenmp -O3) + fi + elif [[ "$INTEL_COMPILER" -ne "0" ]]; then + "$CXX" -DCRYPTOPP_ADHOC_MAIN -openmp -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_OMP=1 + OMP_FLAG=(-openmp -O3) + fi + elif [[ "$CLANG_COMPILER" -ne "0" ]]; then + "$CXX" -DCRYPTOPP_ADHOC_MAIN -fopenmp=libomp -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_OMP=1 + OMP_FLAG=(-fopenmp=libomp -O3) + fi + elif [[ "$SUN_COMPILER" -ne "0" ]]; then + "$CXX" -DCRYPTOPP_ADHOC_MAIN -xopenmp=parallel -xO3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_OMP=1 + OMP_FLAG=(-xopenmp=parallel -xO3) + fi + fi +fi + rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ (-z "$HAVE_ASAN") ]]; then HAVE_ASAN=0 @@ -735,6 +765,9 @@ fi # Tools available for testing echo | tee -a "$TEST_RESULTS" +if [[ (! -z "$HAVE_OMP") ]]; then + echo "HAVE_OMP: $HAVE_OMP" | tee -a "$TEST_RESULTS" +fi echo "HAVE_ASAN: $HAVE_ASAN" | tee -a "$TEST_RESULTS" if [[ ("$HAVE_ASAN" -ne "0") && (! -z "$ASAN_SYMBOLIZE") ]]; then echo "ASAN_SYMBOLIZE: $ASAN_SYMBOLIZE" | tee -a "$TEST_RESULTS"; fi echo "HAVE_UBSAN: $HAVE_UBSAN" | tee -a "$TEST_RESULTS" @@ -2398,19 +2431,20 @@ if [[ ("$SUN_COMPILER" -eq "0") ]]; then fi fi +*** ############################################ -# Debug build, UBSan, c++03 -if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_UBSAN" -ne "0") ]]; then +# Debug build, dead code strip +if [[ ("$SUN_COMPILER" -eq "0") ]]; then echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Debug, c++03, UBsan" | tee -a "$TEST_RESULTS" + echo "Testing: Debug, dead code strip" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$DEBUG_CXXFLAGS -std=c++03 ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" - CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" ubsan | tee -a "$TEST_RESULTS" + CXXFLAGS="$DEBUG_CXXFLAGS ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" + CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" lean 2>&1 | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" @@ -2427,17 +2461,45 @@ if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_UBSAN" -ne "0") ]]; then fi ############################################ -# Release build, UBSan, c++03 -if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_UBSAN" -ne "0") ]]; then +# Release build, dead code strip +if [[ ("$SUN_COMPILER" -eq "0") ]]; then echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Release, c++03, UBsan" | tee -a "$TEST_RESULTS" + echo "Testing: Release, dead code strip" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$RELEASE_CXXFLAGS -std=c++03 ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" + CXXFLAGS="$RELEASE_CXXFLAGS ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" + CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" lean 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi +fi + +############################################ +# OpenMP +if [[ ("$HAVE_OMP" -ne "0") ]]; then + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Release, OpenMP" | tee -a "$TEST_RESULTS" + echo + + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXXFLAGS="${OMP_FLAG[@]} ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" ubsan | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then From 65984d31e6ffa0ad079505b2f17be416f36fc0db Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 22 Aug 2016 03:03:59 -0400 Subject: [PATCH 2/4] Remove duplicate dead code stripping --- cryptest.sh | 82 ++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 70 deletions(-) diff --git a/cryptest.sh b/cryptest.sh index bb403496..921b14c4 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -439,25 +439,25 @@ if [[ (-z "$HAVE_OMP") ]]; then "$CXX" -DCRYPTOPP_ADHOC_MAIN -fopenmp -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_OMP=1 - OMP_FLAG=(-fopenmp -O3) + OMP_FLAGS=(-fopenmp -O3) fi elif [[ "$INTEL_COMPILER" -ne "0" ]]; then "$CXX" -DCRYPTOPP_ADHOC_MAIN -openmp -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_OMP=1 - OMP_FLAG=(-openmp -O3) + OMP_FLAGS=(-openmp -O3) fi elif [[ "$CLANG_COMPILER" -ne "0" ]]; then "$CXX" -DCRYPTOPP_ADHOC_MAIN -fopenmp=libomp -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_OMP=1 - OMP_FLAG=(-fopenmp=libomp -O3) + OMP_FLAGS=(-fopenmp=libomp -O3) fi elif [[ "$SUN_COMPILER" -ne "0" ]]; then "$CXX" -DCRYPTOPP_ADHOC_MAIN -xopenmp=parallel -xO3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_OMP=1 - OMP_FLAG=(-xopenmp=parallel -xO3) + OMP_FLAGS=(-xopenmp=parallel -xO3) fi fi fi @@ -765,9 +765,7 @@ fi # Tools available for testing echo | tee -a "$TEST_RESULTS" -if [[ (! -z "$HAVE_OMP") ]]; then - echo "HAVE_OMP: $HAVE_OMP" | tee -a "$TEST_RESULTS" -fi +if [[ ((! -z "$HAVE_OMP") && ("$HAVE_OMP" -ne "0")) ]]; then echo "HAVE_OMP: $HAVE_OMP" | tee -a "$TEST_RESULTS"; fi echo "HAVE_ASAN: $HAVE_ASAN" | tee -a "$TEST_RESULTS" if [[ ("$HAVE_ASAN" -ne "0") && (! -z "$ASAN_SYMBOLIZE") ]]; then echo "ASAN_SYMBOLIZE: $ASAN_SYMBOLIZE" | tee -a "$TEST_RESULTS"; fi echo "HAVE_UBSAN: $HAVE_UBSAN" | tee -a "$TEST_RESULTS" @@ -2376,8 +2374,11 @@ if [[ "$HAVE_OFAST" -ne "0" ]]; then fi ############################################ -# Debug build, dead code strip +# Dead code stripping if [[ ("$SUN_COMPILER" -eq "0") ]]; then + + ############################################ + # Debug build echo echo "************************************" | tee -a "$TEST_RESULTS" echo "Testing: Debug, dead code strip" | tee -a "$TEST_RESULTS" @@ -2401,68 +2402,9 @@ if [[ ("$SUN_COMPILER" -eq "0") ]]; then echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" fi fi -fi -############################################ -# Release build, dead code strip -if [[ ("$SUN_COMPILER" -eq "0") ]]; then - echo - echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Release, dead code strip" | tee -a "$TEST_RESULTS" - echo - - "$MAKE" clean > /dev/null 2>&1 - rm -f adhoc.cpp > /dev/null 2>&1 - - CXXFLAGS="$RELEASE_CXXFLAGS ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" - CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" lean 2>&1 | tee -a "$TEST_RESULTS" - - if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then - echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" - else - ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" - if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then - echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" - fi - ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" - if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then - echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" - fi - fi -fi - -*** -############################################ -# Debug build, dead code strip -if [[ ("$SUN_COMPILER" -eq "0") ]]; then - echo - echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Debug, dead code strip" | tee -a "$TEST_RESULTS" - echo - - "$MAKE" clean > /dev/null 2>&1 - rm -f adhoc.cpp > /dev/null 2>&1 - - CXXFLAGS="$DEBUG_CXXFLAGS ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" - CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" lean 2>&1 | tee -a "$TEST_RESULTS" - - if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then - echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" - else - ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" - if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then - echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" - fi - ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" - if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then - echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" - fi - fi -fi - -############################################ -# Release build, dead code strip -if [[ ("$SUN_COMPILER" -eq "0") ]]; then + ############################################ + # Release build echo echo "************************************" | tee -a "$TEST_RESULTS" echo "Testing: Release, dead code strip" | tee -a "$TEST_RESULTS" @@ -2499,7 +2441,7 @@ if [[ ("$HAVE_OMP" -ne "0") ]]; then "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="${OMP_FLAG[@]} ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" + CXXFLAGS="-DNDEBUG ${OMP_FLAGS[@]} ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" ubsan | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then From 4892ae25a7a60b4c80683ce95b640265da83966a Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 22 Aug 2016 03:11:52 -0400 Subject: [PATCH 3/4] Add debug and release test --- cryptest.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/cryptest.sh b/cryptest.sh index 921b14c4..d6bfa18a 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -2458,6 +2458,62 @@ if [[ ("$HAVE_OMP" -ne "0") ]]; then fi fi +############################################ +# Debug build, UBSan, c++03 +if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_UBSAN" -ne "0") ]]; then + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Debug, c++03, UBsan" | tee -a "$TEST_RESULTS" + echo + + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXXFLAGS="$DEBUG_CXXFLAGS -std=c++03 ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" + CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" ubsan | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi +fi + +############################################ +# Release build, UBSan, c++03 +if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_UBSAN" -ne "0") ]]; then + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Release, c++03, UBsan" | tee -a "$TEST_RESULTS" + echo + + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXXFLAGS="$RELEASE_CXXFLAGS -std=c++03 ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" + CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" ubsan | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi +fi + ############################################ # Debug build, Asan, c++03 if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_ASAN" -ne "0") ]]; then @@ -2494,6 +2550,7 @@ if [[ ("$HAVE_CXX03" -ne "0" && "$HAVE_ASAN" -ne "0") ]]; then echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" fi fi + fi fi From 81e346ff35f11c2e5401799cda868b49b757ef40 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 22 Aug 2016 03:16:12 -0400 Subject: [PATCH 4/4] Remove ubsan target from OpenMP test --- cryptest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptest.sh b/cryptest.sh index d6bfa18a..3824c7cc 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -2442,7 +2442,7 @@ if [[ ("$HAVE_OMP" -ne "0") ]]; then rm -f adhoc.cpp > /dev/null 2>&1 CXXFLAGS="-DNDEBUG ${OMP_FLAGS[@]} ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}" - CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" ubsan | tee -a "$TEST_RESULTS" + CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS"