#pragma once #include #include #include "custom_assert.h" using namespace cl; namespace clboost { Platform get_platform(); Device get_gpu_device(const Platform& pf); Context get_context(const Device& dev); CommandQueue make_cq(const Context& ct,const Device& dev); Program make_prog(const std::string& path,const Context& ct,const Device& dev); Program make_prog(const std::string& path, const Context& ct, const Device& dev, bool checker); Event make_event(); template Buffer make_r_buf(const Context& ct, const int& size, std::vector& vec); template Buffer make_r_buf(const Context& ct, const int& size, T* data); template Buffer make_w_buf(const Context& ct, const int& size); Kernel make_kernel(const Program& prog,const std::string& class_name); template void set_args(Kernel& kn, const Args ... args); void enq_q(CommandQueue& q, const Kernel& kernel, Event& this_event, const vector& wait_ev, const int global_size, const int local_size = NULL); void enq_q(CommandQueue& q, const Kernel& kernel, const int global_size, const int local_size = NULL); template void q_read(CommandQueue& q, Buffer& wbuf, const bool check_dirct, const int& size, vector

& data); template void q_read(CommandQueue& q, Buffer& wbuf, const bool check_dirct, const int& size, P* data); //template //void q_read(CommandQueue& q, Buffer& wbuf, const bool check_dirct, const int& size, vector

& data, Event& this_event, const vector& wait_ev); } template Buffer clboost::make_r_buf(const Context& ct, const int& size, std::vector& vec) { return Buffer(ct, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(T) * size, vec.data()); } template Buffer clboost::make_r_buf(const Context& ct, const int& size, T* data) { return Buffer(ct, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(T) * size, data); } template Buffer clboost::make_w_buf(const Context& ct, const int& size) { return Buffer(ct, CL_MEM_WRITE_ONLY, sizeof(W) * size); } template void clboost::set_args(Kernel& kn, const Args ... args) { int index = 0; (ASSERT_EQ(kn.setArg(index++, args),0), ...); ASSERT_UEQ(index, 0); } template void clboost::q_read(CommandQueue& q, Buffer& wbuf, const bool check_dirct, const int& size, vector

& data) { q.enqueueReadBuffer(wbuf, (check_dirct ? CL_TRUE : CL_FALSE), 0, sizeof(P) * size, data.data()); } // //template //void //clboost::q_read(CommandQueue& q, Buffer& wbuf, const bool check_dirct, const int& size, vector

& data, Event& this_event, const vector& wait_ev) //{ // q.enqueueReadBuffer(wbuf, (check_dirct ? CL_TRUE : CL_FALSE), 0, sizeof(P) * size, data.data(), wait_ev, this_event); //} template void clboost::q_read(CommandQueue& q, Buffer& wbuf, const bool check_dirct, const int& size, P* data) { ASSERT_EQ(q.enqueueReadBuffer(wbuf, (check_dirct ? CL_TRUE : CL_FALSE), 0, sizeof(P) * size, data),0); }