2015-01-12 13:20:53 -05:00
|
|
|
#ifndef ATIDLAS_BACKEND_TEMPLATES_REDUCTION_H
|
|
|
|
#define ATIDLAS_BACKEND_TEMPLATES_REDUCTION_H
|
|
|
|
|
2015-01-17 10:48:02 -05:00
|
|
|
#include "atidlas/backend/templates/base.h"
|
2015-01-12 13:20:53 -05:00
|
|
|
|
|
|
|
namespace atidlas
|
|
|
|
{
|
|
|
|
|
2015-01-17 10:48:02 -05:00
|
|
|
struct reduction_parameters : public base::parameters_type
|
2015-01-12 13:20:53 -05:00
|
|
|
{
|
|
|
|
reduction_parameters(unsigned int _simd_width,
|
|
|
|
unsigned int _group_size, unsigned int _num_groups,
|
|
|
|
fetching_policy_type _fetching_policy);
|
|
|
|
unsigned int num_groups;
|
|
|
|
fetching_policy_type fetching_policy;
|
|
|
|
};
|
|
|
|
|
2015-01-17 10:48:02 -05:00
|
|
|
class reduction : public base_impl<reduction, reduction_parameters>
|
2015-01-12 13:20:53 -05:00
|
|
|
{
|
|
|
|
private:
|
2015-01-31 22:01:48 -05:00
|
|
|
unsigned int lmem_usage(array_expressions_container const & array_expressions) const;
|
|
|
|
int check_invalid_impl(cl::Device const &, array_expressions_container const &) const;
|
2015-01-12 13:20:53 -05:00
|
|
|
inline void reduce_1d_local_memory(kernel_generation_stream & stream, unsigned int size, std::vector<mapped_scalar_reduction*> exprs,
|
|
|
|
std::string const & buf_str, std::string const & buf_value_str) const;
|
2015-01-31 22:01:48 -05:00
|
|
|
std::string generate_impl(unsigned int label, const char * type, array_expressions_container const & array_expressions, std::vector<mapping_type> const & mappings, unsigned int simd_width) const;
|
|
|
|
std::vector<std::string> generate_impl(unsigned int label, array_expressions_container const & array_expressions, std::vector<mapping_type> const & mappings) const;
|
2015-01-12 13:20:53 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
reduction(reduction::parameters_type const & parameters, binding_policy_t binding_policy = BIND_ALL_UNIQUE);
|
|
|
|
reduction(unsigned int simd, unsigned int ls, unsigned int ng, fetching_policy_type fetch, binding_policy_t bind = BIND_ALL_UNIQUE);
|
2015-01-31 22:01:48 -05:00
|
|
|
std::vector<int_t> input_sizes(array_expressions_container const & array_expressions);
|
2015-01-12 13:20:53 -05:00
|
|
|
void enqueue(cl::CommandQueue & queue,
|
2015-01-27 16:14:02 -05:00
|
|
|
std::vector<cl_ext::lazy_compiler> & programs,
|
2015-01-12 13:20:53 -05:00
|
|
|
unsigned int label,
|
2015-01-31 22:01:48 -05:00
|
|
|
array_expressions_container const & array_expressions);
|
2015-01-12 13:20:53 -05:00
|
|
|
private:
|
|
|
|
std::vector< cl::Buffer > tmp_;
|
|
|
|
std::vector< cl::Buffer > tmpidx_;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|