diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2016-07-06 21:50:12 +0200 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2016-07-06 21:50:12 +0200 |
commit | 27854070b4f9ba1d58ccd7189032e56325506597 (patch) | |
tree | a2e1b393ad06668f00ac7f5701d53df10a97fb4c /src/routines/common.cpp | |
parent | 77325b8974e19188fc5afad1447d4df4f9ae30fd (diff) |
Added a VERBOSE mode to debug performance: now prints details about compilation and kernel execution to screen
Diffstat (limited to 'src/routines/common.cpp')
-rw-r--r-- | src/routines/common.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/routines/common.cpp b/src/routines/common.cpp index c378df28..2e82e04d 100644 --- a/src/routines/common.cpp +++ b/src/routines/common.cpp @@ -12,6 +12,7 @@ // ================================================================================================= #include <vector> +#include <chrono> #include "routines/common.hpp" @@ -44,11 +45,26 @@ StatusCode RunKernel(Kernel &kernel, Queue &queue, const Device &device, const auto local_mem_usage = kernel.LocalMemUsage(device); if (!device.IsLocalMemoryValid(local_mem_usage)) { return StatusCode::kInvalidLocalMemUsage; } + // Prints the name of the kernel to launch in case of debugging in verbose mode + #ifdef VERBOSE + queue.Finish(); + printf("[DEBUG] Running kernel '%s'\n", kernel.GetFunctionName().c_str()); + const auto start_time = std::chrono::steady_clock::now(); + #endif + // Launches the kernel (and checks for launch errors) try { kernel.Launch(queue, global, local, event, waitForEvents); } catch (...) { return StatusCode::kKernelLaunchError; } + // Prints the elapsed execution time in case of debugging in verbose mode + #ifdef VERBOSE + queue.Finish(); + const auto elapsed_time = std::chrono::steady_clock::now() - start_time; + const auto timing = std::chrono::duration<double,std::milli>(elapsed_time).count(); + printf("[DEBUG] Completed kernel in %.2lf ms\n", timing); + #endif + // No errors, normal termination of this function return StatusCode::kSuccess; } |