#ifndef STIM_CUDA_TIMER #define STIM_CUDA_TIMER static cudaEvent_t tStartEvent; static cudaEvent_t tStopEvent; namespace stim{ /// These functions calculate the time between GPU functions in milliseconds static void gpuStartTimer() { //set up timing events cudaEventCreate(&tStartEvent); cudaEventCreate(&tStopEvent); cudaEventRecord(tStartEvent, 0); } static float gpuStopTimer() { cudaEventRecord(tStopEvent, 0); cudaEventSynchronize(tStopEvent); float elapsedTime; cudaEventElapsedTime(&elapsedTime, tStartEvent, tStopEvent); cudaEventDestroy(tStartEvent); cudaEventDestroy(tStopEvent); return elapsedTime; } } //end namespace stim #endif