25 #ifndef OPENCLPROGRAM_HH_
26 #define OPENCLPROGRAM_HH_
28 #include <bias_config.h>
29 #include <Base/Common/BIASpragmaStart.hh>
30 #include <OpenCLFramework/clfOpenCL.hh>
31 #include <OpenCLFramework/clfBuffer.hh>
32 #include <OpenCLFramework/clfImage2D.hh>
33 #include <OpenCLFramework/clfImage3D.hh>
35 #include <OpenCLFramework/clfKernelSources.hh>
63 std::string AddSource(std::string filename);
69 void AddSourceFromString(std::string sourceCode);
75 void Build(
int deviceNr = 0, std::string options =
"");
77 std::string GetBuildLog(
int deviceNr = 0);
83 void AddKernel(std::string kernelname);
89 void AddKernels(std::vector<std::string> kernelnames);
98 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
clfBuffer &buffer);
99 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
clfImage2D &buffer);
100 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
clfImage3D &buffer);
103 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_float2 arg);
104 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_float4 arg);
105 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_float8 arg);
106 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_float16 arg);
108 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_int2 arg);
109 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_int4 arg);
110 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_int8 arg);
111 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_int16 arg);
113 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_uint2 arg);
114 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_uint4 arg);
115 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_uint8 arg);
116 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
cl_uint16 arg);
118 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
int arg);
119 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
float arg);
120 void KernelSetArgument(std::string kernelname,
unsigned int argnumber,
float* arg);
122 void KernelSetLocalArgument(std::string kernelname,
unsigned int argnumber,
int size);
124 static void AddSourceToDB(
const std::string fname,
const char *source,
unsigned int &blocks) {
125 kernelsourcesdb_.AddSource(fname, source, blocks);
128 additionalsourcedirs_.push_back(dir);
132 clfProgram(cl::Context *context, std::vector<cl::Device> *devices);
133 cl::Kernel& operator()(std::string kernelname);
138 cl::Context *context_;
139 std::vector<cl::Device> *devices_;
141 cl::Program::Sources sources_;
142 cl::Program program_;
145 bool addWriteMultiplier_;
148 static std::vector<std::string> additionalsourcedirs_;
151 #include <Base/Common/BIASpragmaEnd.hh>
static void AddSourceToDB(const std::string fname, const char *source, unsigned int &blocks)
std::map< std::string, cl::Kernel > cl_kernel_map
static void AddAdditionalSourceDir(const std::string dir)