Change the value of scalar, and specify in a #define

This commit is contained in:
Tom Deakin 2016-10-24 13:19:31 +01:00
parent fe41771bd4
commit 5ae613519d
2 changed files with 14 additions and 8 deletions

View File

@ -10,6 +10,12 @@
#include <vector> #include <vector>
#include <string> #include <string>
// Array values
#define startA (0.1)
#define startB (0.2)
#define startC (0.0)
#define startScalar (0.4)
template <class T> template <class T>
class Stream class Stream
{ {
@ -35,3 +41,4 @@ class Stream
void listDevices(void); void listDevices(void);
std::string getDeviceName(const int); std::string getDeviceName(const int);
std::string getDeviceDriver(const int); std::string getDeviceDriver(const int);

View File

@ -44,7 +44,6 @@ unsigned int num_times = 100;
unsigned int deviceIndex = 0; unsigned int deviceIndex = 0;
bool use_float = false; bool use_float = false;
template <typename T> template <typename T>
void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>& b, std::vector<T>& c); void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>& b, std::vector<T>& c);
@ -85,9 +84,9 @@ void run()
std::cout << "Precision: double" << std::endl; std::cout << "Precision: double" << std::endl;
// Create host vectors // Create host vectors
std::vector<T> a(ARRAY_SIZE, 0.1); std::vector<T> a(ARRAY_SIZE, startA);
std::vector<T> b(ARRAY_SIZE, 0.2); std::vector<T> b(ARRAY_SIZE, startB);
std::vector<T> c(ARRAY_SIZE, 0.0); std::vector<T> c(ARRAY_SIZE, startC);
std::streamsize ss = std::cout.precision(); std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(1) << std::fixed std::cout << std::setprecision(1) << std::fixed
<< "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB" << "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB"
@ -222,11 +221,11 @@ template <typename T>
void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>& b, std::vector<T>& c)
{ {
// Generate correct solution // Generate correct solution
T goldA = 0.1; T goldA = startA;
T goldB = 0.2; T goldB = startB;
T goldC = 0.0; T goldC = startC;
const T scalar = 0.3; const T scalar = startScalar;
for (unsigned int i = 0; i < ntimes; i++) for (unsigned int i = 0; i < ntimes; i++)
{ {