mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-07-04 21:36:57 +02:00
Changed the way the test-data is generated: now using a single MT generator and distribution for all data
This commit is contained in:
parent
f9a520b3af
commit
7f14b11f1e
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <random>
|
||||
|
||||
#include <cltune.h>
|
||||
|
||||
|
@ -77,12 +78,14 @@ void Tuner(int argc, char* argv[]) {
|
|||
auto b_mat = std::vector<T>(C::GetSizeB(args));
|
||||
auto c_mat = std::vector<T>(C::GetSizeC(args));
|
||||
auto temp = std::vector<T>(C::GetSizeTemp(args));
|
||||
PopulateVector(x_vec, kSeed);
|
||||
PopulateVector(y_vec, kSeed);
|
||||
PopulateVector(a_mat, kSeed);
|
||||
PopulateVector(b_mat, kSeed);
|
||||
PopulateVector(c_mat, kSeed);
|
||||
PopulateVector(temp, kSeed);
|
||||
std::mt19937 mt(kSeed);
|
||||
std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
|
||||
PopulateVector(x_vec, mt, dist);
|
||||
PopulateVector(y_vec, mt, dist);
|
||||
PopulateVector(a_mat, mt, dist);
|
||||
PopulateVector(b_mat, mt, dist);
|
||||
PopulateVector(c_mat, mt, dist);
|
||||
PopulateVector(temp, mt, dist);
|
||||
|
||||
// Initializes the tuner for the chosen device
|
||||
cltune::Tuner tuner(args.platform_id, args.device_id);
|
||||
|
|
|
@ -326,42 +326,29 @@ unsigned int GetRandomSeed() {
|
|||
|
||||
// Create a random number generator and populates a vector with samples from a random distribution
|
||||
template <typename T>
|
||||
void PopulateVector(std::vector<T> &vector, const unsigned int seed) {
|
||||
auto lower_limit = static_cast<T>(kTestDataLowerLimit);
|
||||
auto upper_limit = static_cast<T>(kTestDataUpperLimit);
|
||||
std::mt19937 mt(seed);
|
||||
std::uniform_real_distribution<T> dist(lower_limit, upper_limit);
|
||||
for (auto &element: vector) { element = dist(mt); }
|
||||
void PopulateVector(std::vector<T> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||
for (auto &element: vector) { element = static_cast<T>(dist(mt)); }
|
||||
}
|
||||
template void PopulateVector<float>(std::vector<float>&, const unsigned int);
|
||||
template void PopulateVector<double>(std::vector<double>&, const unsigned int);
|
||||
template void PopulateVector<float>(std::vector<float>&, std::mt19937&, std::uniform_real_distribution<double>&);
|
||||
template void PopulateVector<double>(std::vector<double>&, std::mt19937&, std::uniform_real_distribution<double>&);
|
||||
|
||||
// Specialized versions of the above for complex data-types
|
||||
template <>
|
||||
void PopulateVector(std::vector<float2> &vector, const unsigned int seed) {
|
||||
auto lower_limit = static_cast<float>(kTestDataLowerLimit);
|
||||
auto upper_limit = static_cast<float>(kTestDataUpperLimit);
|
||||
std::mt19937 mt(seed);
|
||||
std::uniform_real_distribution<float> dist(lower_limit, upper_limit);
|
||||
for (auto &element: vector) { element.real(dist(mt)); element.imag(dist(mt)); }
|
||||
void PopulateVector(std::vector<float2> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||
for (auto &element: vector) {
|
||||
element.real(static_cast<float>(dist(mt)));
|
||||
element.imag(static_cast<float>(dist(mt)));
|
||||
}
|
||||
}
|
||||
template <>
|
||||
void PopulateVector(std::vector<double2> &vector, const unsigned int seed) {
|
||||
auto lower_limit = static_cast<double>(kTestDataLowerLimit);
|
||||
auto upper_limit = static_cast<double>(kTestDataUpperLimit);
|
||||
std::mt19937 mt(seed);
|
||||
std::uniform_real_distribution<double> dist(lower_limit, upper_limit);
|
||||
void PopulateVector(std::vector<double2> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||
for (auto &element: vector) { element.real(dist(mt)); element.imag(dist(mt)); }
|
||||
}
|
||||
|
||||
// Specialized versions of the above for half-precision
|
||||
template <>
|
||||
void PopulateVector(std::vector<half> &vector, const unsigned int seed) {
|
||||
const auto lower_limit = static_cast<float>(kTestDataLowerLimit);
|
||||
const auto upper_limit = static_cast<float>(kTestDataUpperLimit);
|
||||
std::mt19937 mt(seed);
|
||||
std::uniform_real_distribution<float> dist(lower_limit, upper_limit);
|
||||
for (auto &element: vector) { element = FloatToHalf(dist(mt)); }
|
||||
void PopulateVector(std::vector<half> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||
for (auto &element: vector) { element = FloatToHalf(static_cast<float>(dist(mt))); }
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <string>
|
||||
#include <functional>
|
||||
#include <complex>
|
||||
#include <random>
|
||||
|
||||
#include "clpp11.hpp"
|
||||
#include "clblast.h"
|
||||
|
@ -234,7 +235,7 @@ constexpr auto kTestDataUpperLimit = 2.0;
|
|||
|
||||
// Populates a vector with random data
|
||||
template <typename T>
|
||||
void PopulateVector(std::vector<T> &vector, const unsigned int seed);
|
||||
void PopulateVector(std::vector<T> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist);
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "test/correctness/testblas.hpp"
|
||||
|
||||
namespace clblast {
|
||||
|
@ -88,13 +90,15 @@ TestBlas<T,U>::TestBlas(const std::vector<std::string> &arguments, const bool si
|
|||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
// ===============================================================================================
|
||||
|
|
|
@ -11,13 +11,15 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include "test/performance/client.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "test/performance/client.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
@ -179,13 +181,15 @@ void Client<T,U>::PerformanceTest(Arguments<U> &args, const SetMetric set_sizes)
|
|||
std::vector<T> c_source(args.c_size);
|
||||
std::vector<T> ap_source(args.ap_size);
|
||||
std::vector<T> scalar_source(args.scalar_size);
|
||||
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);
|
||||
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);
|
||||
|
||||
// Creates the matrices on the device
|
||||
auto x_vec = Buffer<T>(context, args.x_size);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "routines/levelx/xinvert.hpp"
|
||||
#include "utilities/utilities.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
|
Loading…
Reference in a new issue