diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2016-07-06 21:25:55 +0200 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2016-07-06 21:25:55 +0200 |
commit | 77325b8974e19188fc5afad1447d4df4f9ae30fd (patch) | |
tree | ec5c44ea16d704242b0c4b615d382f2b88ae3459 | |
parent | 2d665099ef6b14713beb0cac1bd405073a49e791 (diff) |
Added an option to the performance clients to do a warm-up run before timing
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | src/utilities.hpp | 3 | ||||
-rw-r--r-- | test/performance/client.cpp | 15 | ||||
-rw-r--r-- | test/performance/client.hpp | 3 |
4 files changed, 20 insertions, 2 deletions
@@ -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<U> Client<T,U>::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 <typename T, typename U> double Client<T,U>::TimedExecution(const size_t num_runs, const Arguments<U> &args, Buffers<T> &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<StatusCode>(kUnknownError); } + if (status != StatusCode::kSuccess) { + throw std::runtime_error(library_name+" error: "+ToString(static_cast<int>(status))); + } + } + + // Start the timed part auto timings = std::vector<double>(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<StatusCode>(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<std::string> 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 }; // ================================================================================================= |