From 5ae613519da7eff7150d7383b7fe4dea39a58d51 Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Mon, 24 Oct 2016 13:19:31 +0100 Subject: [PATCH] Change the value of scalar, and specify in a #define --- Stream.h | 7 +++++++ main.cpp | 15 +++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Stream.h b/Stream.h index 671289e..631e305 100644 --- a/Stream.h +++ b/Stream.h @@ -10,6 +10,12 @@ #include #include +// Array values +#define startA (0.1) +#define startB (0.2) +#define startC (0.0) +#define startScalar (0.4) + template class Stream { @@ -35,3 +41,4 @@ class Stream void listDevices(void); std::string getDeviceName(const int); std::string getDeviceDriver(const int); + diff --git a/main.cpp b/main.cpp index 87ff9b2..6a15aa7 100644 --- a/main.cpp +++ b/main.cpp @@ -44,7 +44,6 @@ unsigned int num_times = 100; unsigned int deviceIndex = 0; bool use_float = false; - template void check_solution(const unsigned int ntimes, std::vector& a, std::vector& b, std::vector& c); @@ -85,9 +84,9 @@ void run() std::cout << "Precision: double" << std::endl; // Create host vectors - std::vector a(ARRAY_SIZE, 0.1); - std::vector b(ARRAY_SIZE, 0.2); - std::vector c(ARRAY_SIZE, 0.0); + std::vector a(ARRAY_SIZE, startA); + std::vector b(ARRAY_SIZE, startB); + std::vector c(ARRAY_SIZE, startC); std::streamsize ss = std::cout.precision(); std::cout << std::setprecision(1) << std::fixed << "Array size: " << ARRAY_SIZE*sizeof(T)*1.0E-6 << " MB" @@ -222,11 +221,11 @@ template void check_solution(const unsigned int ntimes, std::vector& a, std::vector& b, std::vector& c) { // Generate correct solution - T goldA = 0.1; - T goldB = 0.2; - T goldC = 0.0; + T goldA = startA; + T goldB = startB; + T goldC = startC; - const T scalar = 0.3; + const T scalar = startScalar; for (unsigned int i = 0; i < ntimes; i++) {