-
Notifications
You must be signed in to change notification settings - Fork 1
/
HandleOpenCL.h
101 lines (81 loc) · 2.86 KB
/
HandleOpenCL.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* HandleOpenCL.h
* XclNet
*
* Created by David Higgins on 19/10/2011.
* Copyright 2011 __MyCompanyName__. All rights reserved.
*
*/
#include "GeneralIncludes.h"
#include "cl_LIFNeuron.h"
#include "cl_Synapse.h"
//int job_size;
typedef struct random_struct_marsaglia{
//float value;
unsigned int * d_z;
unsigned int * d_w;
unsigned int * d_jsr;
unsigned int * d_jcong;
} cl_MarsagliaStruct;
// Wrap variables in a struct
typedef struct cl_struct{
int err; // error code returned from api calls
size_t global; // global domain size for our calculation: work size per dimension
size_t local; // local domain size for our calculation: work-group size per dimension
cl_platform_id platform;
cl_device_id device_id; // compute device id
cl_context context; // compute context
cl_command_queue commands; // compute command queue
cl_program program; // compute program
cl_kernel kernel; // compute kernel
cl_mem gauss;
// LIF specific memory streams
cl_mem input_v;
cl_mem input_current;
cl_mem input_spike;
//cl_mem blah;
// Synapse specific memory streams
cl_mem rho;
cl_mem ca;
cl_mem pre_spike;
cl_mem post_spike;
// Random number memory streams
cl_mem d_z;
cl_mem d_w;
cl_mem d_jsr;
cl_mem d_jcong;
int job_size;
} CL;
char* print_cl_errstring(cl_int err);
char* readKernelSource(char * filename);
int getPlatformIDs(CL *cl);
int connectToComputeDevice(CL *cl);
int createComputeContext(CL *cl);
int createCommandQueue(CL *cl);
int createProgram(CL *cl, char ** KernelSource);
int buildProgram(CL *cl);
int createKernel(CL *cl, char * k_name);
//int createIObufs(CL *cl, unsigned int count);
int createLifIObufs(CL *cl);
int createSynIObufs(CL *cl);
int mapLifIObufs(CL *cl, cl_LIFNeuron *lif);
//int enqueueInputBuf(CL *cl, unsigned int count);
int enqueueLifInputBuf(CL *cl, cl_LIFNeuron *lif, cl_MarsagliaStruct *rnd);
int enqueueSynInputBuf(CL *cl, cl_Synapse *syn, SynapseConsts *syn_const, cl_MarsagliaStruct *rnd);
//int setKernelArgs(CL *cl, unsigned int count);
int setLifKernelArgs(CL *cl, cl_LIFNeuron *lif);
int setSynKernelArgs(CL *cl, cl_Synapse *syn, SynapseConsts *syn_const);
int getMaxWorkSize(CL *cl);
//int enqueueKernel(CL *cl, unsigned int count);
int enqueueLifKernel(CL *cl);
int enqueueSynKernel(CL *cl);
int waitForKernel(CL *cl);
//int enqueueOutputBuf(CL *cl, unsigned int count);
int enqueueLifOutputBuf(CL *cl, cl_LIFNeuron *lif, cl_MarsagliaStruct *rnd);
int enqueueSynOutputBuf(CL *cl, cl_Synapse *syn, SynapseConsts *syn_const, cl_MarsagliaStruct *rnd);
//void shutdownKernel(CL *cl);
void shutdownLifKernel(CL *cl);
void shutdownSynKernel(CL *cl);
// My Macro functions
int setupCL(CL *cl);
int makeProgram(CL *cl, char* KernelSource, char* k_name);