24 #ifndef __ARM_COMPUTE_CLKERNELLIBRARY_H__ 25 #define __ARM_COMPUTE_CLKERNELLIBRARY_H__ 39 using StringSet = std::set<std::string>;
77 const StringSet &
options()
const;
80 StringSet _build_opts;
94 Program(cl::Context context, std::string name, std::string source);
102 Program(cl::Context context, cl::Device device, std::string name, std::vector<unsigned char> binary);
123 explicit operator cl::Program()
const;
125 static bool build(
const cl::Program &program,
const std::string &build_options =
"");
132 cl::Program build(
const std::string &build_options =
"")
const;
135 cl::Context _context;
140 std::vector<unsigned char> _binary;
162 Kernel(std::string name,
const cl::Program &program);
175 explicit operator cl::Kernel()
const 188 using StringSet = std::set<std::string>;
209 void init(std::string kernel_path =
".", cl::Context context = cl::Context::getDefault(), cl::Device device = cl::Device::getDefault())
211 _kernel_path = std::move(kernel_path);
212 _context = std::move(context);
213 _device = std::move(device);
221 _kernel_path = kernel_path;
233 std::string get_program_source(
const std::string &program_name);
243 _context = std::move(context);
245 const auto cl_devices = _context.getInfo<CL_CONTEXT_DEVICES>();
247 if(cl_devices.empty())
249 _device = cl::Device();
253 _device = cl_devices[0];
262 _device = std::move(device);
271 Kernel create_kernel(
const std::string &kernel_name,
const StringSet &build_options_set = {})
const;
283 size_t max_local_workgroup_size(
const cl::Kernel &kernel)
const;
287 cl::NDRange default_ndrange()
const;
293 _programs_map.clear();
294 _built_programs_map.clear();
302 const Program &load_program(
const std::string &program_name)
const;
309 std::string stringify_set(
const StringSet &s)
const;
311 cl::Context _context;
313 std::string _kernel_path;
314 mutable std::map<std::string, const Program> _programs_map;
315 mutable std::map<std::string, cl::Program> _built_programs_map;
316 static const std::map<std::string, std::string> _kernel_program_map;
317 static const std::map<std::string, std::string> _program_source_map;
void init(std::string kernel_path=".", cl::Context context=cl::Context::getDefault(), cl::Device device=cl::Device::getDefault())
Initialises the kernel library.
void set_kernel_path(const std::string &kernel_path)
Sets the path that the kernels reside in.
std::string name() const
Returns program name.
CLBuildOptions()
Default constructor.
void set_context(cl::Context context)
Sets the CL context used to create programs.
This file contains all available output stages for GEMMLowp on OpenCL.
void add_option(std::string option)
Adds option to the existing build option list.
void add_options(const StringSet &options)
Appends given build options to the current's objects options.
void clear_programs_cache()
Clear the library's cache of binary programs.
void set_device(cl::Device device)
Sets the CL device for which the programs are created.
const StringSet & options() const
Gets the current options list set.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
std::unique_ptr< Kernel > create_kernel()
Helper function to create and return a unique_ptr pointed to a CL kernel object.
std::string get_kernel_path()
Gets the path that the kernels reside in.
std::string name() const
Returns kernel name.
void add_options_if(bool cond, const StringSet &options)
Appends given build options to the current's objects options if a given condition is true...
void add_option_if_else(bool cond, std::string option_true, std::string option_false)
Adds first option if condition is true else the second one.