diff options
author | CNugteren <web@cedricnugteren.nl> | 2015-06-20 11:26:01 +0200 |
---|---|---|
committer | CNugteren <web@cedricnugteren.nl> | 2015-06-20 11:26:01 +0200 |
commit | dfbc3365312a8ee1c100d7659e5814548192b48d (patch) | |
tree | 38399dfada74feb562279d7a39e99d93971fd64f /test | |
parent | e26742c62993892deffbd44e68f3769423330cbb (diff) |
Moved the argument parsing to the common Tester base class
Diffstat (limited to 'test')
-rw-r--r-- | test/correctness/routines/xaxpy.cc | 10 | ||||
-rw-r--r-- | test/correctness/routines/xgemm.cc | 10 | ||||
-rw-r--r-- | test/correctness/routines/xgemv.cc | 10 | ||||
-rw-r--r-- | test/correctness/routines/xsymm.cc | 10 | ||||
-rw-r--r-- | test/correctness/testabc.cc | 4 | ||||
-rw-r--r-- | test/correctness/testabc.h | 2 | ||||
-rw-r--r-- | test/correctness/testaxy.cc | 4 | ||||
-rw-r--r-- | test/correctness/testaxy.h | 2 | ||||
-rw-r--r-- | test/correctness/tester.cc | 10 | ||||
-rw-r--r-- | test/correctness/tester.h | 6 | ||||
-rw-r--r-- | test/correctness/testxy.cc | 4 | ||||
-rw-r--r-- | test/correctness/testxy.h | 2 |
12 files changed, 29 insertions, 45 deletions
diff --git a/test/correctness/routines/xaxpy.cc b/test/correctness/routines/xaxpy.cc index aa90766e..45dcf6bb 100644 --- a/test/correctness/routines/xaxpy.cc +++ b/test/correctness/routines/xaxpy.cc @@ -46,19 +46,13 @@ void XaxpyTest(int argc, char *argv[], const bool silent, const std::string &nam return static_cast<StatusCode>(status); }; - // Selects the platform and device on which to test (command-line options) - auto help = std::string{"Options given/available:\n"}; - const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0}); - const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0}); - if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); } - - // Initializes the other arguments relevant for this routine + // Initializes the arguments relevant for this routine auto args = Arguments<T>{}; const auto options = std::vector<std::string>{kArgN, kArgXInc, kArgYInc, kArgXOffset, kArgYOffset, kArgAlpha}; // Creates a tester - TestXY<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda}; + TestXY<T> tester{argc, argv, silent, name, options, clblast_lambda, clblas_lambda}; // Runs the tests const auto case_name = "default"; diff --git a/test/correctness/routines/xgemm.cc b/test/correctness/routines/xgemm.cc index 2de17518..4129e17c 100644 --- a/test/correctness/routines/xgemm.cc +++ b/test/correctness/routines/xgemm.cc @@ -56,13 +56,7 @@ void XgemmTest(int argc, char *argv[], const bool silent, const std::string &nam return static_cast<StatusCode>(status); }; - // Selects the platform and device on which to test (command-line options) - auto help = std::string{"Options given/available:\n"}; - const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0}); - const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0}); - if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); } - - // Initializes the other arguments relevant for this routine + // Initializes the arguments relevant for this routine auto args = Arguments<T>{}; const auto options = std::vector<std::string>{kArgM, kArgN, kArgK, kArgLayout, kArgATransp, kArgBTransp, @@ -70,7 +64,7 @@ void XgemmTest(int argc, char *argv[], const bool silent, const std::string &nam kArgAOffset, kArgBOffset, kArgCOffset}; // Creates a tester - TestABC<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda}; + TestABC<T> tester{argc, argv, silent, name, options, clblast_lambda, clblas_lambda}; // Loops over the test-cases from a data-layout point of view for (auto &layout: tester.kLayouts) { diff --git a/test/correctness/routines/xgemv.cc b/test/correctness/routines/xgemv.cc index 69faeb64..1f484eb4 100644 --- a/test/correctness/routines/xgemv.cc +++ b/test/correctness/routines/xgemv.cc @@ -50,20 +50,14 @@ void XgemvTest(int argc, char *argv[], const bool silent, const std::string &nam return static_cast<StatusCode>(status); }; - // Selects the platform and device on which to test (command-line options) - auto help = std::string{"Options given/available:\n"}; - const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0}); - const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0}); - if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); } - - // Initializes the other arguments relevant for this routine + // Initializes the arguments relevant for this routine auto args = Arguments<T>{}; const auto options = std::vector<std::string>{kArgM, kArgN, kArgLayout, kArgATransp, kArgALeadDim, kArgXInc, kArgYInc, kArgAOffset, kArgXOffset, kArgYOffset}; // Creates a tester - TestAXY<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda}; + TestAXY<T> tester{argc, argv, silent, name, options, clblast_lambda, clblas_lambda}; // Loops over the test-cases from a data-layout point of view for (auto &layout: tester.kLayouts) { diff --git a/test/correctness/routines/xsymm.cc b/test/correctness/routines/xsymm.cc index 14d6a3f7..d769177f 100644 --- a/test/correctness/routines/xsymm.cc +++ b/test/correctness/routines/xsymm.cc @@ -56,13 +56,7 @@ void XsymmTest(int argc, char *argv[], const bool silent, const std::string &nam return static_cast<StatusCode>(status); }; - // Selects the platform and device on which to test (command-line options) - auto help = std::string{"Options given/available:\n"}; - const auto platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0}); - const auto device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0}); - if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); } - - // Initializes the other arguments relevant for this routine + // Initializes the arguments relevant for this routine auto args = Arguments<T>{}; const auto options = std::vector<std::string>{kArgM, kArgN, kArgLayout, kArgSide, kArgTriangle, @@ -70,7 +64,7 @@ void XsymmTest(int argc, char *argv[], const bool silent, const std::string &nam kArgAOffset, kArgBOffset, kArgCOffset}; // Creates a tester - TestABC<T> tester{platform_id, device_id, name, options, clblast_lambda, clblas_lambda}; + TestABC<T> tester{argc, argv, silent, name, options, clblast_lambda, clblas_lambda}; // Loops over the test-cases from a data-layout point of view for (auto &layout: tester.kLayouts) { diff --git a/test/correctness/testabc.cc b/test/correctness/testabc.cc index 0d78a24d..107ffb70 100644 --- a/test/correctness/testabc.cc +++ b/test/correctness/testabc.cc @@ -20,10 +20,10 @@ namespace clblast { // Constructor, initializes the base class tester and input data template <typename T> -TestABC<T>::TestABC(const size_t platform_id, const size_t device_id, +TestABC<T>::TestABC(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options, const Routine clblast_lambda, const Routine clblas_lambda): - Tester<T>{platform_id, device_id, name, options}, + Tester<T>{argc, argv, silent, name, options}, clblast_lambda_(clblast_lambda), clblas_lambda_(clblas_lambda) { diff --git a/test/correctness/testabc.h b/test/correctness/testabc.h index e995ba5b..6472af42 100644 --- a/test/correctness/testabc.h +++ b/test/correctness/testabc.h @@ -57,7 +57,7 @@ class TestABC: public Tester<T> { CommandQueue&)>; // Constructor, initializes the base class tester and input data - TestABC(const size_t platform_id, const size_t device_id, + TestABC(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options, const Routine clblast_lambda, const Routine clblas_lambda); diff --git a/test/correctness/testaxy.cc b/test/correctness/testaxy.cc index 50591613..3588573a 100644 --- a/test/correctness/testaxy.cc +++ b/test/correctness/testaxy.cc @@ -20,10 +20,10 @@ namespace clblast { // Constructor, initializes the base class tester and input data template <typename T> -TestAXY<T>::TestAXY(const size_t platform_id, const size_t device_id, +TestAXY<T>::TestAXY(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options, const Routine clblast_lambda, const Routine clblas_lambda): - Tester<T>{platform_id, device_id, name, options}, + Tester<T>{argc, argv, silent, name, options}, clblast_lambda_(clblast_lambda), clblas_lambda_(clblas_lambda) { diff --git a/test/correctness/testaxy.h b/test/correctness/testaxy.h index 97155d69..9135e2ba 100644 --- a/test/correctness/testaxy.h +++ b/test/correctness/testaxy.h @@ -59,7 +59,7 @@ class TestAXY: public Tester<T> { CommandQueue&)>; // Constructor, initializes the base class tester and input data - TestAXY(const size_t platform_id, const size_t device_id, + TestAXY(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options, const Routine clblast_lambda, const Routine clblas_lambda); diff --git a/test/correctness/tester.cc b/test/correctness/tester.cc index 5fd9da92..e6285f32 100644 --- a/test/correctness/tester.cc +++ b/test/correctness/tester.cc @@ -34,10 +34,11 @@ template <> const std::vector<Transpose> Tester<double2>::kTransposes = {Transpo // General constructor for all CLBlast testers. It prints out the test header to stdout and sets-up // the clBLAS library for reference. template <typename T> -Tester<T>::Tester(const size_t platform_id, const size_t device_id, +Tester<T>::Tester(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options): - platform_(Platform(platform_id)), - device_(Device(platform_, kDeviceType, device_id)), + help_("Options given/available:\n"), + platform_(Platform(GetArgument(argc, argv, help_, kArgPlatform, size_t{0}))), + device_(Device(platform_, kDeviceType, GetArgument(argc, argv, help_, kArgDevice, size_t{0}))), context_(Context(device_)), queue_(CommandQueue(context_, device_)), error_log_{}, @@ -49,6 +50,9 @@ Tester<T>::Tester(const size_t platform_id, const size_t device_id, tests_passed_{0}, options_{options} { + // Prints the help message (command-line arguments) + if (!silent) { fprintf(stdout, "\n* %s\n", help_.c_str()); } + // 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", diff --git a/test/correctness/tester.h b/test/correctness/tester.h index e6815fce..ffc02bbf 100644 --- a/test/correctness/tester.h +++ b/test/correctness/tester.h @@ -76,7 +76,7 @@ class Tester { // Creates an instance of the tester, running on a particular OpenCL platform and device. It // takes the routine's names as an additional parameter. - explicit Tester(const size_t platform_id, const size_t device_id, + explicit Tester(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options); ~Tester(); @@ -97,6 +97,9 @@ class Tester { // Retrieves a list of example scalars of the right type const std::vector<T> GetExampleScalars(); + // The help-message + std::string help_; + // The OpenCL objects (accessible by derived classes) Platform platform_; Device device_; @@ -105,6 +108,7 @@ class Tester { private: + // Internal methods to report a passed, skipped, or failed test void ReportPass(); void ReportSkipped(); diff --git a/test/correctness/testxy.cc b/test/correctness/testxy.cc index b88600b7..b2d6c147 100644 --- a/test/correctness/testxy.cc +++ b/test/correctness/testxy.cc @@ -20,10 +20,10 @@ namespace clblast { // Constructor, initializes the base class tester and input data template <typename T> -TestXY<T>::TestXY(const size_t platform_id, const size_t device_id, +TestXY<T>::TestXY(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options, const Routine clblast_lambda, const Routine clblas_lambda): - Tester<T>{platform_id, device_id, name, options}, + Tester<T>{argc, argv, silent, name, options}, clblast_lambda_(clblast_lambda), clblas_lambda_(clblas_lambda) { diff --git a/test/correctness/testxy.h b/test/correctness/testxy.h index 2a9dcab9..c806de14 100644 --- a/test/correctness/testxy.h +++ b/test/correctness/testxy.h @@ -56,7 +56,7 @@ class TestXY: public Tester<T> { CommandQueue&)>; // Constructor, initializes the base class tester and input data - TestXY(const size_t platform_id, const size_t device_id, + TestXY(int argc, char *argv[], const bool silent, const std::string &name, const std::vector<std::string> &options, const Routine clblast_lambda, const Routine clblas_lambda); |