17 #ifndef __TBB_flow_graph_opencl_node_H 18 #define __TBB_flow_graph_opencl_node_H 21 #if __TBB_PREVIEW_OPENCL_NODE 34 #include <OpenCL/opencl.h> 42 namespace interface10 {
44 template <
typename DeviceFilter>
47 namespace opencl_info {
51 template <
typename Factory>
55 if (err != CL_SUCCESS) {
56 std::cerr << msg <<
"; error code: " << err << std::endl;
64 enforce_cl_retcode(clGetEventInfo(e, i,
sizeof(res), &res, NULL),
"Failed to get OpenCL event information");
71 enforce_cl_retcode(clGetDeviceInfo(
d, i,
sizeof(res), &res, NULL),
"Failed to get OpenCL device information");
76 inline std::string device_info<std::string>(cl_device_id
d, cl_device_info i) {
78 enforce_cl_retcode(clGetDeviceInfo(
d, i, 0, NULL, &required),
"Failed to get OpenCL device information");
80 char *buff = (
char*)alloca(required);
81 enforce_cl_retcode(clGetDeviceInfo(
d, i, required, buff, NULL),
"Failed to get OpenCL device information");
89 enforce_cl_retcode(clGetPlatformInfo(
p, i,
sizeof(res), &res, NULL),
"Failed to get OpenCL platform information");
94 inline std::string platform_info<std::string>(cl_platform_id
p, cl_platform_info i) {
96 enforce_cl_retcode(clGetPlatformInfo(
p, i, 0, NULL, &required),
"Failed to get OpenCL platform information");
98 char *buff = (
char*)alloca(required);
99 enforce_cl_retcode(clGetPlatformInfo(
p, i, required, buff, NULL),
"Failed to get OpenCL platform information");
120 return platform_info<std::string>(
platform_id(), CL_PLATFORM_PROFILE );
123 return platform_info<std::string>(
platform_id(), CL_PLATFORM_VERSION );
126 return platform_info<std::string>(
platform_id(), CL_PLATFORM_NAME );
129 return platform_info<std::string>(
platform_id(), CL_PLATFORM_VENDOR );
132 return platform_info<std::string>(
platform_id(), CL_PLATFORM_EXTENSIONS );
135 template <
typename T>
136 void info( cl_device_info i, T &t )
const {
145 std::sscanf(
version().c_str(),
"OpenCL %d", &major );
150 std::sscanf(
version().c_str(),
"OpenCL %d.%d", &major, &minor );
156 return (device_info<cl_command_queue_properties>(
my_cl_device_id, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES ) & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) != 0;
159 return (device_info<cl_command_queue_properties>(
my_cl_device_id, CL_DEVICE_QUEUE_PROPERTIES ) & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) != 0;
164 return (device_info<cl_command_queue_properties>(
my_cl_device_id, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES ) & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) != 0;
170 return device_info<std::array<size_t, 3>>(
my_cl_device_id, CL_DEVICE_MAX_WORK_ITEM_SIZES );
173 return device_info<size_t>(
my_cl_device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE );
176 const std::string semi =
";";
178 return (semi +
built_in_kernels() + semi).find( semi + k + semi ) != std::string::npos;
181 return device_info<std::string>(
my_cl_device_id, CL_DEVICE_BUILT_IN_KERNELS );
190 return device_info<cl_bool>(
my_cl_device_id, CL_DEVICE_COMPILER_AVAILABLE );
193 return device_info<cl_bool>(
my_cl_device_id, CL_DEVICE_LINKER_AVAILABLE );
196 const std::string space =
" ";
198 return (space +
extensions() + space).find( space + ext + space ) != std::string::npos;
201 return device_info<std::string>(
my_cl_device_id, CL_DEVICE_EXTENSIONS );
213 return device_info<cl_uint>(
my_cl_device_id, CL_DEVICE_ADDRESS_BITS );
229 return device_info<cl_platform_id>(
my_cl_device_id, CL_DEVICE_PLATFORM );
240 template <
typename DeviceFilter>
242 template <
typename Factory>
244 template <
typename Factory>
248 template <
typename T,
typename Factory>
283 cl_uint num_platforms;
284 enforce_cl_retcode(clGetPlatformIDs(0, NULL, &num_platforms),
"clGetPlatformIDs failed");
286 std::vector<cl_platform_id> platforms(num_platforms);
287 enforce_cl_retcode(clGetPlatformIDs(num_platforms, platforms.data(), NULL),
"clGetPlatformIDs failed");
290 std::vector<cl_platform_id>::iterator platforms_it = platforms.begin();
291 cl_uint num_all_devices = 0;
292 while (platforms_it != platforms.end()) {
293 cl_int err = clGetDeviceIDs(*platforms_it, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
294 if (err == CL_DEVICE_NOT_FOUND) {
295 platforms_it = platforms.erase(platforms_it);
299 num_all_devices += num_devices;
304 std::vector<cl_device_id> devices(num_all_devices);
305 std::vector<cl_device_id>::iterator devices_it = devices.begin();
306 for (
auto p = platforms.begin();
p != platforms.end(); ++
p) {
307 enforce_cl_retcode(clGetDeviceIDs((*
p), CL_DEVICE_TYPE_ALL, (cl_uint)std::distance(devices_it, devices.end()), &*devices_it, &num_devices),
"clGetDeviceIDs failed");
308 devices_it += num_devices;
311 for (
auto d = devices.begin();
d != devices.end(); ++
d) {
315 return opencl_devices;
321 namespace opencl_info {
334 virtual void call() = 0;
338 template <
typename Callback,
typename T>
350 template <
typename T,
typename Factory = opencl_info::default_opencl_factory>
377 const T&
data(
bool wait =
true )
const {
398 dmsg.my_is_event =
false;
428 cl_command_queue cq = event_info<cl_command_queue>(
my_event, CL_EVENT_COMMAND_QUEUE );
429 if ( cq != event_info<cl_command_queue>( e, CL_EVENT_COMMAND_QUEUE ) )
440 enforce_cl_retcode( clFlush( event_info<cl_command_queue>(
my_event, CL_EVENT_COMMAND_QUEUE ) ),
"Failed to flush an OpenCL command queue" );
446 template <
typename Callback>
452 operator T&() {
return data(); }
453 operator const T&()
const {
return data(); }
477 __TBB_ASSERT( event_command_exec_status == CL_COMPLETE, NULL );
491 template <
typename K,
typename T,
typename Factory>
494 const T &t = dmsg.
data(
false );
496 return key_from_message<K, T>( t );
499 template <
typename Factory>
557 my_factory->enqueue_unmap_buffer(device, *
this,
d);
587 template <
typename Factory>
600 cl_buffer_region region = { index,
size };
601 this->
my_cl_mem = clCreateSubBuffer( m, 0, CL_BUFFER_CREATE_TYPE_REGION, ®ion, &err );
610 this->
my_factory->enqueue_map_buffer( device, *
this, dmsg );
614 template <
typename,
typename>
625 template <
typename T,
typename Factory = opencl_info::default_opencl_factory>
628 template <
typename T,
typename Factory = opencl_info::default_opencl_factory>
637 template <access_type a>
639 T* ptr = (T*)
my_impl->get_host_ptr();
644 T*
data()
const {
return &access<read_write>()[0]; }
646 template <access_type a = read_write>
649 template <access_type a = read_write>
671 const cl_event *e =
d.get_event();
678 const cl_event *e =
d.get_event();
698 template <
typename,
typename>
702 template <
typename T,
typename Factory>
711 template <
typename T,
typename Factory>
717 #define is_typedef(type) \ 718 template <typename T> \ 720 template <typename C> \ 721 static std::true_type check( typename C::type* ); \ 722 template <typename C> \ 723 static std::false_type check( ... ); \ 725 static const bool value = decltype(check<T>(0))::value; \ 731 template <
typename T>
733 return t.native_object();
736 template <
typename T>
742 template <
typename T,
typename Factory>
744 const T &t = dmsg.
data(
false );
745 typedef typename T::memory_object_type mem_obj_t;
746 mem_obj_t mem_obj = t.memory_object();
749 mem_obj.send( device,
d );
750 if (
d.get_event() ) dmsg.
set_event( *
d.get_event() );
753 template <
typename T>
755 typedef typename T::memory_object_type mem_obj_t;
756 mem_obj_t mem_obj = t.memory_object();
758 mem_obj.send( device, dmsg );
761 template <
typename T>
765 template <
typename T,
typename Factory>
767 const T &t = dmsg.
data(
false );
768 typedef typename T::memory_object_type mem_obj_t;
769 mem_obj_t mem_obj = t.memory_object();
772 mem_obj.receive(
d );
773 if (
d.get_event() ) dmsg.
set_event( *
d.get_event() );
776 template <
typename T>
784 template <
typename G = std::initializer_list<
int>,
typename L = std::initializer_list<
int>,
785 typename =
typename std::enable_if<!std::is_same<
typename std::decay<G>::type, opencl_range>::value>::type>
786 opencl_range(G&& global_work = std::initializer_list<int>({ 0 }), L&& local_work = std::initializer_list<int>({ 0, 0, 0 })) {
787 auto g_it = global_work.begin();
788 auto l_it = local_work.begin();
791 for (
int s = 0;
s < 3 && g_it != global_work.end(); ++g_it, ++l_it, ++
s) {
792 __TBB_ASSERT(l_it != local_work.end(),
"global_work & local_work must have same size");
806 template <
typename DeviceFilter>
818 std::vector<char> kernel_name;
819 for (
size_t curr_size = 32;; curr_size <<= 1 ) {
820 kernel_name.resize( curr_size <<= 1 );
821 enforce_cl_retcode( clGetKernelInfo( k.
my_cl_kernel, CL_KERNEL_FUNCTION_NAME, curr_size, kernel_name.data(), &ret_size ),
"Failed to get kernel info" );
822 if ( ret_size < curr_size )
break;
845 template <
typename DeviceFilter_>
848 template <
typename Factory>
862 enforce_cl_retcode( clReleaseCommandQueue( (*d).my_cl_command_queue ),
"Failed to release a command queue" );
879 template <
typename Factory>
885 e1 == NULL ? 0 : 1, e1, &e2, &err );
887 dmsg.
data(
false ) = ptr;
893 template <
typename Factory>
899 "Failed to unmap a buffer" );
905 template <
size_t NUM_ARGS,
typename T>
908 enforce_cl_retcode( clSetKernelArg(kernel.my_cl_kernel, place++,
sizeof(
p), &
p),
"Failed to set a kernel argument" );
911 template <
size_t NUM_ARGS,
typename T,
typename F>
913 __TBB_ASSERT((
static_cast<typename std::array<cl_event, NUM_ARGS>::size_type
>(num_events) < events.size()), NULL);
915 const cl_event *
const e = msg.
get_event();
917 events[num_events++] = *e;
923 template <
size_t NUM_ARGS,
typename T,
typename ...Rest>
924 void process_arg_list(
const kernel_type& kernel, std::array<cl_event, NUM_ARGS>& events,
int& num_events,
int& place,
const T& t,
const Rest&... args ) {
929 template <
size_t NUM_ARGS>
932 template <
typename T>
935 template <
typename T,
typename F>
940 template <
typename T,
typename ...Rest>
949 template <
typename ...Args>
951 std::array<cl_event,
sizeof...(Args)> events;
956 const cl_event e =
send_kernel_impl( device, kernel.my_cl_kernel, work_size, num_events, events.data() );
965 template <
typename T,
typename ...Rest>
976 const range_type& work_size, cl_uint num_events, cl_event* event_list ) {
981 for (
s = 1;
s < 3 && g_size[
s] != size_t(-1); ++
s) {}
985 g_offset.data(), g_size.data(), l_size[0] ? l_size.data() : NULL, num_events, num_events ? event_list : NULL, &
event ),
986 "Failed to enqueue a kernel" );
991 template <
typename T>
996 template <
typename T,
typename F>
1000 if ( e_ptr != NULL ) {
1008 template <
typename T,
typename ...Rest>
1027 template<
typename Fn>
1036 __TBB_ASSERT(event_command_exec_status == CL_COMPLETE, NULL);
1038 finalize_fn *
const fn_ptr = static_cast<finalize_fn*>(
data);
1039 __TBB_ASSERT(fn_ptr != NULL,
"Invalid finalize function pointer");
1046 template <
typename FinalizeFn,
typename ...Args>
1052 new finalize_fn_leaf<FinalizeFn>(
fn) ),
"Failed to set a callback" );
1090 enforce_cl_retcode(it->platform_id() == platform_id ? CL_SUCCESS : CL_INVALID_PLATFORM,
"All devices should be in the same platform");
1092 std::vector<cl_device_id> cl_device_ids;
1094 cl_device_ids.push_back((*d).my_cl_device_id);
1097 cl_context_properties context_properties[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id, (cl_context_properties)NULL };
1099 cl_context ctx = clCreateContext(context_properties,
1100 (cl_uint)cl_device_ids.size(),
1101 cl_device_ids.data(),
1106 size_t device_counter = 0;
1108 (*d).my_device_id = device_counter++;
1110 cl_command_queue cq;
1112 if ((*d).major_version() >= 2) {
1113 if ((*d).out_of_order_exec_mode_on_host_present()) {
1114 cl_queue_properties props[] = { CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0 };
1115 cq = clCreateCommandQueueWithProperties(ctx, (*d).my_cl_device_id, props, &err2);
1117 cl_queue_properties props[] = { 0 };
1118 cq = clCreateCommandQueueWithProperties(ctx, (*d).my_cl_device_id, props, &err2);
1123 cl_command_queue_properties props = (*d).out_of_order_exec_mode_on_host_present() ? CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE : 0;
1125 #if __TBB_GCC_WARNING_SUPPRESSION_PRESENT 1126 #pragma GCC diagnostic push 1127 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 1129 #if _MSC_VER || __INTEL_COMPILER 1130 #pragma warning( push ) 1131 #if __INTEL_COMPILER 1132 #pragma warning (disable: 1478) 1134 #pragma warning (disable: 4996) 1137 cq = clCreateCommandQueue(ctx, (*d).my_cl_device_id, props, &err2);
1138 #if _MSC_VER || __INTEL_COMPILER 1139 #pragma warning( pop ) 1141 #if __TBB_GCC_WARNING_SUPPRESSION_PRESENT 1142 #pragma GCC diagnostic pop 1146 (*d).my_cl_command_queue = cq;
1156 template <
typename Factory>
1158 template <
typename Factory>
1160 template <
typename Factory>
1165 namespace opencl_info {
1169 template <
typename Factory>
1172 __TBB_ASSERT(!f.devices().empty(),
"No available devices");
1173 return *(f.devices().begin());
1180 cl_platform_id platform_id = devices.
begin()->platform_id();
1182 if (it->platform_id() == platform_id) {
1207 template <
typename T,
typename Factory>
1217 template <
typename Factory = opencl_info::default_opencl_factory>
1249 cl_kernel kernel = clCreateKernel(
my_cl_program, k.c_str(), &err );
1257 std::ifstream file_descriptor( filepath, std::ifstream::binary );
1258 if ( !file_descriptor.is_open() ) {
1259 std::string str = std::string(
"Could not open file: " ) + filepath;
1260 std::cerr << str << std::endl;
1263 file_descriptor.seekg( 0, file_descriptor.end );
1264 size_t length = size_t( file_descriptor.tellg() );
1265 file_descriptor.seekg( 0, file_descriptor.beg );
1269 file_descriptor.close();
1281 cl_uint num_devices, cl_device_id* device_list,
1284 cl_int err = clBuildProgram( program, num_devices, device_list, options,
1286 if( err == CL_SUCCESS )
1288 std::string str = std::string(
"Failed to build program: " ) +
name;
1289 if ( err == CL_BUILD_PROGRAM_FAILURE ) {
1291 for (
auto d = devices.
begin();
d != devices.
end(); ++
d ) {
1292 std::cerr <<
"Build log for device: " << (*d).name() << std::endl;
1294 cl_int query_err = clGetProgramBuildInfo(
1295 program, (*d).my_cl_device_id, CL_PROGRAM_BUILD_LOG, 0, NULL,
1299 std::vector<char> output;
1300 output.resize( log_size );
1301 query_err = clGetProgramBuildInfo(
1302 program, (*d).my_cl_device_id, CL_PROGRAM_BUILD_LOG,
1303 output.size(), output.data(), NULL );
1305 std::cerr << output.data() << std::endl;
1307 std::cerr <<
"No build log available" << std::endl;
1317 template<
typename Filter>
1319 Filter
filter,
const char* message ) {
1320 for ( cl_uint i = 0; i < num_devices; ++i )
1321 if (
filter(device_list[i]) ) {
1322 device_list[i--] = device_list[--num_devices];
1329 void init(
const std::string& )
const {
1330 cl_uint num_devices;
1332 "Failed to get OpenCL context info" );
1335 cl_device_id *device_list = (cl_device_id *)alloca( num_devices*
sizeof( cl_device_id ) );
1336 enforce_cl_retcode( clGetContextInfo(
my_factory.context(), CL_CONTEXT_DEVICES, num_devices*
sizeof( cl_device_id ), device_list, NULL ),
1337 "Failed to get OpenCL context info" );
1338 const char *options = NULL;
1342 const char *
s[] = { fr.
content() };
1343 const size_t l[] = { fr.
length() };
1348 num_devices, device_list,
1350 return !
d.compiler_available() || !
d.linker_available();
1351 },
"No one device supports building program from sources" );
1354 options, NULL, NULL );
1358 options =
"-x spir";
1361 std::vector<const unsigned char*>
s(
1362 num_devices, reinterpret_cast<const unsigned char*>(fr.
content()) );
1363 std::vector<size_t> l( num_devices, fr.
length() );
1364 std::vector<cl_int> bin_statuses( num_devices, -1 );
1367 device_list, l.data(),
s.data(),
1368 bin_statuses.data(), &err );
1369 if( err != CL_SUCCESS ) {
1370 std::string statuses_str;
1371 for (
auto st = bin_statuses.begin(); st != bin_statuses.end(); ++st) {
1372 statuses_str += std::to_string((*st));
1376 std::string(
", binary_statuses = " ) + statuses_str );
1380 options, NULL, NULL );
1394 template <
typename DeviceFilter>
1397 template <
typename DeviceFilter>
1401 template<typename... Args>
1404 template<typename JP, typename Factory, typename... Ports>
1411 :
base_type( g, kernel, opencl_info::default_device_selector< opencl_info::default_opencl_factory >(), opencl_info::
default_factory() )
1417 :
base_type( g, kernel, opencl_info::default_device_selector <Factory >(), f )
1422 template <
typename DeviceSelector>
1430 template<
typename JP,
typename... Ports>
1437 :
base_type( g, kernel, opencl_info::default_device_selector< opencl_info::default_opencl_factory >(), opencl_info::
default_factory() )
1440 template <
typename DeviceSelector>
1446 template<
typename... Ports>
1447 class opencl_node< tuple<Ports...> > :
public opencl_node < tuple<Ports...>, queueing, opencl_info::default_opencl_factory > {
1453 :
base_type( g, kernel, opencl_info::default_device_selector< opencl_info::default_opencl_factory >(), opencl_info::
default_factory() )
1456 template <
typename DeviceSelector>
1464 using interface10::opencl_node;
1468 using interface10::opencl_buffer;
1469 using interface10::opencl_subbuffer;
1470 using interface10::opencl_device;
1471 using interface10::opencl_device_list;
1472 using interface10::opencl_program;
1474 using interface10::opencl_async_msg;
1475 using interface10::opencl_factory;
1476 using interface10::opencl_range;
1482 #endif // __TBB_flow_graph_opencl_node_H cl_command_queue command_queue() const
opencl_program(const std::string &program_name)
opencl_async_msg & operator=(const opencl_async_msg &dmsg)
std::string built_in_kernels() const
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
opencl_subbuffer< T, Factory > subbuffer(size_t index, size_t size) const
opencl_program(Factory &factory, const std::string &program_name)
const_iterator cend() const
kernel_type get_kernel(const std::string &k) const
opencl_async_msg< void *, Factory > receive(const cl_event *e)
opencl_program(Factory &factory, const char *program_name)
void info(cl_device_info i, T &t) const
cl_event my_sending_event
void call() __TBB_override
friend bool operator==(opencl_device d1, opencl_device d2)
void init(const std::string &) const
device_id_type my_device_id
Represents acquisition of a mutex.
void store(value_type value)
cl_mem get_cl_mem() const
opencl_async_msg(const T &data)
opencl_node< tuple< Ports... >, JP, opencl_info::default_opencl_factory > base_type
void move(tbb_thread &t1, tbb_thread &t2)
iterator< a > end() const
std::enable_if< is_memory_object_type< T >::value >::type receive_if_memory_object(const opencl_async_msg< T, Factory > &dmsg)
opencl_node(graph &g, const kernel_type &kernel, Factory &f)
bool get_event_from_one_arg(cl_event &e, const opencl_async_msg< T, F > &msg)
const opencl_device_list & available_devices()
const opencl_device_list & devices()
opencl_device_list(std::initializer_list< opencl_device > il)
std::string platform_profile() const
file_reader(const std::string &filepath)
opencl_buffer memory_object_type
void const char const char int ITT_FORMAT __itt_group_sync s
base_type::kernel_type kernel_type
opencl_range(G &&global_work=std::initializer_list< int >({ 0 }), L &&local_work=std::initializer_list< int >({ 0, 0, 0 }))
opencl_buffer(Factory &f, cl_mem m, size_t index, size_t size)
default_opencl_factory & default_factory()
size_t max_work_group_size() const
std::shared_ptr< impl_type > my_impl
virtual void map_memory(opencl_device, opencl_async_msg< void *, Factory > &)=0
opencl_program(const opencl_program &src)
opencl_device_list my_devices
container_type my_container
void process_one_arg(const kernel_type &kernel, std::array< cl_event, NUM_ARGS > &events, int &num_events, int &place, const opencl_async_msg< T, F > &msg)
void(CL_CALLBACK * cl_callback_type)(cl_program, void *)
opencl_buffer_impl(size_t size, Factory &f)
tbb::spin_mutex my_sending_lock
Primary template for atomic.
std::string platform_extensions() const
bool built_in_kernel_available(const std::string &k) const
cl_device_id my_cl_device_id
bool my_sending_event_present
opencl_node(graph &g, const kernel_type &kernel, DeviceSelector d)
const_iterator end() const
Base class for types that should not be copied or assigned.
opencl_device(cl_device_id d_id)
opencl_node(graph &g, const kernel_type &kernel)
opencl_node(graph &g, const kernel_type &kernel, DeviceSelector d, Factory &f)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void enqueue_map_buffer(opencl_device device, opencl_buffer_impl< Factory > &buffer, opencl_async_msg< void *, Factory > &dmsg)
tbb::spin_mutex my_devices_mutex
const nd_range_type & local_range() const
cl_platform_id platform_id() const
void send_kernel(opencl_device device, const kernel_type &kernel, const range_type &work_size, Args &... args)
Factory opencl_factory_type
std::vector< opencl_device > container_type
opencl_program_type my_type
opencl_buffer(Factory &f, size_t size)
std::string platform_vendor() const
callback(Callback c, const T &t)
const opencl_buffer & memory_object() const
container_type::const_iterator const_iterator
T event_info(cl_event e, cl_event_info i)
int major_version() const
kernel(const cl_kernel &k, factory_type &f)
static void CL_CALLBACK register_callback_func(cl_event, cl_int event_command_exec_status, void *data)
static void fgt_multiinput_multioutput_node(string_index, void *, void *)
opencl_node< tuple< Ports... >, queueing, opencl_info::default_opencl_factory > base_type
std::enable_if< is_native_object_type< T >::value, typename T::native_object_type >::type get_native_object(const T &t)
cl_event const * get_event() const
std::enable_if< is_memory_object_type< T >::value >::type send_if_memory_object(opencl_device device, opencl_async_msg< T, Factory > &dmsg)
void finalize(opencl_device device, FinalizeFn fn, Args &... args)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size
std::once_flag my_once_flag
A lock that occupies a single byte.
opencl_device_list operator()(const opencl_device_list &devices)
bool extension_available(const std::string &ext) const
Base class for types that should not be assigned.
void update_one_arg(cl_event, T &)
streaming_node< tuple< Ports... >, JP, Factory > base_type
opencl_buffer_impl< Factory > impl_type
std::string platform_name() const
opencl_node(graph &g, const kernel_type &kernel)
std::string platform_version() const
cl_device_id device_id() const
opencl_program(opencl_program_type type, const std::string &program_name)
opencl_device operator()(Factory &f)
opencl_node(graph &g, const kernel_type &kernel)
base_type::kernel_type kernel_type
tbb::atomic< opencl_device::device_id_type > my_curr_device_id
void send(opencl_device device, opencl_async_msg< opencl_buffer, Factory > &dependency) const
void process_one_arg(const kernel_type &kernel, std::array< cl_event, NUM_ARGS > &, int &, int &place, const T &t)
int minor_version() const
T device_info(cl_device_id d, cl_device_info i)
cl_uint address_bits() const
opencl_program(Factory &factory, opencl_program_type type, const std::string &program_name)
bool get_event_from_one_arg(cl_event &, const T &)
bool get_event_from_args(cl_event &)
cl_command_queue my_cl_command_queue
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
cl_kernel get_cl_kernel(const std::string &k) const
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d __itt_event event
void operator()() __TBB_override
std::string version() const
opencl_async_msg(const opencl_async_msg &dmsg)
void add(opencl_device d)
void send_data(opencl_device device, T &t, Rest &... args)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d __itt_event ITT_FORMAT __itt_group_mark d void const wchar_t const wchar_t int ITT_FORMAT __itt_group_sync __itt_group_fsync x void const wchar_t int const wchar_t int int ITT_FORMAT __itt_group_sync __itt_group_fsync x void ITT_FORMAT __itt_group_sync __itt_group_fsync p void ITT_FORMAT __itt_group_sync __itt_group_fsync p void size_t ITT_FORMAT lu no args __itt_obj_prop_t __itt_obj_state_t ITT_FORMAT d const char ITT_FORMAT s __itt_frame ITT_FORMAT p const char const char ITT_FORMAT s __itt_counter ITT_FORMAT p __itt_counter unsigned long long ITT_FORMAT lu const wchar_t ITT_FORMAT S __itt_mark_type const wchar_t ITT_FORMAT S __itt_mark_type const char ITT_FORMAT s __itt_mark_type ITT_FORMAT d __itt_caller ITT_FORMAT p __itt_caller ITT_FORMAT p no args const __itt_domain __itt_clock_domain unsigned long long __itt_id ITT_FORMAT lu const __itt_domain __itt_clock_domain unsigned long long __itt_id __itt_id void * fn
void map_memory(opencl_device device, opencl_async_msg< void *, Factory > &dmsg) __TBB_override
void suppress_unused_warning(const T1 &)
Utility template function to prevent "unused" warnings by various compilers.
const nd_range_type & global_range() const
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
void set_event(cl_event e) const
iterator< a > begin() const
cl_bool available() const
opencl_async_msg(opencl_async_msg &&dmsg)
void process_arg_list(const kernel_type &, std::array< cl_event, NUM_ARGS > &, int &, int &)
Factory * factory() const
bool out_of_order_exec_mode_on_device_present() const
void finalize() const __TBB_override
opencl_factory< DeviceFilter > factory_type
opencl_buffer_impl(cl_mem m, size_t index, size_t size, Factory &f)
opencl_factory & operator=(const opencl_factory &)
std::string vendor() const
opencl_subbuffer(const opencl_buffer< T, Factory > &owner, size_t index, size_t size)
K key_from_message(const T &t)
container_type::size_type size_type
container_type::iterator iterator
virtual void operator()()
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr
opencl_program_builder(Factory &f, const std::string &name, cl_program program, cl_uint num_devices, cl_device_id *device_list, const char *options, cl_callback_type callback, void *user_data)
void register_callback(Callback c) const
opencl_program(opencl_program_type type)
cl_mem native_object() const
friend bool operator==(const opencl_buffer< T, Factory > &lhs, const opencl_buffer< T, Factory > &rhs)
void update_arg_list(cl_event e, T &t, Rest &... args)
opencl_async_msg< void *, Factory > send(opencl_device device, const cl_event *e)
T platform_info(cl_platform_id p, cl_platform_info i)
factory_type & my_factory
std::array< size_t, 3 > max_work_item_sizes() const
bool is_same_context(opencl_device::device_id_type d1, opencl_device::device_id_type d2)
static void CL_CALLBACK finalize_callback(cl_event, cl_int event_command_exec_status, void *data)
cl_device_type type() const
Factory::kernel_type kernel_type
std::string extensions() const
friend default_opencl_factory & default_factory()
opencl_program(Factory &factory, cl_program program)
opencl_buffer< T, Factory > my_owner
cl_mem native_object_type
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
is_typedef(native_object_type)
void const char const char int ITT_FORMAT __itt_group_sync p
void send_data(opencl_device)
bool out_of_order_exec_mode_on_host_present() const
bool init(const opencl_device_list &device_list)
bool get_event_from_args(cl_event &e, const T &t, const Rest &... args)
void process_arg_list(const kernel_type &kernel, std::array< cl_event, NUM_ARGS > &events, int &num_events, int &place, const T &t, const Rest &... args)
std::array< range_index_type, 3 > nd_range_type
The graph related classes and functions.
cl_bool compiler_available() const
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
opencl_device device_type
opencl_device_filter(cl_uint &num_devices, cl_device_id *device_list, Filter filter, const char *message)
base_type::kernel_type kernel_type
const T & data(bool wait=true) const
opencl_node(graph &g, const kernel_type &kernel, DeviceSelector d)
iterator< a > access() const
std::once_flag my_do_once_flag
void update_arg_list(cl_event)
const_iterator begin() const
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
opencl_memory(Factory &f)
opencl_device_list find_available_devices()
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void * data
K key_from_message(const opencl_async_msg< T, Factory > &dmsg)
opencl_device(cl_device_id cl_d_id, device_id_type device_id)
nd_range_type my_local_work_size
default_opencl_factory()=default
void set_command_queue(cl_command_queue cmd_queue)
cl_event send_kernel_impl(opencl_device device, const cl_kernel &kernel, const range_type &work_size, cl_uint num_events, cl_event *event_list)
opencl_async_msg(const T &data, cl_event event)
opencl_program(const char *program_name)
const_iterator cbegin() const
void receive(const opencl_async_msg< opencl_buffer, Factory > &dependency) const
nd_range_type my_global_work_size
T & operator[](ptrdiff_t k)
void update_one_arg(cl_event e, opencl_async_msg< T, F > &msg)
#define __TBB_STATIC_ASSERT(condition, msg)
cl_bool linker_available() const
void enforce_cl_retcode(cl_int err, std::string msg)
void enqueue_unmap_buffer(opencl_device device, opencl_memory< Factory > &memory, opencl_async_msg< void *, Factory > &dmsg)