From 12354f5e11d59c9544b9a5b7a48de7f2615f79b7 Mon Sep 17 00:00:00 2001 From: Lizzzka007 <gashchuk2011@mail.ru> Date: Tue, 14 Mar 2023 10:40:52 +0300 Subject: [PATCH] cuda upd --- Event.cu | 43 +++++++++++++++++-------------------------- Jikan.h | 4 ++-- JikanDepths.cu | 42 ++++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/Event.cu b/Event.cu index 12245e0..bdfc3ff 100644 --- a/Event.cu +++ b/Event.cu @@ -4,35 +4,26 @@ using namespace std; -void EventData::InitEventsCUDA() -{ - cudaEventCreate(&(this->gpu_start)); - cudaEventCreate(&(this->gpu_end)); +#ifdef INCLUDE_GPU_TIMER + void EventData::InitEventsCUDA() + { + cudaEventCreate(&(this->gpu_start)); + cudaEventCreate(&(this->gpu_end)); - this->ifCUDAinit = true; -} + this->ifCUDAinit = true; + } -void EventData::DeinitEventsCUDA() -{ - if((this->ifCUDAinit)) + void EventData::DeinitEventsCUDA() { - // cudaError_t stat = cudaEventDestroy(this->gpu_start); - // cout << "gpu_star: " << cudaGetErrorString(stat) << endl; + if((this->ifCUDAinit)) + { + // cudaError_t stat = cudaEventDestroy(this->gpu_start); + // cout << "gpu_star: " << cudaGetErrorString(stat) << endl; - // stat = cudaEventDestroy(this->gpu_end); - // cout << "gpu_end: " << cudaGetErrorString(stat) << endl; + // stat = cudaEventDestroy(this->gpu_end); + // cout << "gpu_end: " << cudaGetErrorString(stat) << endl; - this->ifCUDAinit = false; + this->ifCUDAinit = false; + } } -} - -// void EventData::CUDASyncStart() -// { -// cudaEventRecord (this->gpu_start); -// } - -// void EventData::CUDASyncStart() -// { -// cudaEventRecord(this->gpu_end); -// cudaEventSynchronize(this->gpu_end); -// } \ No newline at end of file +#endif \ No newline at end of file diff --git a/Jikan.h b/Jikan.h index 8c9c792..ccb1ad0 100644 --- a/Jikan.h +++ b/Jikan.h @@ -2,8 +2,8 @@ //------------------------- Jikan-config --------------------------------------------- #define TIMER_ON -#define INCLUDE_GPU_TIMER -#define INCLUDE_MPI +// #define INCLUDE_GPU_TIMER +// #define INCLUDE_MPI // #define INCLUDE_OPEN_MP #define SAVE_TIME_SERIES diff --git a/JikanDepths.cu b/JikanDepths.cu index 75335df..6f2f947 100644 --- a/JikanDepths.cu +++ b/JikanDepths.cu @@ -9,26 +9,28 @@ using namespace std; -void Jikan::StartCUDASync(const string& name) -{ - cudaEventRecord ((this->Events)[name].gpu_start); -} +#ifdef INCLUDE_GPU_TIMER + void Jikan::StartCUDASync(const string& name) + { + cudaEventRecord ((this->Events)[name].gpu_start); + } -void Jikan::EndCUDASync(const string& name) -{ - cudaEventRecord((this->Events)[name].gpu_end); - cudaEventSynchronize((this->Events)[name].gpu_end); -} + void Jikan::EndCUDASync(const string& name) + { + cudaEventRecord((this->Events)[name].gpu_end); + cudaEventSynchronize((this->Events)[name].gpu_end); + } -void Jikan::CUDAGetTime(const string& name) -{ - float GPUtime = 0.0; - cudaEventElapsedTime(&GPUtime, (this->Events)[name].gpu_start, (this->Events)[name].gpu_end ); - GPUtime *= 1e-3; - (this->Events)[name].elapsed_time += GPUtime; - (this->Events)[name].count ++; + void Jikan::CUDAGetTime(const string& name) + { + float GPUtime = 0.0; + cudaEventElapsedTime(&GPUtime, (this->Events)[name].gpu_start, (this->Events)[name].gpu_end ); + GPUtime *= 1e-3; + (this->Events)[name].elapsed_time += GPUtime; + (this->Events)[name].count ++; - #ifdef SAVE_TIME_SERIES - (this->Events)[name].time_series.push_back(GPUtime); - #endif -} \ No newline at end of file + #ifdef SAVE_TIME_SERIES + (this->Events)[name].time_series.push_back(GPUtime); + #endif + } +#endif \ No newline at end of file -- GitLab