From a74e7cee4c594f084ea4ddfc32968edf4f0e7914 Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Mon, 27 Jul 2015 13:44:07 +0100 Subject: [PATCH] Bug fix: sizes array wasn't updating with ARRAY_SIZE argument sizes array was fixed at compile time not run time. Moved the declaration to the correct scope. --- cuda-stream.cu | 13 ++++++------- ocl-stream.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cuda-stream.cu b/cuda-stream.cu index 3549774..684e0ed 100644 --- a/cuda-stream.cu +++ b/cuda-stream.cu @@ -40,13 +40,6 @@ struct badntimes : public std::exception } }; -size_t sizes[4] = { - 2 * DATATYPE_SIZE * ARRAY_SIZE, - 2 * DATATYPE_SIZE * ARRAY_SIZE, - 3 * DATATYPE_SIZE * ARRAY_SIZE, - 3 * DATATYPE_SIZE * ARRAY_SIZE -}; - void check_solution(void* a, void* b, void* c) { // Generate correct solution @@ -279,6 +272,12 @@ int main(int argc, char *argv[]) check_solution(h_a, h_b, h_c); // Crunch results + size_t sizes[4] = { + 2 * DATATYPE_SIZE * ARRAY_SIZE, + 2 * DATATYPE_SIZE * ARRAY_SIZE, + 3 * DATATYPE_SIZE * ARRAY_SIZE, + 3 * DATATYPE_SIZE * ARRAY_SIZE + }; double min[4] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; double max[4] = {0.0, 0.0, 0.0, 0.0}; double avg[4] = {0.0, 0.0, 0.0, 0.0}; diff --git a/ocl-stream.cpp b/ocl-stream.cpp index 1a2d80a..a4e7a67 100644 --- a/ocl-stream.cpp +++ b/ocl-stream.cpp @@ -49,12 +49,6 @@ struct badntimes : public std::exception } }; -size_t sizes[4] = { - 2 * DATATYPE_SIZE * ARRAY_SIZE, - 2 * DATATYPE_SIZE * ARRAY_SIZE, - 3 * DATATYPE_SIZE * ARRAY_SIZE, - 3 * DATATYPE_SIZE * ARRAY_SIZE -}; void check_solution(void* a, void* b, void* c) { @@ -288,6 +282,12 @@ int main(int argc, char *argv[]) check_solution(h_a, h_b, h_c); // Crunch results + size_t sizes[4] = { + 2 * DATATYPE_SIZE * ARRAY_SIZE, + 2 * DATATYPE_SIZE * ARRAY_SIZE, + 3 * DATATYPE_SIZE * ARRAY_SIZE, + 3 * DATATYPE_SIZE * ARRAY_SIZE + }; double min[4] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; double max[4] = {0.0, 0.0, 0.0, 0.0}; double avg[4] = {0.0, 0.0, 0.0, 0.0};