mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-07-07 12:23:46 +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 <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include <cltune.h>
|
#include <cltune.h>
|
||||||
|
|
||||||
|
@ -77,12 +78,14 @@ void Tuner(int argc, char* argv[]) {
|
||||||
auto b_mat = std::vector<T>(C::GetSizeB(args));
|
auto b_mat = std::vector<T>(C::GetSizeB(args));
|
||||||
auto c_mat = std::vector<T>(C::GetSizeC(args));
|
auto c_mat = std::vector<T>(C::GetSizeC(args));
|
||||||
auto temp = std::vector<T>(C::GetSizeTemp(args));
|
auto temp = std::vector<T>(C::GetSizeTemp(args));
|
||||||
PopulateVector(x_vec, kSeed);
|
std::mt19937 mt(kSeed);
|
||||||
PopulateVector(y_vec, kSeed);
|
std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
|
||||||
PopulateVector(a_mat, kSeed);
|
PopulateVector(x_vec, mt, dist);
|
||||||
PopulateVector(b_mat, kSeed);
|
PopulateVector(y_vec, mt, dist);
|
||||||
PopulateVector(c_mat, kSeed);
|
PopulateVector(a_mat, mt, dist);
|
||||||
PopulateVector(temp, kSeed);
|
PopulateVector(b_mat, mt, dist);
|
||||||
|
PopulateVector(c_mat, mt, dist);
|
||||||
|
PopulateVector(temp, mt, dist);
|
||||||
|
|
||||||
// Initializes the tuner for the chosen device
|
// Initializes the tuner for the chosen device
|
||||||
cltune::Tuner tuner(args.platform_id, args.device_id);
|
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
|
// Create a random number generator and populates a vector with samples from a random distribution
|
||||||
template <typename T>
|
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) {
|
||||||
auto lower_limit = static_cast<T>(kTestDataLowerLimit);
|
for (auto &element: vector) { element = static_cast<T>(dist(mt)); }
|
||||||
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); }
|
|
||||||
}
|
}
|
||||||
template void PopulateVector<float>(std::vector<float>&, const unsigned int);
|
template void PopulateVector<float>(std::vector<float>&, std::mt19937&, std::uniform_real_distribution<double>&);
|
||||||
template void PopulateVector<double>(std::vector<double>&, const unsigned int);
|
template void PopulateVector<double>(std::vector<double>&, std::mt19937&, std::uniform_real_distribution<double>&);
|
||||||
|
|
||||||
// Specialized versions of the above for complex data-types
|
// Specialized versions of the above for complex data-types
|
||||||
template <>
|
template <>
|
||||||
void PopulateVector(std::vector<float2> &vector, const unsigned int seed) {
|
void PopulateVector(std::vector<float2> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||||
auto lower_limit = static_cast<float>(kTestDataLowerLimit);
|
for (auto &element: vector) {
|
||||||
auto upper_limit = static_cast<float>(kTestDataUpperLimit);
|
element.real(static_cast<float>(dist(mt)));
|
||||||
std::mt19937 mt(seed);
|
element.imag(static_cast<float>(dist(mt)));
|
||||||
std::uniform_real_distribution<float> dist(lower_limit, upper_limit);
|
}
|
||||||
for (auto &element: vector) { element.real(dist(mt)); element.imag(dist(mt)); }
|
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
void PopulateVector(std::vector<double2> &vector, const unsigned int seed) {
|
void PopulateVector(std::vector<double2> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||||
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);
|
|
||||||
for (auto &element: vector) { element.real(dist(mt)); element.imag(dist(mt)); }
|
for (auto &element: vector) { element.real(dist(mt)); element.imag(dist(mt)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialized versions of the above for half-precision
|
// Specialized versions of the above for half-precision
|
||||||
template <>
|
template <>
|
||||||
void PopulateVector(std::vector<half> &vector, const unsigned int seed) {
|
void PopulateVector(std::vector<half> &vector, std::mt19937 &mt, std::uniform_real_distribution<double> &dist) {
|
||||||
const auto lower_limit = static_cast<float>(kTestDataLowerLimit);
|
for (auto &element: vector) { element = FloatToHalf(static_cast<float>(dist(mt))); }
|
||||||
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)); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include "clpp11.hpp"
|
#include "clpp11.hpp"
|
||||||
#include "clblast.h"
|
#include "clblast.h"
|
||||||
|
@ -234,7 +235,7 @@ constexpr auto kTestDataUpperLimit = 2.0;
|
||||||
|
|
||||||
// Populates a vector with random data
|
// Populates a vector with random data
|
||||||
template <typename T>
|
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 "utilities/utilities.hpp"
|
||||||
#include "test/routines/level3/xgemm.hpp"
|
#include "test/routines/level3/xgemm.hpp"
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace clblast {
|
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_a = std::vector<T>(args.m * args.k);
|
||||||
auto host_b = std::vector<T>(args.n * args.k);
|
auto host_b = std::vector<T>(args.n * args.k);
|
||||||
auto host_c = std::vector<T>(args.m * args.n);
|
auto host_c = std::vector<T>(args.m * args.n);
|
||||||
PopulateVector(host_a, kSeed);
|
std::mt19937 mt(kSeed);
|
||||||
PopulateVector(host_b, kSeed);
|
std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
|
||||||
PopulateVector(host_c, kSeed);
|
PopulateVector(host_a, mt, dist);
|
||||||
|
PopulateVector(host_b, mt, dist);
|
||||||
|
PopulateVector(host_c, mt, dist);
|
||||||
|
|
||||||
// Copy the matrices to the device
|
// Copy the matrices to the device
|
||||||
auto device_a = Buffer<T>(context, host_a.size());
|
auto device_a = Buffer<T>(context, host_a.size());
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
#include "utilities/utilities.hpp"
|
||||||
#include "test/correctness/testblas.hpp"
|
#include "test/correctness/testblas.hpp"
|
||||||
|
|
||||||
namespace clblast {
|
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);
|
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);
|
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);
|
scalar_source_.resize(std::max(max_mat, max_matvec) + max_offset);
|
||||||
PopulateVector(x_source_, kSeed);
|
std::mt19937 mt(kSeed);
|
||||||
PopulateVector(y_source_, kSeed);
|
std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
|
||||||
PopulateVector(a_source_, kSeed);
|
PopulateVector(x_source_, mt, dist);
|
||||||
PopulateVector(b_source_, kSeed);
|
PopulateVector(y_source_, mt, dist);
|
||||||
PopulateVector(c_source_, kSeed);
|
PopulateVector(a_source_, mt, dist);
|
||||||
PopulateVector(ap_source_, kSeed);
|
PopulateVector(b_source_, mt, dist);
|
||||||
PopulateVector(scalar_source_, kSeed);
|
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 <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
#include "utilities/utilities.hpp"
|
||||||
|
#include "test/performance/client.hpp"
|
||||||
|
|
||||||
namespace clblast {
|
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> c_source(args.c_size);
|
||||||
std::vector<T> ap_source(args.ap_size);
|
std::vector<T> ap_source(args.ap_size);
|
||||||
std::vector<T> scalar_source(args.scalar_size);
|
std::vector<T> scalar_source(args.scalar_size);
|
||||||
PopulateVector(x_source, kSeed);
|
std::mt19937 mt(kSeed);
|
||||||
PopulateVector(y_source, kSeed);
|
std::uniform_real_distribution<double> dist(kTestDataLowerLimit, kTestDataUpperLimit);
|
||||||
PopulateVector(a_source, kSeed);
|
PopulateVector(x_source, mt, dist);
|
||||||
PopulateVector(b_source, kSeed);
|
PopulateVector(y_source, mt, dist);
|
||||||
PopulateVector(c_source, kSeed);
|
PopulateVector(a_source, mt, dist);
|
||||||
PopulateVector(ap_source, kSeed);
|
PopulateVector(b_source, mt, dist);
|
||||||
PopulateVector(scalar_source, kSeed);
|
PopulateVector(c_source, mt, dist);
|
||||||
|
PopulateVector(ap_source, mt, dist);
|
||||||
|
PopulateVector(scalar_source, mt, dist);
|
||||||
|
|
||||||
// Creates the matrices on the device
|
// Creates the matrices on the device
|
||||||
auto x_vec = Buffer<T>(context, args.x_size);
|
auto x_vec = Buffer<T>(context, args.x_size);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "routines/levelx/xinvert.hpp"
|
#include "utilities/utilities.hpp"
|
||||||
|
|
||||||
namespace clblast {
|
namespace clblast {
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
Loading…
Reference in a new issue