summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2018-05-19 17:54:27 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2018-05-19 17:54:27 +0200
commitcbcd4ff7e8e21584a9a1f405c9f4cb979a73b718 (patch)
tree4a131ed480dc4f496a211453f95adfebaf3f6336 /test
parente057a9186a1ed0a169fcf4db7a2598d08f530834 (diff)
parent507d7bc729eff888dd499e937bf1a636cbdee75b (diff)
Merge branch 'master' into CLBlast-267-convgemm
Diffstat (limited to 'test')
-rw-r--r--test/correctness/testblas.cpp41
-rw-r--r--test/routines/level2/xhpr.hpp2
-rw-r--r--test/routines/level2/xhpr2.hpp2
-rw-r--r--test/routines/level2/xspr.hpp2
-rw-r--r--test/routines/level2/xspr2.hpp2
-rw-r--r--test/test_utilities.cpp1
6 files changed, 37 insertions, 13 deletions
diff --git a/test/correctness/testblas.cpp b/test/correctness/testblas.cpp
index aa4b4785..3c92565e 100644
--- a/test/correctness/testblas.cpp
+++ b/test/correctness/testblas.cpp
@@ -66,14 +66,14 @@ TestBlas<T,U>::TestBlas(const std::vector<std::string> &arguments, const bool si
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(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);
+ // Creates test input data. Adds a 'canary' region to detect buffer overflows
+ x_source_.resize(max_batch_count * std::max(max_vec, max_matvec)*max_inc + max_offset + kCanarySize);
+ y_source_.resize(max_batch_count * std::max(max_vec, max_matvec)*max_inc + max_offset + kCanarySize);
+ a_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset + kCanarySize);
+ b_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset + kCanarySize);
+ c_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_ld, max_matvec) + max_offset + kCanarySize);
+ ap_source_.resize(max_batch_count * std::max(max_mat, max_matvec)*std::max(max_mat, max_matvec) + max_offset + kCanarySize);
+ scalar_source_.resize(max_batch_count * std::max(max_mat, max_matvec) + max_offset + kCanarySize);
std::mt19937 mt(kSeed);
std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
PopulateVector(x_source_, mt, dist);
@@ -94,7 +94,16 @@ void TestBlas<T,U>::TestRegular(std::vector<Arguments<U>> &test_vector, const st
TestStart("regular behaviour", name);
// Iterates over all the to-be-tested combinations of arguments
- for (const auto &args: test_vector) {
+ for (auto &args: test_vector) {
+
+ // Adds a 'canary' region to detect buffer overflows
+ args.x_size += kCanarySize;
+ args.y_size += kCanarySize;
+ args.a_size += kCanarySize;
+ args.b_size += kCanarySize;
+ args.c_size += kCanarySize;
+ args.ap_size += kCanarySize;
+ args.scalar_size += kCanarySize;
// Prints the current test configuration
if (verbose_) {
@@ -209,6 +218,20 @@ void TestBlas<T,U>::TestRegular(std::vector<Arguments<U>> &test_vector, const st
}
}
}
+ // Checks for differences in the 'canary' region to detect buffer overflows
+ for (auto canary_id=size_t{0}; canary_id<kCanarySize; ++canary_id) {
+ auto index = get_index_(args, get_id1_(args) - 1, get_id2_(args) - 1) + canary_id;
+ if (!TestSimilarity(result1[index], result2[index])) {
+ errors++;
+ if (verbose_) {
+ if (get_id2_(args) == 1) { std::cout << std::endl << " Buffer overflow index " << index << ": "; }
+ else { std::cout << std::endl << " Buffer overflow " << index << ": "; }
+ std::cout << " " << ToString(result1[index]) << " (reference) versus ";
+ std::cout << " " << ToString(result2[index]) << " (CLBlast)";
+ }
+ }
+ }
+
// Report the results
if (verbose_ && errors > 0) {
diff --git a/test/routines/level2/xhpr.hpp b/test/routines/level2/xhpr.hpp
index 1e9bbe29..3a79efa0 100644
--- a/test/routines/level2/xhpr.hpp
+++ b/test/routines/level2/xhpr.hpp
@@ -139,7 +139,7 @@ class TestXhpr {
}
// Describes how to compute the indices of the result buffer
- static size_t ResultID1(const Arguments<U> &args) { return args.ap_size - args.ap_offset; }
+ static size_t ResultID1(const Arguments<U> &args) { return GetSizeAP(args) - args.ap_offset; }
static size_t ResultID2(const Arguments<U> &) { return 1; } // N/A for this routine
static size_t GetResultIndex(const Arguments<U> &args, const size_t id1, const size_t) {
return id1 + args.ap_offset;
diff --git a/test/routines/level2/xhpr2.hpp b/test/routines/level2/xhpr2.hpp
index 433a5a93..ed37e175 100644
--- a/test/routines/level2/xhpr2.hpp
+++ b/test/routines/level2/xhpr2.hpp
@@ -148,7 +148,7 @@ class TestXhpr2 {
}
// Describes how to compute the indices of the result buffer
- static size_t ResultID1(const Arguments<T> &args) { return args.ap_size - args.ap_offset; }
+ static size_t ResultID1(const Arguments<T> &args) { return GetSizeAP(args) - args.ap_offset; }
static size_t ResultID2(const Arguments<T> &) { return 1; } // N/A for this routine
static size_t GetResultIndex(const Arguments<T> &args, const size_t id1, const size_t) {
return id1 + args.ap_offset;
diff --git a/test/routines/level2/xspr.hpp b/test/routines/level2/xspr.hpp
index af17b8cd..3f0dfe62 100644
--- a/test/routines/level2/xspr.hpp
+++ b/test/routines/level2/xspr.hpp
@@ -139,7 +139,7 @@ class TestXspr {
}
// Describes how to compute the indices of the result buffer
- static size_t ResultID1(const Arguments<T> &args) { return args.ap_size - args.ap_offset; }
+ static size_t ResultID1(const Arguments<T> &args) { return GetSizeAP(args) - args.ap_offset; }
static size_t ResultID2(const Arguments<T> &) { return 1; } // N/A for this routine
static size_t GetResultIndex(const Arguments<T> &args, const size_t id1, const size_t) {
return id1 + args.ap_offset;
diff --git a/test/routines/level2/xspr2.hpp b/test/routines/level2/xspr2.hpp
index b615aca7..b91eab24 100644
--- a/test/routines/level2/xspr2.hpp
+++ b/test/routines/level2/xspr2.hpp
@@ -148,7 +148,7 @@ class TestXspr2 {
}
// Describes how to compute the indices of the result buffer
- static size_t ResultID1(const Arguments<T> &args) { return args.ap_size - args.ap_offset; }
+ static size_t ResultID1(const Arguments<T> &args) { return GetSizeAP(args) - args.ap_offset; }
static size_t ResultID2(const Arguments<T> &) { return 1; } // N/A for this routine
static size_t GetResultIndex(const Arguments<T> &args, const size_t id1, const size_t) {
return id1 + args.ap_offset;
diff --git a/test/test_utilities.cpp b/test/test_utilities.cpp
index d8c1995e..59ec949d 100644
--- a/test/test_utilities.cpp
+++ b/test/test_utilities.cpp
@@ -171,6 +171,7 @@ void GetBestParametersFromJSONFile(const std::string& file_name,
kernel_family.erase(std::remove(kernel_family.begin(), kernel_family.end(), '1'), kernel_family.end());
kernel_family.erase(std::remove(kernel_family.begin(), kernel_family.end(), '2'), kernel_family.end());
kernel_family.erase(std::remove(kernel_family.begin(), kernel_family.end(), '3'), kernel_family.end());
+ if (kernel_family == "Xgemmdirect") { kernel_family = "XgemmDirect"; } // more kinds of mismatches
}
// Retrieves the best-parameters and sets the override