HPXCL
/home/diehl/git/hpxcl/opencl/device.hpp
00001 // Copyright (c)    2013 Martin Stumpf
00002 //
00003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00005 
00006 #pragma once
00007 #ifndef HPX_OPENCL_DEVICE_HPP_
00008 #define HPX_OPENCL_DEVICE_HPP_
00009 
00010 // Default includes
00011 #include <hpx/hpx.hpp>
00012 #include <hpx/config.hpp>
00013 
00014 // Export definitions
00015 #include "export_definitions.hpp"
00016 
00017 // OpenCL
00018 #include "cl_headers.hpp"
00019 
00020 // Forward Declarations
00021 #include "fwd_declarations.hpp"
00022 
00023 // Dependencies
00024 #include "detail/info_type.hpp"
00025 #include "util/generic_buffer.hpp"
00026 
00027 namespace hpx {
00028 namespace opencl {
00029 
00033     class HPX_OPENCL_EXPORT device
00034       : public hpx::components::client_base<device, server::device>
00035     {
00036     
00037         typedef hpx::components::client_base<device, server::device> base_type;
00038 
00039         public:
00040             device(){}
00041 
00042             device(hpx::shared_future<hpx::naming::id_type> const& gid)
00043               : base_type(gid)
00044             {}
00045             
00047             // Exposed Component functionality
00048             // 
00049 
00071             hpx::opencl::buffer
00072             create_buffer(cl_mem_flags flags, std::size_t size) const;
00073 
00086             hpx::opencl::program
00087             create_program_with_source(
00088                 const hpx::serialization::serialize_buffer<char> source) const;
00089             
00100             hpx::opencl::program
00101             create_program_with_binary(
00102                 const hpx::serialization::serialize_buffer<char> binary) const;
00103 
00114             template<cl_device_info Name>
00115             hpx::future<typename detail::device_info<Name>::type>
00116             get_device_info() const {
00117 
00118                 hpx::opencl::util::generic_buffer data = 
00119                     get_device_info_raw(Name);
00120 
00121                 return data.get<typename detail::device_info<Name>::type>();
00122 
00123             }
00124 
00135             template<cl_platform_info Name>
00136             hpx::future<typename detail::platform_info<Name>::type>
00137             get_platform_info() const {
00138 
00139                 hpx::opencl::util::generic_buffer data = 
00140                     get_platform_info_raw(Name);
00141 
00142                 return data.get<typename detail::platform_info<Name>::type>();
00143 
00144             }
00145 
00146         private:
00147             
00149             // Internal Component functionality
00150             // 
00151 
00163             hpx::opencl::util::generic_buffer
00164             get_device_info_raw(cl_device_info info_type) const;
00165 
00177             hpx::opencl::util::generic_buffer
00178             get_platform_info_raw(cl_platform_info info_type) const;
00179 
00180 
00181     };
00182 
00183 }}
00184 
00185 
00186 #endif// HPX_OPENCL_DEVICE_HPP_
00187 
00188             
 All Classes Functions