#pragma once #include "common.hpp" namespace saw { /** * Represents a remote Sycl device. */ template<> class device final { private: cl::sycl::queue cmd_queue_; public: device(): cmd_queue_{cl::sycl::default_selector_v, cl::sycl::property_list{cl::sycl::property::queue::enable_profiling()}} {} SAW_FORBID_COPY(device); SAW_FORBID_MOVE(device); /** * Copy data to device */ template error_or>> copy_to_device(const data& host_data){ return data>{host_data}; } template error_or>> allocate_on_device(const data::MetaSchema, Encoding>& host_meta){ return copy_to_device(data{host_meta}); } /** * Copy data to host */ template error_or> copy_to_host(data>& dev_data){ /** data host_data; cmd_queue_.submit([&](cl::sycl::handler& h){ auto acc_buff = dev_data.template access(h); h.copy(acc_buff, &host_data); }); cmd_queue_.wait(); */ cl::sycl::host_accessor result{dev_data.get_handle()}; return result[0]; } /** * Get a reference to the handle */ cl::sycl::queue& get_handle(){ return cmd_queue_; } }; }