2 #include <dlprim/context.hpp> 5 #include <unordered_map> 10 inline int round_up(
int x,
int y)
15 inline cl::NDRange round_range(
int x,cl::NDRange
const &l)
17 size_t const *size = l;
18 x=round_up(x,size[0]);
19 return cl::NDRange(x);
22 inline cl::NDRange round_range(
int x,
int y,cl::NDRange
const &l)
24 size_t const *size = l;
25 x=round_up(x,size[0]);
26 y=round_up(y,size[1]);
27 return cl::NDRange(x,y);
30 inline cl::NDRange round_range(
int x,
int y,
int z,cl::NDRange
const &l)
32 size_t const *size = l;
33 x=round_up(x,size[0]);
34 y=round_up(y,size[1]);
35 z=round_up(z,size[2]);
36 return cl::NDRange(x,y,z);
39 extern std::map<std::string,std::string> kernel_sources;
43 name(n), value(std::to_string(v))
46 Parameter(std::string
const &n,std::string
const &v):
57 static Cache &instance();
59 static void fill_params(std::vector<Parameter> &)
63 template<
typename Val,
typename... Args>
64 static void fill_params(std::vector<Parameter> &p,std::string
const &n,Val v,Args... args)
67 fill_params(p,args...);
70 template<
typename Val,
typename... Args>
71 cl::Program
const &get_program(
Context &ctx,std::string
const &source,std::string
const &n1,Val
const &v1,Args...args)
73 std::vector<Parameter> p;
74 fill_params(p,n1,v1,args...);
75 return get_program(ctx,source,p);
77 cl::Program
const &get_program(
Context &ctx,std::string
const &source)
79 std::vector<Parameter> p;
80 return get_program(ctx,source,p);
82 cl::Program
const &get_program(
Context &ctx,std::string
const &source,std::vector<Parameter>
const ¶ms);
84 template<
typename Val,
typename... Args>
85 static cl::Program build_program(
Context &ctx,std::string
const &source,std::string
const &n1,Val
const &v1,Args...args)
87 std::vector<Parameter> p;
88 fill_params(p,n1,v1,args...);
89 return build_program(ctx,source,p);
91 static cl::Program build_program(
Context &ctx,std::string
const &source)
93 std::vector<Parameter> p;
94 return build_program(ctx,source,p);
96 static cl::Program build_program(
Context &ctx,std::string
const &source,std::vector<Parameter>
const ¶ms);
98 static std::string make_key(
Context &ctx,std::string
const &src,std::vector<Parameter>
const ¶ms);
99 std::unordered_map<std::string,cl::Program> cache_;
This is main object that represent the pair of OpenCL platform and device all other objects use it...
Definition: context.hpp:302
Definition: program_cache.hpp:55
Mane namespace.
Definition: context.hpp:9
Definition: program_cache.hpp:41