summaryrefslogtreecommitdiff
path: root/test/correctness
diff options
context:
space:
mode:
Diffstat (limited to 'test/correctness')
-rw-r--r--test/correctness/misc/override_parameters.cpp15
-rw-r--r--test/correctness/routines/levelx/xaxpybatched.cpp30
-rw-r--r--test/correctness/testblas.cpp42
-rw-r--r--test/correctness/testblas.hpp9
-rw-r--r--test/correctness/tester.cpp1
5 files changed, 73 insertions, 24 deletions
diff --git a/test/correctness/misc/override_parameters.cpp b/test/correctness/misc/override_parameters.cpp
index a4cecf0d..e6eebef7 100644
--- a/test/correctness/misc/override_parameters.cpp
+++ b/test/correctness/misc/override_parameters.cpp
@@ -11,11 +11,14 @@
//
// =================================================================================================
+#include <string>
+#include <vector>
+#include <unordered_map>
+#include <random>
+
#include "utilities/utilities.hpp"
#include "test/routines/level3/xgemm.hpp"
-#include <unordered_map>
-
namespace clblast {
// =================================================================================================
@@ -71,9 +74,11 @@ size_t RunOverrideTests(int argc, char *argv[], const bool silent, const std::st
auto host_a = std::vector<T>(args.m * args.k);
auto host_b = std::vector<T>(args.n * args.k);
auto host_c = std::vector<T>(args.m * args.n);
- PopulateVector(host_a, kSeed);
- PopulateVector(host_b, kSeed);
- PopulateVector(host_c, kSeed);
+ std::mt19937 mt(kSeed);
+ std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
+ PopulateVector(host_a, mt, dist);
+ PopulateVector(host_b, mt, dist);
+ PopulateVector(host_c, mt, dist);
// Copy the matrices to the device
auto device_a = Buffer<T>(context, host_a.size());
diff --git a/test/correctness/routines/levelx/xaxpybatched.cpp b/test/correctness/routines/levelx/xaxpybatched.cpp
new file mode 100644
index 00000000..a106440f
--- /dev/null
+++ b/test/correctness/routines/levelx/xaxpybatched.cpp
@@ -0,0 +1,30 @@
+
+// =================================================================================================
+// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
+// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
+// width of 100 characters per line.
+//
+// Author(s):
+// Cedric Nugteren <www.cedricnugteren.nl>
+//
+// =================================================================================================
+
+#include "test/correctness/testblas.hpp"
+#include "test/routines/levelx/xaxpybatched.hpp"
+
+// Shortcuts to the clblast namespace
+using float2 = clblast::float2;
+using double2 = clblast::double2;
+
+// Main function (not within the clblast namespace)
+int main(int argc, char *argv[]) {
+ auto errors = size_t{0};
+ errors += clblast::RunTests<clblast::TestXaxpyBatched<float>, float, float>(argc, argv, false, "SAXPYBATCHED");
+ errors += clblast::RunTests<clblast::TestXaxpyBatched<double>, double, double>(argc, argv, true, "DAXPYBATCHED");
+ errors += clblast::RunTests<clblast::TestXaxpyBatched<float2>, float2, float2>(argc, argv, true, "CAXPYBATCHED");
+ errors += clblast::RunTests<clblast::TestXaxpyBatched<double2>, double2, double2>(argc, argv, true, "ZAXPYBATCHED");
+ errors += clblast::RunTests<clblast::TestXaxpyBatched<half>, half, half>(argc, argv, true, "HAXPYBATCHED");
+ if (errors > 0) { return 1; } else { return 0; }
+}
+
+// =================================================================================================
diff --git a/test/correctness/testblas.cpp b/test/correctness/testblas.cpp
index d959ce18..56376d0b 100644
--- a/test/correctness/testblas.cpp
+++ b/test/correctness/testblas.cpp
@@ -13,7 +13,9 @@
#include <algorithm>
#include <iostream>
+#include <random>
+#include "utilities/utilities.hpp"
#include "test/correctness/testblas.hpp"
namespace clblast {
@@ -25,6 +27,7 @@ template <typename T, typename U> const std::vector<size_t> TestBlas<T,U>::kIncr
template <typename T, typename U> const std::vector<size_t> TestBlas<T,U>::kMatrixDims = { 7, 64 };
template <typename T, typename U> const std::vector<size_t> TestBlas<T,U>::kMatrixVectorDims = { 61, 256 };
template <typename T, typename U> const std::vector<size_t> TestBlas<T,U>::kBandSizes = { 4, 19 };
+template <typename T, typename U> const std::vector<size_t> TestBlas<T,U>::kBatchCounts = { 1, 3 };
// Test settings for the invalid tests
template <typename T, typename U> const std::vector<size_t> TestBlas<T,U>::kInvalidIncrements = { 0, 1 };
@@ -79,22 +82,25 @@ TestBlas<T,U>::TestBlas(const std::vector<std::string> &arguments, const bool si
const auto max_ld = *std::max_element(kMatrixDims.begin(), kMatrixDims.end());
const auto max_matvec = *std::max_element(kMatrixVectorDims.begin(), kMatrixVectorDims.end());
const auto max_offset = *std::max_element(kOffsets.begin(), kOffsets.end());
+ const auto max_batch_count = *std::max_element(kBatchCounts.begin(), kBatchCounts.end());
// Creates test input data
- x_source_.resize(std::max(max_vec, max_matvec)*max_inc + max_offset);
- y_source_.resize(std::max(max_vec, max_matvec)*max_inc + max_offset);
- a_source_.resize(std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset);
- b_source_.resize(std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset);
- c_source_.resize(std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset);
- ap_source_.resize(std::max(max_mat, max_matvec)*std::max(max_mat, max_matvec) + max_offset);
- scalar_source_.resize(std::max(max_mat, max_matvec) + max_offset);
- PopulateVector(x_source_, kSeed);
- PopulateVector(y_source_, kSeed);
- PopulateVector(a_source_, kSeed);
- PopulateVector(b_source_, kSeed);
- PopulateVector(c_source_, kSeed);
- PopulateVector(ap_source_, kSeed);
- PopulateVector(scalar_source_, kSeed);
+ x_source_.resize(max_batch_count * std::max(max_vec, max_matvec)*max_inc + max_offset);
+ y_source_.resize(max_batch_count * std::max(max_vec, max_matvec)*max_inc + max_offset);
+ a_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset);
+ b_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset);
+ c_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset);
+ ap_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_mat, max_matvec) + max_offset);
+ scalar_source_.resize(max_batch_count * std::max(max_mat, max_matvec) + max_offset);
+ std::mt19937 mt(kSeed);
+ std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
+ PopulateVector(x_source_, mt, dist);
+ PopulateVector(y_source_, mt, dist);
+ PopulateVector(a_source_, mt, dist);
+ PopulateVector(b_source_, mt, dist);
+ PopulateVector(c_source_, mt, dist);
+ PopulateVector(ap_source_, mt, dist);
+ PopulateVector(scalar_source_, mt, dist);
}
// ===============================================================================================
@@ -190,15 +196,15 @@ void TestBlas<T,U>::TestRegular(std::vector<Arguments<U>> &test_vector, const st
auto result2 = get_result_(args, buffers2, queue_);
// Computes the L2 error
- const auto kErrorMarginL2 = getL2ErrorMargin<T>();
auto l2error = 0.0;
+ const auto kErrorMarginL2 = getL2ErrorMargin<T>();
for (auto id1=size_t{0}; id1<get_id1_(args); ++id1) {
for (auto id2=size_t{0}; id2<get_id2_(args); ++id2) {
auto index = get_index_(args, id1, id2);
l2error += SquaredDifference(result1[index], result2[index]);
}
}
- l2error /= (get_id1_(args) * get_id2_(args));
+ l2error /= static_cast<double>(get_id1_(args) * get_id2_(args));
// Checks for differences in the output
auto errors = size_t{0};
@@ -219,8 +225,10 @@ void TestBlas<T,U>::TestRegular(std::vector<Arguments<U>> &test_vector, const st
}
}
}
+
+ // Report the results
if (verbose_ && errors > 0) {
- fprintf(stdout, "\n Combined L2 error: %.2e\n ", l2error);
+ fprintf(stdout, "\n Combined average L2 error: %.2e\n ", l2error);
}
// Tests the error count (should be zero)
diff --git a/test/correctness/testblas.hpp b/test/correctness/testblas.hpp
index ee795aad..42e8aef7 100644
--- a/test/correctness/testblas.hpp
+++ b/test/correctness/testblas.hpp
@@ -56,6 +56,7 @@ class TestBlas: public Tester<T,U> {
static const std::vector<size_t> kMatrixDims;
static const std::vector<size_t> kMatrixVectorDims;
static const std::vector<size_t> kBandSizes;
+ static const std::vector<size_t> kBatchCounts;
const std::vector<size_t> kOffsets;
const std::vector<U> kAlphaValues;
const std::vector<U> kBetaValues;
@@ -183,6 +184,7 @@ size_t RunTests(int argc, char *argv[], const bool silent, const std::string &na
auto imax_offsets = std::vector<size_t>{args.imax_offset};
auto alphas = std::vector<U>{args.alpha};
auto betas = std::vector<U>{args.beta};
+ auto batch_counts = std::vector<size_t>{args.batch_count};
auto x_sizes = std::vector<size_t>{args.x_size};
auto y_sizes = std::vector<size_t>{args.y_size};
auto a_sizes = std::vector<size_t>{args.a_size};
@@ -226,6 +228,7 @@ size_t RunTests(int argc, char *argv[], const bool silent, const std::string &na
if (option == kArgImaxOffset) { imax_offsets = tester.kOffsets; }
if (option == kArgAlpha) { alphas = tester.kAlphaValues; }
if (option == kArgBeta) { betas = tester.kBetaValues; }
+ if (option == kArgBatchCount) { batch_counts = tester.kBatchCounts; }
if (option == kArgXOffset) { x_sizes = tester.kVecSizes; }
if (option == kArgYOffset) { y_sizes = tester.kVecSizes; }
@@ -268,8 +271,10 @@ size_t RunTests(int argc, char *argv[], const bool silent, const std::string &na
for (auto &imax_offset: imax_offsets) { r_args.imax_offset = imax_offset;
for (auto &alpha: alphas) { r_args.alpha = alpha;
for (auto &beta: betas) { r_args.beta = beta;
- C::SetSizes(r_args);
- regular_test_vector.push_back(r_args);
+ for (auto &batch_count: batch_counts) { r_args.batch_count = batch_count;
+ C::SetSizes(r_args);
+ regular_test_vector.push_back(r_args);
+ }
}
}
}
diff --git a/test/correctness/tester.cpp b/test/correctness/tester.cpp
index cbfc5bb2..40784fdb 100644
--- a/test/correctness/tester.cpp
+++ b/test/correctness/tester.cpp
@@ -367,6 +367,7 @@ std::string Tester<T,U>::GetOptionsString(const Arguments<U> &args) {
if (o == kArgDotOffset){ result += kArgDotOffset + equals + ToString(args.dot_offset) + " "; }
if (o == kArgAlpha) { result += kArgAlpha + equals + ToString(args.alpha) + " "; }
if (o == kArgBeta) { result += kArgBeta + equals + ToString(args.beta) + " "; }
+ if (o == kArgBatchCount){result += kArgBatchCount + equals + ToString(args.batch_count) + " "; }
}
return result;
}