25 #ifndef OPENCLCONTEXT_HH_
26 #define OPENCLCONTEXT_HH_
29 #include <Base/Common/BIASpragmaStart.hh>
30 #include <OpenCLFramework/clfOpenCL.hh>
31 #include <OpenCLFramework/clfProgram.hh>
32 #include <OpenCLFramework/clfBuffer.hh>
33 #include <OpenCLFramework/clfException.hh>
34 #include <OpenCLFramework/clfDeviceInfo.hh>
35 #include <Base/Debug/Debug.hh>
52 clfContextTypeCPU = 0,
60 clfContext(
bool useGLsharing =
false, clfDeviceType deviceType = clfContextTypeGPU);
80 return new clfBuffer(&context_, &queues_[activeQueue_]);
88 return new clfImage2D(&context_, &queues_[activeQueue_]);
96 return new clfImage3D(&context_, &queues_[activeQueue_]);
100 void PrintDeviceInfo(
unsigned int device=0,
bool verbose =
false,std::ostream& out=std::cout);
102 void PrintPlatformsInfo(std::ostream& out=std::cout);
121 void RunOn1DRange(
clfProgram &program, std::string kernelname,
unsigned int globalrange,
unsigned int localrange=0);
125 void RunOn2DRange(
clfProgram &program, std::string kernelname,
unsigned int globalrangeX,
unsigned int globalrangeY,
unsigned int localrangeX=0,
unsigned int localrangeY=0);
130 void RunOn3DRange(
clfProgram &program, std::string kernelname,
unsigned int globalrangeX,
unsigned int globalrangeY,
unsigned int globalrangeZ,
unsigned int localrangeX=0,
unsigned int localrangeY=0,
unsigned int localrangeZ=0);
138 return devices_.size();
142 return devinfo_[device];
149 void SetActiveDevice(
unsigned int device);
151 unsigned int GetActiveDevice();
153 int DivUp(
const int mod,
int val);
158 static void clnotify(
const char * p1,
const void *p2,
size_t p3,
clfContext *p4);
160 void QueryDeviceInfo_(
unsigned int device = 0);
163 cl::Context context_;
164 std::vector<cl::Device> devices_;
166 std::vector<cl::Platform> platforms_;
168 std::vector<cl::CommandQueue> queues_;
169 unsigned int activeQueue_;
171 std::vector<clfDeviceInfo> devinfo_;
176 #include <Base/Common/BIASpragmaEnd.hh>
clfBuffer * CreateBuffer()
create buffer object
unsigned int GetNumDevices()
clfProgram * CreateProgram()
create program object
clfDeviceInfo GetDeviceInfo(unsigned int device=0)
clfImage2D * CreateImage2D()
create buffer object
clfImage3D * CreateImage3D()
create buffer object