#ifndef KERNELS_HPP #define KERNELS_HPP #include #include #include class Kernel { public: using StrategyFunction = std::function; using PreparationFunction = std::function; Kernel(const std::string& name, StrategyFunction strategy_function, PreparationFunction preparation_function); void prepare() const; void execute(int n_threads_or_tasks, int kernel_tripcount) const; private: std::string name_; StrategyFunction strategy_function_; PreparationFunction preparation_function_; }; class KernelRegistry { public: using KernelBuilder = std::function; void register_kernel(const std::string& name, KernelBuilder factory); Kernel load_kernel(const std::string& name) const; std::vector list_available_kernels() const; private: // FIXME: no benchmarking of maps done. The registry is expected to stay // small, though std::unordered_map registry_; }; void initialize_registry(KernelRegistry* registry, std::string strategy_name); #endif // KERNELS_HPP