forked from BeamMW/opencl-miner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clHost.h
67 lines (51 loc) · 1.27 KB
/
clHost.h
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
// BEAM OpenCL Miner
// OpenCL Host Interface
// Copyright 2018 The Beam Team
// Copyright 2018 Wilke Trei
#include <CL/cl.hpp>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include <cstdlib>
#include <climits>
#include "beamStratum.h"
namespace beamMiner {
struct clCallbackData {
void* host;
uint32_t gpuIndex;
beamStratum::WorkDescription wd;
};
class clHost {
private:
// OpenCL
vector<cl::Platform> platforms;
vector<cl::Context> contexts;
vector<cl::CommandQueue> queues;
vector<cl::Device> devices;
vector<cl::Event> events;
vector<unsigned*> results;
vector< vector<cl::Buffer> > buffers;
vector< vector<cl::Kernel> > kernels;
vector<bool> is3G;
// Statistics
vector<int> solutionCnt;
// To check if a mining thread stoped and we must resume it
vector<bool> paused;
// Callback data
vector<clCallbackData> currentWork;
bool restart = true;
// Functions
void detectPlatFormDevices(vector<int32_t>, bool, bool);
void loadAndCompileKernel(cl::Device &, uint32_t, bool);
void queueKernels(uint32_t, clCallbackData*);
// The connector
beamStratum* stratum;
public:
void setup(beamStratum*, vector<int32_t>, bool, bool);
void startMining();
void callbackFunc(cl_int, void*);
};
}