blob: 0da04c52614178bcdcf9abf24aa54312cfc02ed9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#pragma once
#ifndef NO_CUDA
#include <unordered_map>
#include <boost/timer/timer.hpp>
#include <cuda.h>
#include <driver_types.h>
namespace amunmt {
namespace GPU {
/////////////////////////////////////////////////////////////////////////////////////
void HandleError(cudaError_t err, const char *file, int line );
#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
/////////////////////////////////////////////////////////////////////////////////////
extern std::unordered_map<std::string, boost::timer::cpu_timer> timers;
//#define BEGIN_TIMER(str) {}
//#define PAUSE_TIMER(str) {}
#define BEGIN_TIMER(str) { HANDLE_ERROR( cudaStreamSynchronize(mblas::CudaStreamHandler::GetStream())); timers[str].resume(); }
#define PAUSE_TIMER(str) { HANDLE_ERROR( cudaStreamSynchronize(mblas::CudaStreamHandler::GetStream())); \
timers[str].stop(); }
}
}
#else // NO CUDA
/*
#include <vector>
#include <algorithm>
namespace algo = std;
namespace iteralgo = std;
*/
#endif // NO CUDA
|