summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-11-28 20:52:47 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-11-28 20:52:47 +0100
commit426406668e6ebf2ed3a2d3e41e3c97ae5a8fb81d (patch)
tree71b0cc36603662829d332c7175acba107b96fb4f /test
parent14047861ce43593f9a54253b179c305c02e46fa8 (diff)
Improved the pre-processor tester, added GEMV and GER kernels
Diffstat (limited to 'test')
-rw-r--r--test/correctness/misc/preprocessor.cpp77
1 files changed, 53 insertions, 24 deletions
diff --git a/test/correctness/misc/preprocessor.cpp b/test/correctness/misc/preprocessor.cpp
index 88b27c69..5df27111 100644
--- a/test/correctness/misc/preprocessor.cpp
+++ b/test/correctness/misc/preprocessor.cpp
@@ -24,12 +24,38 @@
namespace clblast {
// =================================================================================================
+bool TestKernel(const Device& device, const Context& context,
+ const std::string &kernel_name, const std::string &kernel_source,
+ const Precision precision) {
+
+ fprintf(stdout, "* Testing simple OpenCL pre-processor for '%s'\n", kernel_name.c_str());
+
+ // Verifies that the current kernel compiles properly (assumes so, otherwise throws an error)
+ auto compiler_options_ref = std::vector<std::string>();
+ const auto program_ref = CompileFromSource(kernel_source, precision, kernel_name,
+ device, context, compiler_options_ref);
+
+ // Runs the pre-processor
+ const auto processed_source = PreprocessKernelSource(kernel_source);
+
+ // Verifies that the new kernel compiles properly
+ try {
+ auto compiler_options = std::vector<std::string>();
+ const auto program = CompileFromSource(processed_source, precision, kernel_name,
+ device, context, compiler_options);
+ return true;
+ } catch (...) {
+ fprintf(stdout, "* ERROR: Compilation warnings/errors with pre-processed kernel\n");
+ return false;
+ }
+}
+
+// =================================================================================================
+
size_t RunPreprocessor(int argc, char *argv[], const bool silent,
- const std::string &kernel_name, const std::string &kernel_source,
const Precision precision) {
auto errors = size_t{0};
auto passed = size_t{0};
- fprintf(stdout, "* Testing simple OpenCL pre-processor for '%s'\n", kernel_name.c_str());
// Retrieves the arguments
auto help = std::string{"Options given/available:\n"};
@@ -43,26 +69,34 @@ size_t RunPreprocessor(int argc, char *argv[], const bool silent,
const auto device = Device(platform, device_id);
const auto context = Context(device);
- // Verifies that the current kernel compiles properly (assumes so, otherwise throws an error)
- auto compiler_options_ref = std::vector<std::string>();
- const auto program_ref = CompileFromSource(kernel_source, precision, kernel_name,
- device, context, compiler_options_ref);
+ // XAXPY
+ const auto xaxpy_sources =
+ "#define WPT 2\n"
+ #include "../src/kernels/level1/level1.opencl"
+ #include "../src/kernels/level1/xaxpy.opencl"
+ ;
+ if (TestKernel(device, context, "XaxpyFastest", xaxpy_sources, precision)) { passed++; } else { errors++; }
- // Runs the pre-processor
- const auto processed_source = PreprocessKernelSource(kernel_source);
+ // XGER
+ const auto xger_sources =
+ "#define WPT 2\n"
+ #include "../src/kernels/level2/level2.opencl"
+ #include "../src/kernels/level2/xger.opencl"
+ ;
+ if (TestKernel(device, context, "Xger", xger_sources, precision)) { passed++; } else { errors++; }
- // Verifies that the new kernel compiles properly
- try {
- auto compiler_options = std::vector<std::string>();
- const auto program = CompileFromSource(processed_source, precision, kernel_name,
- device, context, compiler_options);
- passed++;
- } catch (...) {
- fprintf(stdout, "* ERROR: Compilation warnings/errors with pre-processed kernel\n");
- errors++;
- }
+ // XGEMV
+ const auto xgemv_sources =
+ "#define WPT1 2\n"
+ "#define WPT2 2\n"
+ "#define WPT3 2\n"
+ #include "../src/kernels/level2/xgemv.opencl"
+ #include "../src/kernels/level2/xgemv_fast.opencl"
+ ;
+ if (TestKernel(device, context, "XgemvFast", xgemv_sources, precision)) { passed++; } else { errors++; }
// Prints and returns the statistics
+ std::cout << std::endl;
std::cout << " " << passed << " test(s) passed" << std::endl;
std::cout << " " << errors << " test(s) failed" << std::endl;
std::cout << std::endl;
@@ -75,12 +109,7 @@ size_t RunPreprocessor(int argc, char *argv[], const bool silent,
// Main function (not within the clblast namespace)
int main(int argc, char *argv[]) {
auto errors = size_t{0};
- const auto xaxpy_sources =
- #include "../src/kernels/level1/level1.opencl"
- #include "../src/kernels/level1/xaxpy.opencl"
- ;
- errors += clblast::RunPreprocessor(argc, argv, false,
- "XaxpyFastest", xaxpy_sources, clblast::Precision::kSingle);
+ errors += clblast::RunPreprocessor(argc, argv, false, clblast::Precision::kSingle);
if (errors > 0) { return 1; } else { return 0; }
}