diff --git a/src/main.cpp b/src/main.cpp index 42dbe28..d09c3c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,9 @@ const unsigned int ntimes = 10; template void check_solution(const unsigned int ntimes, std::vector& a, std::vector& b, std::vector& c); +template +void run(); + int main(int argc, char *argv[]) { std::cout @@ -27,16 +30,22 @@ int main(int argc, char *argv[]) << "Version: " << VERSION_STRING << std::endl << "Implementation: " << IMPLEMENTATION_STRING << std::endl; + run(); +} + +template +void run() +{ // Create host vectors - std::vector a(ARRAY_SIZE, 1.0); - std::vector b(ARRAY_SIZE, 2.0); - std::vector c(ARRAY_SIZE, 0.0); + std::vector a(ARRAY_SIZE, 1.0); + std::vector b(ARRAY_SIZE, 2.0); + std::vector c(ARRAY_SIZE, 0.0); - Stream *stream; + Stream *stream; // Use the CUDA implementation - stream = new CUDAStream(ARRAY_SIZE); + stream = new CUDAStream(ARRAY_SIZE); stream->write_arrays(a, b, c); @@ -77,7 +86,7 @@ int main(int argc, char *argv[]) // Check solutions stream->read_arrays(a, b, c); - check_solution(ntimes, a, b, c); + check_solution(ntimes, a, b, c); // Display timing results std::cout @@ -91,10 +100,10 @@ int main(int argc, char *argv[]) std::string labels[4] = {"Copy", "Mul", "Add", "Triad"}; size_t sizes[4] = { - 2 * sizeof(double) * ARRAY_SIZE, - 2 * sizeof(double) * ARRAY_SIZE, - 3 * sizeof(double) * ARRAY_SIZE, - 3 * sizeof(double) * ARRAY_SIZE + 2 * sizeof(T) * ARRAY_SIZE, + 2 * sizeof(T) * ARRAY_SIZE, + 3 * sizeof(T) * ARRAY_SIZE, + 3 * sizeof(T) * ARRAY_SIZE }; for (int i = 0; i < 4; i++)