From 2e9ea1cece1274ccffc69d6be703fbff4a71eb9a Mon Sep 17 00:00:00 2001 From: liaogang Date: Tue, 15 Nov 2016 16:56:19 +0800 Subject: [PATCH] Add Gpu profiler interface --- paddle/cuda/include/hl_cuda.h | 10 ++++++++++ paddle/cuda/include/stub/hl_cuda_stub.h | 4 ++++ paddle/cuda/src/hl_cuda_device.cc | 13 +++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/paddle/cuda/include/hl_cuda.h b/paddle/cuda/include/hl_cuda.h index 3196db67f61..d763658c937 100644 --- a/paddle/cuda/include/hl_cuda.h +++ b/paddle/cuda/include/hl_cuda.h @@ -335,4 +335,14 @@ extern bool hl_cuda_event_is_ready(hl_event_t event); */ extern void hl_device_synchronize(); +/** + * @brief gpu profiler start + */ +extern void hl_profiler_start(); + +/** + * @brief gpu profiler stop + */ +extern void hl_profiler_end(); + #endif // HL_CUDA_H_ diff --git a/paddle/cuda/include/stub/hl_cuda_stub.h b/paddle/cuda/include/stub/hl_cuda_stub.h index 675ac03b0e1..fa7904421d0 100644 --- a/paddle/cuda/include/stub/hl_cuda_stub.h +++ b/paddle/cuda/include/stub/hl_cuda_stub.h @@ -93,4 +93,8 @@ inline bool hl_cuda_event_is_ready(hl_event_t event) { return true; } inline void hl_device_synchronize() {} +inline void hl_profiler_start() {} + +inline void hl_profiler_end() {} + #endif // HL_CUDA_STUB_H_ diff --git a/paddle/cuda/src/hl_cuda_device.cc b/paddle/cuda/src/hl_cuda_device.cc index 3ea2c91bd5a..0f45462adc7 100644 --- a/paddle/cuda/src/hl_cuda_device.cc +++ b/paddle/cuda/src/hl_cuda_device.cc @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include +#include #include #include "hl_cuda.h" #include "hl_cuda.ph" @@ -133,8 +134,9 @@ void* cudart_dso_handle = nullptr; __macro(cudaGetLastError) \ __macro(cudaFuncSetCacheConfig) \ __macro(cudaRuntimeGetVersion) \ - __macro(cudaGetErrorString) - + __macro(cudaGetErrorString) \ + __macro(cudaProfilerStart) \ + __macro(cudaProfilerStop) CUDA_ROUTINE_EACH(DYNAMIC_LOAD_CUDART_WRAP) #undef CUDA_ROUNTINE_EACH @@ -756,3 +758,10 @@ bool hl_cuda_event_is_ready(hl_event_t event) { } return true; } + +void hl_profiler_start() { + CHECK_CUDA(dynload::cudaProfilerStart()); +} +void hl_profiler_end() { + CHECK_CUDA(dynload::cudaProfilerStop()); +} -- GitLab