tbb::flow::interface11::opencl_async_msg< T, Factory > Class Template Reference

`#include <flow_graph_opencl_node.h>`

Inheritance diagram for tbb::flow::interface11::opencl_async_msg< T, Factory >:
Collaboration diagram for tbb::flow::interface11::opencl_async_msg< T, Factory >:

## Public Types

typedef T | value_type

## Public Member Functions

| opencl_async_msg ()
| opencl_async_msg (const T &data)
| opencl_async_msg (const T &data, cl_event event)
T & | data (bool wait=true)
const T & | data (bool wait=true) const
| opencl_async_msg (const opencl_async_msg &dmsg)
| opencl_async_msg (opencl_async_msg &&dmsg)
opencl_async_msg & | operator= (const opencl_async_msg &dmsg)
| ~opencl_async_msg ()
cl_event const * | get_event () const
void | set_event (cl_event e) const
void | clear_event () const
template<typename Callback >
void | register_callback (Callback c) const
| operator T& ()
| operator const T & () const

## Protected Member Functions

void | finalize () const __TBB_override

## Static Private Member Functions

static void CL_CALLBACK | register_callback_func (cl_event, cl_int event_command_exec_status, void *data)

## Private Attributes

T | my_data
cl_event | my_event
bool | my_is_event = false
std::shared_ptr< tbb::atomic< bool > > | my_callback_flag_ptr

## Detailed Description

### template<typename T, typename Factory = opencl_info::default_opencl_factory>
class tbb::flow::interface11::opencl_async_msg< T, Factory >

Definition at line 365 of file flow_graph_opencl_node.h.

## Member Typedef Documentation

## value_type

template<typename T , typename Factory = opencl_info::default_opencl_factory>

typedef T tbb::flow::interface11::opencl_async_msg< T, Factory >::value_type

Definition at line 367 of file flow_graph_opencl_node.h.

## Constructor & Destructor Documentation

## opencl_async_msg() [1/5]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::opencl_async_msg | ( |  | ) |

inline

Definition at line 369 of file flow_graph_opencl_node.h.

: my_callback_flag_ptr( std::make_shared< tbb::atomic<bool>>() ) {
my_callback_flag_ptr->store<tbb::relaxed>(false);
}
tbb::relaxed
@ relaxed
No ordering.
Definition: atomic.h:61
tbb::flow::interface11::opencl_async_msg::my_callback_flag_ptr
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr
Definition: flow_graph_opencl_node.h:502

References tbb::relaxed.

## opencl_async_msg() [2/5]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::opencl_async_msg | ( | const T & | data | ) |

inline explicit

Definition at line 373 of file flow_graph_opencl_node.h.

: my_data(data), my_callback_flag_ptr( std::make_shared<tbb::atomic<bool>>() ) {
my_callback_flag_ptr->store<tbb::relaxed>(false);
}
tbb::flow::interface11::opencl_async_msg::data
T & data(bool wait=true)
Definition: flow_graph_opencl_node.h:382
tbb::flow::interface11::opencl_async_msg::my_data
T my_data
Definition: flow_graph_opencl_node.h:498

References tbb::relaxed.

## opencl_async_msg() [3/5]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::opencl_async_msg | ( | const T & | data,
|  | cl_event | event
| ) |  |

inline

Definition at line 377 of file flow_graph_opencl_node.h.

: my_data(data), my_event(event), my_is_event(true), my_callback_flag_ptr( std::make_shared<tbb::atomic<bool>>() ) {
my_callback_flag_ptr->store<tbb::relaxed>(false);
enforce_cl_retcode( clRetainEvent( my_event ), "Failed to retain an event" );
}
event
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_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
Definition: ittnotify_static.h:217
tbb::flow::interface11::enforce_cl_retcode
void enforce_cl_retcode(cl_int err, std::string msg)
Definition: flow_graph_opencl_node.h:68
tbb::flow::interface11::opencl_async_msg::my_event
cl_event my_event
Definition: flow_graph_opencl_node.h:499
tbb::flow::interface11::opencl_async_msg::my_is_event
bool my_is_event
Definition: flow_graph_opencl_node.h:500

References tbb::flow::interface11::enforce_cl_retcode(), and tbb::relaxed.

Here is the call graph for this function:

## opencl_async_msg() [4/5]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::opencl_async_msg | ( | const opencl_async_msg< T, Factory > & | dmsg | ) |

inline

Definition at line 400 of file flow_graph_opencl_node.h.

: async_msg<T>(dmsg),
my_data(dmsg.my_data), my_event(dmsg.my_event), my_is_event( dmsg.my_is_event ),
my_callback_flag_ptr(dmsg.my_callback_flag_ptr)
{
if ( my_is_event )
enforce_cl_retcode( clRetainEvent( my_event ), "Failed to retain an event" );
}

References tbb::flow::interface11::enforce_cl_retcode().

Here is the call graph for this function:

## opencl_async_msg() [5/5]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::opencl_async_msg | ( | opencl_async_msg< T, Factory > && | dmsg | ) |

inline

Definition at line 408 of file flow_graph_opencl_node.h.

: async_msg<T>(std::move(dmsg)),
my_data(std::move(dmsg.my_data)), my_event(dmsg.my_event), my_is_event(dmsg.my_is_event),
my_callback_flag_ptr( std::move(dmsg.my_callback_flag_ptr) )
{
dmsg.my_is_event = false;
}
tbb::move
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319

## ~opencl_async_msg()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::~opencl_async_msg | ( |  | ) |

inline

Definition at line 434 of file flow_graph_opencl_node.h.

{
if ( my_is_event )
enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
}

References tbb::flow::interface11::enforce_cl_retcode().

Here is the call graph for this function:

## Member Function Documentation

## clear_event()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

void tbb::flow::interface11::opencl_async_msg< T, Factory >::clear_event | ( |  | ) | const

inline

Definition at line 452 of file flow_graph_opencl_node.h.

{
if ( my_is_event ) {
enforce_cl_retcode( clFlush( event_info<cl_command_queue>( my_event, CL_EVENT_COMMAND_QUEUE ) ), "Failed to flush an OpenCL command queue" );
enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
}
my_is_event = false;
}

References tbb::flow::interface11::enforce_cl_retcode().

Referenced by tbb::flow::interface11::opencl_buffer< T, Factory >::receive(), and tbb::flow::interface11::opencl_buffer< T, Factory >::send().

Here is the call graph for this function:
Here is the caller graph for this function:

## data() [1/2]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

T& tbb::flow::interface11::opencl_async_msg< T, Factory >::data | ( | bool | wait = `true` | ) |

inline

Definition at line 382 of file flow_graph_opencl_node.h.

{
if ( my_is_event && wait ) {
enforce_cl_retcode( clWaitForEvents( 1, &my_event ), "Failed to wait for an event" );
enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
my_is_event = false;
}
return my_data;
}

References tbb::flow::interface11::enforce_cl_retcode().

Referenced by tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_map_buffer(), tbb::flow::interface11::key_from_message(), tbb::flow::interface11::opencl_factory< DeviceFilter >::process_one_arg(), tbb::flow::interface11::opencl_buffer< T, Factory >::receive(), tbb::flow::interface11::receive_if_memory_object(), tbb::flow::interface11::opencl_buffer< T, Factory >::send(), and tbb::flow::interface11::send_if_memory_object().

Here is the call graph for this function:
Here is the caller graph for this function:

## data() [2/2]

template<typename T , typename Factory = opencl_info::default_opencl_factory>

const T& tbb::flow::interface11::opencl_async_msg< T, Factory >::data | ( | bool | wait = `true` | ) | const

inline

Definition at line 391 of file flow_graph_opencl_node.h.

{
if ( my_is_event && wait ) {
enforce_cl_retcode( clWaitForEvents( 1, &my_event ), "Failed to wait for an event" );
enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
my_is_event = false;
}
return my_data;
}

References tbb::flow::interface11::enforce_cl_retcode().

Here is the call graph for this function:

## finalize()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

void tbb::flow::interface11::opencl_async_msg< T, Factory >::finalize | ( |  | ) | const

inline protected

Definition at line 472 of file flow_graph_opencl_node.h.

{
receive_if_memory_object(*this);
if (! my_callback_flag_ptr->fetch_and_store(true)) {
opencl_async_msg a(*this);
if (my_is_event) {
register_callback([a](const T& t) mutable {
a.set(t);
});
}
else {
a.set(my_data);
}
}
clear_event();
}
tbb::flow::interface11::receive_if_memory_object
std::enable_if< is_memory_object_type< T >::value >::type receive_if_memory_object(const opencl_async_msg< T, Factory > &dmsg)
Definition: flow_graph_opencl_node.h:783
tbb::flow::interface11::opencl_async_msg::register_callback
void register_callback(Callback c) const
Definition: flow_graph_opencl_node.h:461
tbb::flow::interface11::opencl_async_msg::clear_event
void clear_event() const
Definition: flow_graph_opencl_node.h:452
tbb::flow::interface11::opencl_async_msg::opencl_async_msg
opencl_async_msg()
Definition: flow_graph_opencl_node.h:369

References tbb::flow::interface11::receive_if_memory_object().

Here is the call graph for this function:

## get_event()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

cl_event const* tbb::flow::interface11::opencl_async_msg< T, Factory >::get_event | ( |  | ) | const

inline

Definition at line 439 of file flow_graph_opencl_node.h.

{ return my_is_event ? &my_event : NULL; }

Referenced by tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_map_buffer(), tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_unmap_buffer(), tbb::flow::interface11::opencl_factory< DeviceFilter >::get_event_from_one_arg(), tbb::flow::interface11::opencl_factory< DeviceFilter >::process_one_arg(), tbb::flow::interface11::opencl_buffer< T, Factory >::receive(), tbb::flow::interface11::receive_if_memory_object(), tbb::flow::interface11::opencl_buffer< T, Factory >::send(), and tbb::flow::interface11::send_if_memory_object().

Here is the caller graph for this function:

## operator const T &()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::operator const T & | ( |  | ) | const

inline

Definition at line 467 of file flow_graph_opencl_node.h.

{ return data(); }

References data.

## operator T&()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

tbb::flow::interface11::opencl_async_msg< T, Factory >::operator T& | ( |  | ) |

inline

Definition at line 466 of file flow_graph_opencl_node.h.

{ return data(); }

References data.

## operator=()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

opencl_async_msg& tbb::flow::interface11::opencl_async_msg< T, Factory >::operator= | ( | const opencl_async_msg< T, Factory > & | dmsg | ) |

inline

Definition at line 415 of file flow_graph_opencl_node.h.

{
async_msg<T>::operator =(dmsg);
// Release original event
if ( my_is_event )
enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to retain an event" );
my_data = dmsg.my_data;
my_event = dmsg.my_event;
my_is_event = dmsg.my_is_event;
// Retain copied event
if ( my_is_event )
enforce_cl_retcode( clRetainEvent( my_event ), "Failed to retain an event" );
my_callback_flag_ptr = dmsg.my_callback_flag_ptr;
return *this;
}

References tbb::flow::interface11::enforce_cl_retcode(), tbb::flow::interface11::opencl_async_msg< T, Factory >::my_callback_flag_ptr, tbb::flow::interface11::opencl_async_msg< T, Factory >::my_data, tbb::flow::interface11::opencl_async_msg< T, Factory >::my_event, and tbb::flow::interface11::opencl_async_msg< T, Factory >::my_is_event.

Here is the call graph for this function:

## register_callback()

template<typename T , typename Factory = opencl_info::default_opencl_factory>
template<typename Callback >

void tbb::flow::interface11::opencl_async_msg< T, Factory >::register_callback | ( | Callback | c | ) | const

inline

Definition at line 461 of file flow_graph_opencl_node.h.

{
__TBB_ASSERT( my_is_event, "The OpenCL event is not set" );
enforce_cl_retcode( clSetEventCallback( my_event, CL_COMPLETE, register_callback_func, new callback<Callback, T>( c, my_data ) ), "Failed to set an OpenCL callback" );
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::flow::interface11::opencl_async_msg::register_callback_func
static void CL_CALLBACK register_callback_func(cl_event, cl_int event_command_exec_status, void *data)
Definition: flow_graph_opencl_node.h:489

References __TBB_ASSERT, and tbb::flow::interface11::enforce_cl_retcode().

Here is the call graph for this function:

## register_callback_func()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

static void CL_CALLBACK tbb::flow::interface11::opencl_async_msg< T, Factory >::register_callback_func | ( | cl_event | ,
|  | cl_int | event_command_exec_status,
|  | void * | data
| ) |  |

inline static private

Definition at line 489 of file flow_graph_opencl_node.h.

{
tbb::internal::suppress_unused_warning( event_command_exec_status );
__TBB_ASSERT( event_command_exec_status == CL_COMPLETE, NULL );
__TBB_ASSERT( data, NULL );
callback_base *c = static_cast<callback_base*>(data);
c->call();
delete c;
}
tbb::internal::suppress_unused_warning
void suppress_unused_warning(const T1 &)
Utility template function to prevent "unused" warnings by various compilers.
Definition: tbb_stddef.h:398

References __TBB_ASSERT, tbb::flow::interface11::callback_base::call(), data, and tbb::internal::suppress_unused_warning().

Here is the call graph for this function:

## set_event()

template<typename T , typename Factory = opencl_info::default_opencl_factory>

void tbb::flow::interface11::opencl_async_msg< T, Factory >::set_event | ( | cl_event | e | ) | const

inline

Definition at line 440 of file flow_graph_opencl_node.h.

{
if ( my_is_event ) {
cl_command_queue cq = event_info<cl_command_queue>( my_event, CL_EVENT_COMMAND_QUEUE );
if ( cq != event_info<cl_command_queue>( e, CL_EVENT_COMMAND_QUEUE ) )
enforce_cl_retcode( clFlush( cq ), "Failed to flush an OpenCL command queue" );
enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
}
my_is_event = true;
my_event = e;
clRetainEvent( my_event );
}

References tbb::flow::interface11::enforce_cl_retcode().

Referenced by tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_map_buffer(), tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_unmap_buffer(), tbb::flow::interface11::opencl_buffer< T, Factory >::receive(), tbb::flow::interface11::receive_if_memory_object(), tbb::flow::interface11::opencl_buffer< T, Factory >::send(), tbb::flow::interface11::send_if_memory_object(), and tbb::flow::interface11::opencl_factory< DeviceFilter >::update_one_arg().

Here is the call graph for this function:
Here is the caller graph for this function:

## Member Data Documentation

## my_callback_flag_ptr

template<typename T , typename Factory = opencl_info::default_opencl_factory>

std::shared_ptr< tbb::atomic<bool> > tbb::flow::interface11::opencl_async_msg< T, Factory >::my_callback_flag_ptr

private

Definition at line 502 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_async_msg< T, Factory >::operator=().

## my_data

template<typename T , typename Factory = opencl_info::default_opencl_factory>

T tbb::flow::interface11::opencl_async_msg< T, Factory >::my_data

private

Definition at line 498 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_async_msg< T, Factory >::operator=().

## my_event

template<typename T , typename Factory = opencl_info::default_opencl_factory>

cl_event tbb::flow::interface11::opencl_async_msg< T, Factory >::my_event

mutable private

Definition at line 499 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_async_msg< T, Factory >::operator=().

## my_is_event

template<typename T , typename Factory = opencl_info::default_opencl_factory>

bool tbb::flow::interface11::opencl_async_msg< T, Factory >::my_is_event = false

mutable private

Definition at line 500 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_async_msg< T, Factory >::operator=().

The documentation for this class was generated from the following file:

- flow_graph_opencl_node.h

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.