-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathworker.h
56 lines (42 loc) · 1.36 KB
/
worker.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
#pragma once
#ifndef GPGPU_WORKER_LIB
#define GPGPU_WORKER_LIB
#include "gpgpu_init.hpp"
#include "device.h"
#include "context.h"
#include "parameter.h"
#include "kernel.h"
#include "command-queue.h"
#include "task-queue.h"
#include <map>
namespace GPGPU_LIB
{
struct Worker
{
std::mutex commonSync;
std::condition_variable cond;
Context context;
CommandQueue queue;
std::map<std::string, Kernel> mapKernelNameToKernel;
std::map<std::string, Parameter> mapParameterNameToParameter;
GPGPUTaskQueue taskQueue;
GPGPUTaskQueue retireQueue;
bool working;
std::map<std::string, double> benchmarks;
std::map<std::string, size_t> works;
std::thread workerThread;
Worker(Device dev);
void work();
void stop();
void runTasks(std::shared_ptr<GPGPUTaskQueue> taskQueueShared, std::string kernelName);
void compile(std::string kernel, std::string kernelName, std::mutex* compileLock);
void mirror(GPGPU::HostParameter* hostParameter);
void setArg(std::string kernelName, std::string parameterName, int parameterIndex);
void waitAllTasks();
void run(std::string kernelName, size_t globalOffset, size_t offset, size_t numGlobal, size_t numLocal, bool multipleKernels = false, std::vector<std::string> kernelNames = std::vector<std::string>());
std::string deviceName();
std::string deviceNameSimple();
~Worker();
};
}
#endif // !GPGPU_WORKER_LIB