Skip to content

Commit

Permalink
Merge pull request #491 from eng-flavio-teixeira/bitwise_repro_tests_…
Browse files Browse the repository at this point in the history
…fix_6.2

Fix GTest skip/fail propagation throughout bitwise repro tests
  • Loading branch information
mamaydeo authored Jul 19, 2024
2 parents c5e2f48 + fc7ddc8 commit 7a8c475
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 101 deletions.
2 changes: 1 addition & 1 deletion clients/tests/accuracy_test_1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

#include "../../shared/accuracy_test.h"
#include "../../shared/fftw_transform.h"
#include "../../shared/params_gen.h"
#include "../../shared/rocfft_against_fftw.h"
#include "accuracy_tests_range.h"
#include "params_gen.h"

using ::testing::ValuesIn;

Expand Down
2 changes: 1 addition & 1 deletion clients/tests/accuracy_test_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

#include "../../shared/accuracy_test.h"
#include "../../shared/fftw_transform.h"
#include "../../shared/params_gen.h"
#include "../../shared/rocfft_against_fftw.h"
#include "accuracy_tests_range.h"
#include "params_gen.h"

using ::testing::ValuesIn;

Expand Down
2 changes: 1 addition & 1 deletion clients/tests/accuracy_test_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

#include "../../shared/accuracy_test.h"
#include "../../shared/fftw_transform.h"
#include "../../shared/params_gen.h"
#include "../../shared/rocfft_against_fftw.h"
#include "accuracy_tests_range.h"
#include "params_gen.h"

using ::testing::ValuesIn;

Expand Down
2 changes: 1 addition & 1 deletion clients/tests/accuracy_test_adhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// THE SOFTWARE.

#include "../../shared/accuracy_test.h"
#include "params_gen.h"
#include "../../shared/params_gen.h"

std::vector<std::vector<size_t>> adhoc_sizes = {
// sizes that exercise L1D_TRTRT subplan of 2D_RTRT or 3D_TRTRTR
Expand Down
2 changes: 1 addition & 1 deletion clients/tests/accuracy_test_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

#include "../../shared/accuracy_test.h"
#include "params_gen.h"
#include "../../shared/params_gen.h"

std::vector<std::vector<size_t>> callback_sizes = {
// some single kernel sizes
Expand Down
2 changes: 1 addition & 1 deletion clients/tests/accuracy_test_checkstride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

#include "../../shared/accuracy_test.h"
#include "params_gen.h"
#include "../../shared/params_gen.h"

extern bool fftw_compare;

Expand Down
56 changes: 50 additions & 6 deletions clients/tests/bitwise_repro/bitwise_repro_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <stdexcept>
#include <vector>

#include "../../../shared/params_gen.h"
#include "../../../shared/rocfft_params.h"
#include "../accuracy_tests_range.h"
#include "../params_gen.h"
#include "bitwise_repro_test.h"

using ::testing::ValuesIn;
Expand All @@ -51,7 +51,18 @@ TEST(bitwise_repro_test, compare_precisions)
GTEST_SKIP();
}

bitwise_repro(params_1, params_2);
try
{
bitwise_repro(params_1, params_2);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
SUCCEED();
}

Expand All @@ -75,7 +86,18 @@ TEST(bitwise_repro_test, compare_lengths)
GTEST_SKIP();
}

bitwise_repro(params_1, params_2);
try
{
bitwise_repro(params_1, params_2);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
SUCCEED();
}

Expand All @@ -99,7 +121,18 @@ TEST(bitwise_repro_test, compare_transform_types)
GTEST_SKIP();
}

bitwise_repro(params_1, params_2);
try
{
bitwise_repro(params_1, params_2);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
SUCCEED();
}

Expand Down Expand Up @@ -128,7 +161,18 @@ TEST_P(bitwise_repro_test, compare_to_reference)
GTEST_SKIP();
}

bitwise_repro(params);
try
{
bitwise_repro(params);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
SUCCEED();
}

Expand Down Expand Up @@ -565,4 +609,4 @@ INSTANTIATE_TEST_SUITE_P(
ooffset_range_zero,
place_range,
true)),
bitwise_repro_test::TestName);
bitwise_repro_test::TestName);
79 changes: 36 additions & 43 deletions clients/tests/bitwise_repro/bitwise_repro_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ inline void execute_fft(Tparams& params,
if(hip_status != hipSuccess)
{
++n_hip_failures;
std::stringstream msg;
msg << "hipMemcpy failure";
if(skip_runtime_fails)
{
GTEST_SKIP() << "hipMemcpy failure";
}
throw ROCFFT_GTEST_SKIP{std::move(msg)};
else
{
GTEST_FAIL() << "hipMemcpy failure";
}
throw ROCFFT_GTEST_FAIL{std::move(msg)};
}
}
if(verbose > 2)
Expand Down Expand Up @@ -128,16 +126,12 @@ void compute_fft_data(Tparams& params,
catch(fft_params::work_buffer_alloc_failure& e)
{
++n_hip_failures;
std::stringstream ss;
ss << "Work buffer allocation failed with size: " << params.workbuffersize;
std::stringstream msg;
msg << "Work buffer allocation failed with size: " << params.workbuffersize;
if(skip_runtime_fails)
{
GTEST_SKIP() << ss.str();
}
throw ROCFFT_GTEST_SKIP{std::move(msg)};
else
{
GTEST_FAIL() << ss.str();
}
throw ROCFFT_GTEST_FAIL{std::move(msg)};
}
ASSERT_EQ(plan_status, fft_status_success) << "plan creation failed";

Expand All @@ -148,19 +142,15 @@ void compute_fft_data(Tparams& params,
hip_status = ibuffer[i].alloc(ibuffer_sizes[i]);
if(hip_status != hipSuccess)
{
std::stringstream ss;
ss << "hipMalloc failure for input buffer " << i << " size " << ibuffer_sizes[i] << "("
<< bytes_to_GiB(ibuffer_sizes[i]) << " GiB)"
<< " with code " << hipError_to_string(hip_status);
std::stringstream msg;
msg << "hipMalloc failure for input buffer " << i << " size " << ibuffer_sizes[i] << "("
<< bytes_to_GiB(ibuffer_sizes[i]) << " GiB)"
<< " with code " << hipError_to_string(hip_status);
++n_hip_failures;
if(skip_runtime_fails)
{
GTEST_SKIP() << ss.str();
}
throw ROCFFT_GTEST_SKIP{std::move(msg)};
else
{
GTEST_FAIL() << ss.str();
}
throw ROCFFT_GTEST_FAIL{std::move(msg)};
}
pibuffer[i] = ibuffer[i].data();
}
Expand All @@ -183,15 +173,14 @@ void compute_fft_data(Tparams& params,
hipMemcpyDeviceToHost);
if(hip_status != hipSuccess)
{
std::stringstream msg;
msg << "hipMemcpy failure with error " << hip_status;

++n_hip_failures;
if(skip_runtime_fails)
{
GTEST_SKIP() << "hipMemcpy failure with error " << hip_status;
}
throw ROCFFT_GTEST_SKIP{std::move(msg)};
else
{
GTEST_FAIL() << "hipMemcpy failure with error " << hip_status;
}
throw ROCFFT_GTEST_FAIL{std::move(msg)};
}
}

Expand All @@ -214,18 +203,14 @@ void compute_fft_data(Tparams& params,
if(hip_status != hipSuccess)
{
++n_hip_failures;
std::stringstream ss;
ss << "hipMalloc failure for output buffer " << i << " size " << obuffer_sizes[i]
<< "(" << bytes_to_GiB(obuffer_sizes[i]) << " GiB)"
<< " with code " << hipError_to_string(hip_status);
std::stringstream msg;
msg << "hipMalloc failure for output buffer " << i << " size " << obuffer_sizes[i]
<< "(" << bytes_to_GiB(obuffer_sizes[i]) << " GiB)"
<< " with code " << hipError_to_string(hip_status);
if(skip_runtime_fails)
{
GTEST_SKIP() << ss.str();
}
throw ROCFFT_GTEST_SKIP{std::move(msg)};
else
{
GTEST_FAIL() << ss.str();
}
throw ROCFFT_GTEST_FAIL{std::move(msg)};
}
}
}
Expand Down Expand Up @@ -256,7 +241,11 @@ inline void bitwise_repro_impl(Tparams& params, Tparams& params_comp)
compute_hash(fft_output, obuffer_hash_in, obuffer_hash_out);

if(params_comp.token().compare(params.token()) == 0)
GTEST_SKIP() << "FFT input tokens are identical";
{
std::stringstream msg;
msg << "FFT input tokens are identical";
throw ROCFFT_GTEST_SKIP{std::move(msg)};
}

std::vector<hostbuf> fft_input_comp, fft_output_comp;
compute_fft_data(params_comp, fft_input_comp, fft_output_comp);
Expand Down Expand Up @@ -306,8 +295,12 @@ inline void bitwise_repro_impl(Tparams& params)
if(hash_entry_found)
ASSERT_TRUE(hash_valid) << "FFT result is not bitwise reproducible.";
else
GTEST_SKIP() << "FFT result entry added to the repro-db file. Previously stored reference "
"entry not found.";
{
std::stringstream msg;
msg << "FFT result entry added to the repro-db file. Previously stored reference entry not "
"found. \n";
throw ROCFFT_GTEST_SKIP{std::move(msg)};
}
}

inline void bitwise_repro(rocfft_params& params)
Expand Down
2 changes: 1 addition & 1 deletion clients/tests/callback_change_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// THE SOFTWARE.

#include "../../shared/hostbuf.h"
#include "../../shared/params_gen.h"
#include "../../shared/rocfft_complex.h"
#include "../../shared/rocfft_params.h"
#include "params_gen.h"

#include "../../shared/accuracy_test.h"
#include "../../shared/fftw_transform.h"
Expand Down
27 changes: 25 additions & 2 deletions clients/tests/gtest_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,18 @@ TEST(manual, vs_fftw) // MANUAL TESTS HERE
std::cout << "manual params are not valid\n";
}

fft_vs_reference(params);
try
{
fft_vs_reference(params);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
}

TEST(manual, bitwise_reproducibility) // MANUAL TESTS HERE
Expand All @@ -591,5 +602,17 @@ TEST(manual, bitwise_reproducibility) // MANUAL TESTS HERE
std::cout << "manual params are not valid\n";
}

bitwise_repro(params);
try
{
bitwise_repro(params);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
SUCCEED();
}
2 changes: 1 addition & 1 deletion clients/tests/multi_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// THE SOFTWARE.

#include "../../shared/accuracy_test.h"
#include "../../shared/params_gen.h"
#include "../../shared/rocfft_params.h"
#include "params_gen.h"
#include <gtest/gtest.h>
#include <hip/hip_runtime_api.h>

Expand Down
2 changes: 1 addition & 1 deletion clients/tests/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <random>

#include "../../shared/accuracy_test.h"
#include "../../shared/params_gen.h"
#include "../../shared/rocfft_accuracy_test.h"
#include "../../shared/test_params.h"
#include "params_gen.h"

class random_params
: public ::testing::TestWithParam<
Expand Down
14 changes: 13 additions & 1 deletion clients/tests/rocfft_accuracy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "../../shared/fftw_transform.h"
#include "../../shared/gpubuf.h"
#include "../../shared/gtest_except.h"
#include "../../shared/rocfft_against_fftw.h"
#include "rocfft/rocfft.h"

Expand Down Expand Up @@ -74,6 +75,17 @@ TEST_P(accuracy_test, vs_fftw)
// only do round trip for non-field FFTs
bool round_trip = params.ifields.empty() && params.ofields.empty();

fft_vs_reference(params, round_trip);
try
{
fft_vs_reference(params, round_trip);
}
catch(ROCFFT_GTEST_SKIP& e)
{
GTEST_SKIP() << e.msg.str();
}
catch(ROCFFT_GTEST_FAIL& e)
{
GTEST_FAIL() << e.msg.str();
}
SUCCEED();
}
Loading

0 comments on commit 7a8c475

Please sign in to comment.