From 0f486d9b7442a314fd45f993137e6794372de1f5 Mon Sep 17 00:00:00 2001 From: CNugteren Date: Sat, 20 Jun 2015 14:13:54 +0200 Subject: Automatically skips tests with unsupported precision --- test/correctness/testabc.cc | 2 ++ test/correctness/testabc.h | 1 + test/correctness/testaxy.cc | 2 ++ test/correctness/testaxy.h | 1 + test/correctness/tester.cc | 25 ++++++++++++++++++++++++- test/correctness/tester.h | 3 +++ test/correctness/testxy.cc | 2 ++ test/correctness/testxy.h | 3 ++- 8 files changed, 37 insertions(+), 2 deletions(-) (limited to 'test/correctness') diff --git a/test/correctness/testabc.cc b/test/correctness/testabc.cc index 107ffb70..eed17560 100644 --- a/test/correctness/testabc.cc +++ b/test/correctness/testabc.cc @@ -46,6 +46,7 @@ TestABC::TestABC(int argc, char *argv[], const bool silent, // Tests the routine for a wide variety of parameters template void TestABC::TestRegular(Arguments &args, const std::string &name) { + if (!PrecisionSupported()) { return; } TestStart("regular behaviour", name); // Computes whether or not the matrices are transposed. Note that we assume a default of @@ -161,6 +162,7 @@ void TestABC::TestRegular(Arguments &args, const std::string &name) { // does not test for results (if any). template void TestABC::TestInvalidBufferSizes(Arguments &args, const std::string &name) { + if (!PrecisionSupported()) { return; } TestStart("invalid buffer sizes", name); // Sets example test parameters diff --git a/test/correctness/testabc.h b/test/correctness/testabc.h index b7601024..2c44d532 100644 --- a/test/correctness/testabc.h +++ b/test/correctness/testabc.h @@ -42,6 +42,7 @@ class TestABC: public Tester { using Tester::TestErrorCodes; using Tester::GetExampleScalars; using Tester::GetOffsets; + using Tester::PrecisionSupported; // Test settings for the regular test. Append to this list in case more tests are required. const std::vector kMatrixDims = { 7, 64 }; diff --git a/test/correctness/testaxy.cc b/test/correctness/testaxy.cc index 3588573a..cb5e9923 100644 --- a/test/correctness/testaxy.cc +++ b/test/correctness/testaxy.cc @@ -47,6 +47,7 @@ TestAXY::TestAXY(int argc, char *argv[], const bool silent, // Tests the routine for a wide variety of parameters template void TestAXY::TestRegular(Arguments &args, const std::string &name) { + if (!PrecisionSupported()) { return; } TestStart("regular behaviour", name); // Iterates over the dimension for the matrix and vectors @@ -151,6 +152,7 @@ void TestAXY::TestRegular(Arguments &args, const std::string &name) { // does not test for results (if any). template void TestAXY::TestInvalidBufferSizes(Arguments &args, const std::string &name) { + if (!PrecisionSupported()) { return; } TestStart("invalid buffer sizes", name); // Sets example test parameters diff --git a/test/correctness/testaxy.h b/test/correctness/testaxy.h index 00d4f6ec..fa2c4a98 100644 --- a/test/correctness/testaxy.h +++ b/test/correctness/testaxy.h @@ -42,6 +42,7 @@ class TestAXY: public Tester { using Tester::TestErrorCodes; using Tester::GetExampleScalars; using Tester::GetOffsets; + using Tester::PrecisionSupported; // Test settings for the regular test. Append to this list in case more tests are required. const std::vector kMatrixVectorDims = { 61, 512 }; diff --git a/test/correctness/tester.cc b/test/correctness/tester.cc index 09b0b5bd..74b6679d 100644 --- a/test/correctness/tester.cc +++ b/test/correctness/tester.cc @@ -56,8 +56,18 @@ Tester::Tester(int argc, char *argv[], const bool silent, // Prints the header fprintf(stdout, "* Running on OpenCL device '%s'.\n", device_.Name().c_str()); - fprintf(stdout, "* Starting tests for the %s'%s'%s routine. Legend:\n", + fprintf(stdout, "* Starting tests for the %s'%s'%s routine.", kPrintMessage.c_str(), name.c_str(), kPrintEnd.c_str()); + + // Checks whether the precision is supported + if (!PrecisionSupported()) { + fprintf(stdout, "\n* Tests skipped: %sUnsupported precision%s\n", + kPrintWarning.c_str(), kPrintEnd.c_str()); + return; + } + + // Prints the legend + fprintf(stdout, " Legend:\n"); fprintf(stdout, " %s -> Test produced correct results\n", kSuccessData.c_str()); fprintf(stdout, " %s -> Test returned the correct error code\n", kSuccessStatus.c_str()); fprintf(stdout, " %s -> Test produced incorrect results\n", kErrorData.c_str()); @@ -290,6 +300,19 @@ const std::vector Tester::GetOffsets() { // ================================================================================================= +template <> bool Tester::PrecisionSupported() const { return true; } +template <> bool Tester::PrecisionSupported() const { return true; } +template <> bool Tester::PrecisionSupported() const { + auto extensions = device_.Extensions(); + return (extensions.find(kKhronosDoublePrecision) == std::string::npos) ? false : true; +} +template <> bool Tester::PrecisionSupported() const { + auto extensions = device_.Extensions(); + return (extensions.find(kKhronosDoublePrecision) == std::string::npos) ? false : true; +} + +// ================================================================================================= + // A test can either pass, be skipped, or fail template void Tester::ReportPass() { diff --git a/test/correctness/tester.h b/test/correctness/tester.h index 1085c472..b627d8f1 100644 --- a/test/correctness/tester.h +++ b/test/correctness/tester.h @@ -100,6 +100,9 @@ class Tester { // Retrieves a list of offset values to test const std::vector GetOffsets(); + // Returns false is this precision is not supported by the device + bool PrecisionSupported() const; + // The help-message std::string help_; diff --git a/test/correctness/testxy.cc b/test/correctness/testxy.cc index b2d6c147..5c86182c 100644 --- a/test/correctness/testxy.cc +++ b/test/correctness/testxy.cc @@ -44,6 +44,7 @@ TestXY::TestXY(int argc, char *argv[], const bool silent, // Tests the routine for a wide variety of parameters template void TestXY::TestRegular(Arguments &args, const std::string &name) { + if (!PrecisionSupported()) { return; } TestStart("regular behaviour", name); // Iterates over the vector dimension @@ -122,6 +123,7 @@ void TestXY::TestRegular(Arguments &args, const std::string &name) { // does not test for results (if any). template void TestXY::TestInvalidBufferSizes(Arguments &args, const std::string &name) { + if (!PrecisionSupported()) { return; } TestStart("invalid buffer sizes", name); // Sets example test parameters diff --git a/test/correctness/testxy.h b/test/correctness/testxy.h index 8f2b6876..ec2cbcc7 100644 --- a/test/correctness/testxy.h +++ b/test/correctness/testxy.h @@ -40,11 +40,12 @@ class TestXY: public Tester { using Tester::TestErrorCodes; using Tester::GetExampleScalars; using Tester::GetOffsets; + using Tester::PrecisionSupported; // Test settings for the regular test. Append to this list in case more tests are required. const std::vector kVectorDims = { 7, 93, 4096 }; const std::vector kOffsets = GetOffsets(); - const std::vector kIncrements = { 1, 2 }; + const std::vector kIncrements = { 1, 2, 7 }; const std::vector kAlphaValues = GetExampleScalars(); // Test settings for the invalid test -- cgit v1.2.3