diff --git a/Event.cu b/Event.cu index 12245e01c94b15b9e46b73c1914a94868d410b8a..bdfc3ffd936c8192464274009db59ab23e400880 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 8c9c792a790139d00ff241299c86c89719441ad5..ccb1ad0ed22d29377a42b9c170ff04ddf0816e93 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 75335df92343c25682aeceaaf3b4992df6290b49..6f2f9476d6f1fb70d3309327b0e8b784e531d7d2 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