Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::flow::interface10::opencl_async_msg< T, Factory > Class Template Reference

#include <flow_graph_opencl_node.h>

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

Public Types

typedef T value_type
 
- Public Types inherited from tbb::flow::interface10::async_msg< T >
typedef T async_msg_data_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_msgoperator= (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
 
- Public Member Functions inherited from tbb::flow::interface10::async_msg< T >
 async_msg ()
 
 async_msg (const T &t)
 
 async_msg (T &&t)
 
virtual ~async_msg ()
 
void set (const T &t)
 
void set (T &&t)
 

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

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::interface10::opencl_async_msg< T, Factory >

Definition at line 355 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::interface10::opencl_async_msg< T, Factory >::value_type

Definition at line 357 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::interface10::opencl_async_msg< T, Factory >::opencl_async_msg ( )
inline

Definition at line 359 of file flow_graph_opencl_node.h.

359  : my_callback_flag_ptr( std::make_shared< tbb::atomic<bool>>() ) {
360  my_callback_flag_ptr->store<tbb::relaxed>(false);
361  }
No ordering.
Definition: atomic.h:51
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr

References tbb::flow::interface10::opencl_async_msg< T, Factory >::my_callback_flag_ptr, and tbb::relaxed.

◆ opencl_async_msg() [2/5]

template<typename T, typename Factory = opencl_info::default_opencl_factory>
tbb::flow::interface10::opencl_async_msg< T, Factory >::opencl_async_msg ( const T &  data)
inlineexplicit

◆ opencl_async_msg() [3/5]

template<typename T, typename Factory = opencl_info::default_opencl_factory>
tbb::flow::interface10::opencl_async_msg< T, Factory >::opencl_async_msg ( const T &  data,
cl_event  event 
)
inline

Definition at line 367 of file flow_graph_opencl_node.h.

367  : my_data(data), my_event(event), my_is_event(true), my_callback_flag_ptr( std::make_shared<tbb::atomic<bool>>() ) {
368  my_callback_flag_ptr->store<tbb::relaxed>(false);
369  enforce_cl_retcode( clRetainEvent( my_event ), "Failed to retain an event" );
370  }
No ordering.
Definition: atomic.h:51
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 enforce_cl_retcode(cl_int err, std::string msg)
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr

References tbb::flow::interface10::enforce_cl_retcode(), tbb::flow::interface10::opencl_async_msg< T, Factory >::my_callback_flag_ptr, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_event, 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::interface10::opencl_async_msg< T, Factory >::opencl_async_msg ( const opencl_async_msg< T, Factory > &  dmsg)
inline

Definition at line 390 of file flow_graph_opencl_node.h.

390  : async_msg<T>(dmsg),
391  my_data(dmsg.my_data), my_event(dmsg.my_event), my_is_event( dmsg.my_is_event ),
392  my_callback_flag_ptr(dmsg.my_callback_flag_ptr)
393  {
394  if ( my_is_event )
395  enforce_cl_retcode( clRetainEvent( my_event ), "Failed to retain an event" );
396  }
void enforce_cl_retcode(cl_int err, std::string msg)
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr

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

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::interface10::opencl_async_msg< T, Factory >::opencl_async_msg ( opencl_async_msg< T, Factory > &&  dmsg)
inline

Definition at line 398 of file flow_graph_opencl_node.h.

398  : async_msg<T>(std::move(dmsg)),
399  my_data(std::move(dmsg.my_data)), my_event(dmsg.my_event), my_is_event(dmsg.my_is_event),
400  my_callback_flag_ptr( std::move(dmsg.my_callback_flag_ptr) )
401  {
402  dmsg.my_is_event = false;
403  }
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:309
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr

◆ ~opencl_async_msg()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
tbb::flow::interface10::opencl_async_msg< T, Factory >::~opencl_async_msg ( )
inline

Member Function Documentation

◆ clear_event()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
void tbb::flow::interface10::opencl_async_msg< T, Factory >::clear_event ( ) const
inline

Definition at line 442 of file flow_graph_opencl_node.h.

442  {
443  if ( my_is_event ) {
444  enforce_cl_retcode( clFlush( event_info<cl_command_queue>( my_event, CL_EVENT_COMMAND_QUEUE ) ), "Failed to flush an OpenCL command queue" );
445  enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
446  }
447  my_is_event = false;
448  }
void enforce_cl_retcode(cl_int err, std::string msg)

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

Referenced by tbb::flow::interface10::opencl_async_msg< T, Factory >::finalize(), tbb::flow::interface10::opencl_buffer< T, Factory >::receive(), and tbb::flow::interface10::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::interface10::opencl_async_msg< T, Factory >::data ( bool  wait = true)
inline

Definition at line 372 of file flow_graph_opencl_node.h.

372  {
373  if ( my_is_event && wait ) {
374  enforce_cl_retcode( clWaitForEvents( 1, &my_event ), "Failed to wait for an event" );
375  enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
376  my_is_event = false;
377  }
378  return my_data;
379  }
void enforce_cl_retcode(cl_int err, std::string msg)

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

Referenced by tbb::flow::interface10::opencl_factory< default_device_filter >::enqueue_map_buffer(), tbb::flow::interface10::key_from_message(), tbb::flow::interface10::opencl_async_msg< T, Factory >::operator const T &(), tbb::flow::interface10::opencl_async_msg< T, Factory >::operator T&(), tbb::flow::interface10::opencl_factory< default_device_filter >::process_one_arg(), tbb::flow::interface10::opencl_buffer< T, Factory >::receive(), tbb::flow::interface10::receive_if_memory_object(), tbb::flow::interface10::opencl_async_msg< T, Factory >::register_callback_func(), tbb::flow::interface10::opencl_buffer< T, Factory >::send(), and tbb::flow::interface10::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::interface10::opencl_async_msg< T, Factory >::data ( bool  wait = true) const
inline

Definition at line 381 of file flow_graph_opencl_node.h.

381  {
382  if ( my_is_event && wait ) {
383  enforce_cl_retcode( clWaitForEvents( 1, &my_event ), "Failed to wait for an event" );
384  enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
385  my_is_event = false;
386  }
387  return my_data;
388  }
void enforce_cl_retcode(cl_int err, std::string msg)

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

Here is the call graph for this function:

◆ finalize()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
void tbb::flow::interface10::opencl_async_msg< T, Factory >::finalize ( ) const
inlineprotectedvirtual

Reimplemented from tbb::flow::interface10::async_msg< T >.

Definition at line 462 of file flow_graph_opencl_node.h.

462  {
464  if (! my_callback_flag_ptr->fetch_and_store(true)) {
465  opencl_async_msg a(*this);
466  if (my_is_event) {
467  register_callback([a](const T& t) mutable {
468  a.set(t);
469  });
470  }
471  else {
472  a.set(my_data);
473  }
474  }
475  clear_event();
476  }
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr
std::enable_if< is_memory_object_type< T >::value >::type receive_if_memory_object(const opencl_async_msg< T, Factory > &dmsg)

References tbb::flow::interface10::opencl_async_msg< T, Factory >::clear_event(), tbb::flow::interface10::opencl_async_msg< T, Factory >::my_callback_flag_ptr, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_data, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_is_event, tbb::flow::interface10::receive_if_memory_object(), tbb::flow::interface10::opencl_async_msg< T, Factory >::register_callback(), and tbb::flow::interface10::async_msg< T >::set().

Here is the call graph for this function:

◆ get_event()

◆ operator const T &()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
tbb::flow::interface10::opencl_async_msg< T, Factory >::operator const T & ( ) const
inline

Definition at line 457 of file flow_graph_opencl_node.h.

457 { return data(); }

References tbb::flow::interface10::opencl_async_msg< T, Factory >::data().

Here is the call graph for this function:

◆ operator T&()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
tbb::flow::interface10::opencl_async_msg< T, Factory >::operator T& ( )
inline

Definition at line 456 of file flow_graph_opencl_node.h.

456 { return data(); }

References tbb::flow::interface10::opencl_async_msg< T, Factory >::data().

Here is the call graph for this function:

◆ operator=()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
opencl_async_msg& tbb::flow::interface10::opencl_async_msg< T, Factory >::operator= ( const opencl_async_msg< T, Factory > &  dmsg)
inline

Definition at line 405 of file flow_graph_opencl_node.h.

405  {
407 
408  // Release original event
409  if ( my_is_event )
410  enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to retain an event" );
411 
412  my_data = dmsg.my_data;
413  my_event = dmsg.my_event;
414  my_is_event = dmsg.my_is_event;
415 
416  // Retain copied event
417  if ( my_is_event )
418  enforce_cl_retcode( clRetainEvent( my_event ), "Failed to retain an event" );
419 
420  my_callback_flag_ptr = dmsg.my_callback_flag_ptr;
421  return *this;
422  }
void enforce_cl_retcode(cl_int err, std::string msg)
std::shared_ptr< tbb::atomic< bool > > my_callback_flag_ptr

References tbb::flow::interface10::enforce_cl_retcode(), tbb::flow::interface10::opencl_async_msg< T, Factory >::my_callback_flag_ptr, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_data, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_event, and tbb::flow::interface10::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::interface10::opencl_async_msg< T, Factory >::register_callback ( Callback  c) const
inline

Definition at line 451 of file flow_graph_opencl_node.h.

451  {
452  __TBB_ASSERT( my_is_event, "The OpenCL event is not set" );
453  enforce_cl_retcode( clSetEventCallback( my_event, CL_COMPLETE, register_callback_func, new callback<Callback, T>( c, my_data ) ), "Failed to set an OpenCL callback" );
454  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
void enforce_cl_retcode(cl_int err, std::string msg)
static void CL_CALLBACK register_callback_func(cl_event, cl_int event_command_exec_status, void *data)

References __TBB_ASSERT, tbb::flow::interface10::enforce_cl_retcode(), tbb::flow::interface10::opencl_async_msg< T, Factory >::my_data, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_event, tbb::flow::interface10::opencl_async_msg< T, Factory >::my_is_event, and tbb::flow::interface10::opencl_async_msg< T, Factory >::register_callback_func().

Referenced by tbb::flow::interface10::opencl_async_msg< T, Factory >::finalize().

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

◆ register_callback_func()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
static void CL_CALLBACK tbb::flow::interface10::opencl_async_msg< T, Factory >::register_callback_func ( cl_event  ,
cl_int  event_command_exec_status,
void data 
)
inlinestaticprivate

Definition at line 479 of file flow_graph_opencl_node.h.

479  {
480  tbb::internal::suppress_unused_warning( event_command_exec_status );
481  __TBB_ASSERT( event_command_exec_status == CL_COMPLETE, NULL );
482  __TBB_ASSERT( data, NULL );
483  callback_base *c = static_cast<callback_base*>(data);
484  c->call();
485  delete c;
486  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
void suppress_unused_warning(const T1 &)
Utility template function to prevent "unused" warnings by various compilers.
Definition: tbb_stddef.h:381

References __TBB_ASSERT, tbb::flow::interface10::callback_base::call(), tbb::flow::interface10::opencl_async_msg< T, Factory >::data(), and tbb::internal::suppress_unused_warning().

Referenced by tbb::flow::interface10::opencl_async_msg< T, Factory >::register_callback().

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

◆ set_event()

template<typename T, typename Factory = opencl_info::default_opencl_factory>
void tbb::flow::interface10::opencl_async_msg< T, Factory >::set_event ( cl_event  e) const
inline

Definition at line 430 of file flow_graph_opencl_node.h.

430  {
431  if ( my_is_event ) {
432  cl_command_queue cq = event_info<cl_command_queue>( my_event, CL_EVENT_COMMAND_QUEUE );
433  if ( cq != event_info<cl_command_queue>( e, CL_EVENT_COMMAND_QUEUE ) )
434  enforce_cl_retcode( clFlush( cq ), "Failed to flush an OpenCL command queue" );
435  enforce_cl_retcode( clReleaseEvent( my_event ), "Failed to release an event" );
436  }
437  my_is_event = true;
438  my_event = e;
439  clRetainEvent( my_event );
440  }
void enforce_cl_retcode(cl_int err, std::string msg)

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

Referenced by tbb::flow::interface10::opencl_factory< default_device_filter >::enqueue_map_buffer(), tbb::flow::interface10::opencl_factory< default_device_filter >::enqueue_unmap_buffer(), tbb::flow::interface10::opencl_buffer< T, Factory >::receive(), tbb::flow::interface10::receive_if_memory_object(), tbb::flow::interface10::opencl_buffer< T, Factory >::send(), tbb::flow::interface10::send_if_memory_object(), and tbb::flow::interface10::opencl_factory< default_device_filter >::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::interface10::opencl_async_msg< T, Factory >::my_callback_flag_ptr
private

◆ my_data

◆ my_event

◆ my_is_event


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

Copyright © 2005-2019 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.