libspatialSEIR  0.1
Bayesian Spatial SEIR Modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
OCLProvider.hpp
Go to the documentation of this file.
1 #ifndef OCL_PROVIDER_INC
2 #define OCL_PROVIDER_INC
3 
4 #define __CL_ENABLE_EXCEPTIONS
5 
6 #ifndef SPATIALSEIR_INCLUDEFILES
7 #define SPATIALSEIR_INCLUDEFILES
8 
9 #include<math.h>
10 #include<cstring>
11 #include<vector>
12 #endif
13 
14 #ifdef ENABLE_OPEN_CL
15 
16 #include <CL/cl.hpp>
17 #include <ModelContext.hpp>
18 #include <clBLAS.h>
19 
20 namespace SpatialSEIR
21 {
22 
23  struct P_SE_Calculation_KernelData
24  {
25  int workGroupSize;
26  int numWorkGroups;
27  int totalWorkUnits;
28  int globalSize;
29  };
30 
31  struct FC_R_Star_KernelData
32  {
33  int workGroupSize;
34  int numWorkGroups;
35  int totalWorkUnits;
36  int globalSize;
37  double *outCache;
38  };
39 
40  class DeviceContainer
41  {
42  public:
43  DeviceContainer(cl::Device *inDevice, cl::Context *inContext);
44  ~DeviceContainer();
45  cl::Device** device;
46  cl::CommandQueue * commandQueue;
47  };
48 
49  class PlatformContainer
50  {
51  public:
52  PlatformContainer(cl::Platform *inPlatform);
53  ~PlatformContainer();
54 
55  cl::Platform **platform;
56  cl::Context *context;
57  std::vector<DeviceContainer*> *devices;
58  std::vector<std::string> *deviceTypes; // CPU or GPU
59  std::vector<std::string> *deviceNames;
60  std::vector<cl_uint> *doublePrecision;
61  };
62 
63  class OCLProvider
64  {
65  public:
66  //Methods
67  OCLProvider();
68  void setDevice(int platformId, int deviceId);
69  void buildKernels();
70  void printSummary();
71 
72  ~OCLProvider();
73 
74  //Attributes
75  cl::Platform **currentPlatform;
76  cl::Context **currentContext;
77  DeviceContainer **currentDevice;
78  int *isSetup;
79 
80  std::vector<PlatformContainer*> *platforms;
81  cl::Kernel buildProgramForKernel(std::string kernelFile,
82  DeviceContainer *device);
83  std::vector<cl::Program> *programs;
84  FC_R_Star_KernelData* R_star_args;
85  P_SE_Calculation_KernelData* p_se_args;
86 
87  // FC Methods
88  int test();
89  double FC_R_Star(int nLoc,
90  int nTpts,
91  int* S_star,
92  int* E_star,
93  int* R_star,
94  int* S,
95  int* I,
96  int* R,
97  double* p_se,
98  double* p_rs,
99  double* p_ir);
100 
101  void calculateP_SE(ModelContext* ctx);
102 
103  // Kernels
104  cl::Kernel* test_kernel;
105  cl::Kernel* R_Star_kernel;
106  cl::Kernel* p_se_kernel1;
107  cl::Kernel* p_se_kernel2;
108 
109 
110  // Queues
111  cl::CommandQueue* cpuQueue;
112  cl::CommandQueue* gpuQueue;
113  };
114 }
115 
116 #endif
117 
118 
119 #ifndef ENABLE_OPEN_CL
120 
121 namespace SpatialSEIR
122 {
124  {
125  public:
126  //Methods
127  OCLProvider();
128  void setDevice(int platformId, int deviceId);
129  void printSummary();
130 
131  ~OCLProvider();
132 
133  // FC Methods
134  int test();
135  double FC_R_Star(int nLoc,
136  int nTpts,
137  int* S_star,
138  int* E_star,
139  int* R_star,
140  int* S,
141  int* I,
142  int* R,
143  double* p_se,
144  double* p_rs,
145  double* p_ir);
146 
147  void calculateP_SE(ModelContext* ctx);
148  };
149 }
150 
151 
152 #endif
153 
154 #endif
void setDevice(int platformId, int deviceId)
Definition: OCLProvider.cpp:346
double FC_R_Star(int nLoc, int nTpts, int *S_star, int *E_star, int *R_star, int *S, int *I, int *R, double *p_se, double *p_rs, double *p_ir)
Definition: OCLFunctions.cpp:303
~OCLProvider()
Definition: OCLProvider.cpp:379
OCLProvider()
Definition: OCLProvider.cpp:341
Definition: OCLProvider.hpp:123
void calculateP_SE(ModelContext *ctx)
Definition: OCLFunctions.cpp:22
void printSummary()
Definition: OCLProvider.cpp:352
int test()
Definition: OCLFunctions.cpp:463
Definition: ModelContext.hpp:82