1 #ifndef bocl_device_h_ 2 #define bocl_device_h_ 3 //: 4 // \file 5 // \brief A wrapper for an cl_device_id, and 6 // \author Andrew Miller acm@computervisiongroup.com 7 // \date March 8, 2011 8 // 9 #include <string> 10 #include <vector> 11 #include <iostream> 12 #include <cstddef> 13 #include <iosfwd> 14 #include "bocl_cl.h" 15 #include "bocl_utils.h" 16 #include "bocl_device_info.h" 17 #ifdef _MSC_VER 18 # include <vcl_msvc_warnings.h> 19 #endif 20 #include <vbl/vbl_ref_count.h> 21 #include <vsl/vsl_binary_io.h> 22 #include <vbl/vbl_smart_ptr.h> 23 24 //: High level wrapper OpenCL Device 25 // Currently the device creates its own context 26 class bocl_device: public vbl_ref_count 27 { 28 public: 29 bocl_device() = default; 30 bocl_device(cl_device_id& device); 31 ~bocl_device() override; 32 33 //: accessors for context/device device_id()34 cl_device_id* device_id() { return &device_; } context()35 cl_context& context() { return context_; } info()36 bocl_device_info& info() { return info_; } 37 //: function which returns a unique string for a device. 38 std::string device_identifier(); 39 private: 40 //:Store a pointer to the cl_device_id 41 cl_device_id device_; 42 43 //: create and store a context 44 cl_context context_; 45 46 //: bocl_device_info for this device 47 bocl_device_info info_; 48 }; 49 50 51 typedef vbl_smart_ptr<bocl_device> bocl_device_sptr; 52 std::ostream& operator <<(std::ostream &s, bocl_device& dev); 53 54 //: Binary write bocl_device to stream 55 void vsl_b_write(vsl_b_ostream& os, bocl_device const& scene); 56 void vsl_b_write(vsl_b_ostream& os, const bocl_device* &p); 57 void vsl_b_write(vsl_b_ostream& os, bocl_device_sptr& sptr); 58 void vsl_b_write(vsl_b_ostream& os, bocl_device_sptr const& sptr); 59 60 //: Binary load bocl_device from stream. 61 void vsl_b_read(vsl_b_istream& is, bocl_device &scene); 62 void vsl_b_read(vsl_b_istream& is, bocl_device* p); 63 void vsl_b_read(vsl_b_istream& is, bocl_device_sptr& sptr); 64 void vsl_b_read(vsl_b_istream& is, bocl_device_sptr const& sptr); 65 66 #endif 67