From 77325b8974e19188fc5afad1447d4df4f9ae30fd Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Wed, 6 Jul 2016 21:25:55 +0200 Subject: Added an option to the performance clients to do a warm-up run before timing --- CHANGELOG | 1 + src/utilities.hpp | 3 ++- test/performance/client.cpp | 15 ++++++++++++++- test/performance/client.hpp | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b0d70c80..15948bbd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ Development version (next release) - Fixed proper MSVC dllimport and dllexport declarations - Fixed memory leaks related to events not being released - Fixed a bug with a size_t and cl_ulong mismatch on 32-bit systems +- Added an option (-warm_up) to do a warm-up run before timing in the performance clients - Added tuned parameters for various devices (see README) Version 0.8.0 diff --git a/src/utilities.hpp b/src/utilities.hpp index 5a4eef0f..d5efab9f 100644 --- a/src/utilities.hpp +++ b/src/utilities.hpp @@ -80,8 +80,9 @@ constexpr auto kArgComparecblas = "cblas"; constexpr auto kArgStepSize = "step"; constexpr auto kArgNumSteps = "num_steps"; constexpr auto kArgNumRuns = "runs"; +constexpr auto kArgWarmUp = "warm_up"; -// The client-specific arguments in string form +// The test-specific arguments in string form constexpr auto kArgFullTest = "full_test"; constexpr auto kArgVerbose = "verbose"; diff --git a/test/performance/client.cpp b/test/performance/client.cpp index d0068f8b..aaaab22e 100644 --- a/test/performance/client.cpp +++ b/test/performance/client.cpp @@ -113,6 +113,7 @@ Arguments Client::ParseArguments(int argc, char *argv[], const size_t le args.print_help = CheckArgument(argc, argv, help, kArgHelp); args.silent = CheckArgument(argc, argv, help, kArgQuiet); args.no_abbrv = CheckArgument(argc, argv, help, kArgNoAbbreviations); + warm_up_ = CheckArgument(argc, argv, help, kArgWarmUp); // Prints the chosen (or defaulted) arguments to screen. This also serves as the help message, // which is thus always displayed (unless silence is specified). @@ -244,12 +245,24 @@ template double Client::TimedExecution(const size_t num_runs, const Arguments &args, Buffers &buffers, Queue &queue, Routine run_blas, const std::string &library_name) { + auto status = StatusCode::kSuccess; + + // Do an optional warm-up to omit compilation times and initialisations from the measurements + if (warm_up_) { + try { + status = run_blas(args, buffers, queue); + } catch (...) { status = static_cast(kUnknownError); } + if (status != StatusCode::kSuccess) { + throw std::runtime_error(library_name+" error: "+ToString(static_cast(status))); + } + } + + // Start the timed part auto timings = std::vector(num_runs); for (auto &timing: timings) { auto start_time = std::chrono::steady_clock::now(); // Executes the main computation - auto status = StatusCode::kSuccess; try { status = run_blas(args, buffers, queue); } catch (...) { status = static_cast(kUnknownError); } diff --git a/test/performance/client.hpp b/test/performance/client.hpp index 5ff2aec7..6d35fced 100644 --- a/test/performance/client.hpp +++ b/test/performance/client.hpp @@ -82,6 +82,9 @@ class Client { const std::vector options_; const GetMetric get_flops_; const GetMetric get_bytes_; + + // Extra arguments + bool warm_up_; // if enabled, do a warm-up run first before measuring execution time }; // ================================================================================================= -- cgit v1.2.3