forked from nvmd/BarsWF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.cpp
77 lines (66 loc) · 1.41 KB
/
global.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//we define common things here
#include "global.h"
#include "perm.h"
#include <iostream>
#include <sstream>
#include <math.h>
#include <assert.h>
#include "algo/algo.h"
using namespace std;
global_data *g = NULL;
__m128i gpu_mask_2_128;
__m128i CONST_MAX128,sse2_nodata,sse2_lendata,target_sse[4];
__m128i md5_const_sse2[64];
void thread_launcher_brook::run()
{
g->a->run_brook(data);
};
#ifdef CUDA
void thread_launcher_cuda::run()
{
g->log->information("CUDA thread start GPU#"+i2a(data->gpu.device_id));
g->a->init_cuda_once(data);
data->avg->reset();//so that we ignore inter-length wait time
g->a->run_cuda(data);
cudaThreadExit();
thread_count_dec();
g->log->information("CUDA thread stop GPU#"+i2a(data->gpu.device_id));
};
#endif CUDA
void thread_count_dec()
{
Poco::ScopedLock<Poco::FastMutex> lock(g->thread_count_mutex);
g->threads_running--;
}
void thread_count_inc()
{
Poco::ScopedLock<Poco::FastMutex> lock(g->thread_count_mutex);
g->threads_running++;
}
string f2a(double value)
{
std::stringstream tmp;
tmp.precision(3);
tmp << fixed << value;
return tmp.str();
}
string i2a(int value)
{
std::stringstream tmp;
tmp << value;
return tmp.str();
}
#ifdef CUDA
void CCU()
{
cudaError_t result = cudaGetLastError();
if(result != cudaSuccess)
{
char msg[512];msg[0]=0;
strcpy_s(msg, 512, "CUDA kernel error: ");
strcat_s(msg, 512, cudaGetErrorString(result));
printf(msg);
return;
}
}
#endif