Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::flow::interface9::gfx_factory Class Reference

#include <gfx_factory.h>

Collaboration diagram for tbb::flow::interface9::gfx_factory:

Classes

struct  device_type
 
class  dummy_device_selector
 
class  func_wrapper
 

Public Types

template<typename T >
using async_msg_type = gfx_async_msg< T >
 
typedef func_wrapper kernel_type
 
typedef gfx_offload::task_id_type kernel_id_type
 

Public Member Functions

 gfx_factory (tbb::flow::graph &g)
 
template<typename ... Args>
void send_data (device_type, Args &... args)
 
template<typename ... Args>
void send_kernel (device_type, const kernel_type &kernel, Args &... args)
 
template<typename FinalizeFn , typename ... Args>
void finalize (device_type, FinalizeFn fn, Args &...)
 

Private Member Functions

template<typename ... Args>
void callback (kernel_id_type id, Args... args)
 
template<typename T >
void share_data (T)
 
template<typename T >
void share_data (gfx_buffer< T > &buffer)
 
template<typename T >
void send_arg (T)
 
template<typename T >
void send_arg (async_msg_type< T > &msg)
 
void send_data_impl ()
 
template<typename T , typename ... Rest>
void send_data_impl (T &arg, Rest &... args)
 
template<typename T >
void set_kernel_id_arg (kernel_id_type, T)
 
template<typename T >
void set_kernel_id_arg (kernel_id_type id, async_msg_type< T > &msg)
 
void set_kernel_id (kernel_id_type)
 
template<typename T , typename ... Rest>
void set_kernel_id (kernel_id_type id, T &arg, Rest &... args)
 
template<typename T >
void unshare_data (T)
 
template<typename T >
void unshare_data (gfx_buffer< T > &buffer)
 
template<typename T >
void receive_arg (T)
 
template<typename T >
void receive_arg (async_msg_type< T > &msg)
 
void receive_data ()
 
template<typename T , typename ... Rest>
void receive_data (T &arg, Rest &... args)
 

Private Attributes

int current_task_id
 
std::future< voidcallback_future
 
tbb::flow::graphm_graph
 
std::mutex future_assignment_mutex
 
std::mutex task_wait_mutex
 

Detailed Description

Definition at line 160 of file gfx_factory.h.

Member Typedef Documentation

◆ async_msg_type

Definition at line 182 of file gfx_factory.h.

◆ kernel_id_type

◆ kernel_type

Constructor & Destructor Documentation

◆ gfx_factory()

tbb::flow::interface9::gfx_factory::gfx_factory ( tbb::flow::graph g)
inline

Definition at line 192 of file gfx_factory.h.

Member Function Documentation

◆ callback()

template<typename ... Args>
void tbb::flow::interface9::gfx_factory::callback ( kernel_id_type  id,
Args...  args 
)
inlineprivate

Definition at line 241 of file gfx_factory.h.

241  {
242  // Waiting for specific tasks id to complete
243  {
244  std::lock_guard<std::mutex> lock(task_wait_mutex);
245  if (current_task_id < id) {
248  }
249  }
250 
251  // Get result from device and set to async_msg (args)
252  receive_data(args...);
253 
254  // Data was sent to the graph, release the reference
256  }
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 id
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
void release_wait() __TBB_override
Deregisters an external entity that may have interacted with the graph.
Definition: flow_graph.h:782
void wait_for_task(task_id_type id)
Definition: gfx_factory.h:108

References current_task_id, id, lock, m_graph, receive_data(), tbb::flow::interface10::graph::release_wait(), task_wait_mutex, and tbb::flow::interface9::gfx_offload::wait_for_task().

Here is the call graph for this function:

◆ finalize()

template<typename FinalizeFn , typename ... Args>
void tbb::flow::interface9::gfx_factory::finalize ( device_type  ,
FinalizeFn  fn,
Args &  ... 
)
inline

Definition at line 221 of file gfx_factory.h.

221  {
222  fn();
223  }
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

References fn.

◆ receive_arg() [1/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::receive_arg ( )
inlineprivate

Definition at line 322 of file gfx_factory.h.

322 {}

Referenced by receive_data().

Here is the caller graph for this function:

◆ receive_arg() [2/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::receive_arg ( async_msg_type< T > &  msg)
inlineprivate

Definition at line 325 of file gfx_factory.h.

325  {
326  unshare_data(msg.data());
327  msg.set(msg.data());
328  }

References tbb::flow::interface9::gfx_async_msg< T >::data(), tbb::flow::interface10::async_msg< T >::set(), and unshare_data().

Here is the call graph for this function:

◆ receive_data() [1/2]

void tbb::flow::interface9::gfx_factory::receive_data ( )
inlineprivate

Definition at line 330 of file gfx_factory.h.

330 {}

Referenced by callback(), and receive_data().

Here is the caller graph for this function:

◆ receive_data() [2/2]

template<typename T , typename ... Rest>
void tbb::flow::interface9::gfx_factory::receive_data ( T &  arg,
Rest &...  args 
)
inlineprivate

Definition at line 333 of file gfx_factory.h.

333  {
334  receive_arg(arg);
335  receive_data(args...);
336  }

References receive_arg(), and receive_data().

Here is the call graph for this function:

◆ send_arg() [1/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::send_arg ( )
inlineprivate

Definition at line 272 of file gfx_factory.h.

272 {}

Referenced by send_data_impl().

Here is the caller graph for this function:

◆ send_arg() [2/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::send_arg ( async_msg_type< T > &  msg)
inlineprivate

Definition at line 275 of file gfx_factory.h.

275  {
276  share_data(msg.data());
277  }

References tbb::flow::interface9::gfx_async_msg< T >::data(), and share_data().

Here is the call graph for this function:

◆ send_data()

template<typename ... Args>
void tbb::flow::interface9::gfx_factory::send_data ( device_type  ,
Args &...  args 
)
inline

Definition at line 196 of file gfx_factory.h.

196  {
197  send_data_impl(args...);
198  }

References send_data_impl().

Here is the call graph for this function:

◆ send_data_impl() [1/2]

void tbb::flow::interface9::gfx_factory::send_data_impl ( )
inlineprivate

Definition at line 279 of file gfx_factory.h.

279 {}

Referenced by send_data(), and send_data_impl().

Here is the caller graph for this function:

◆ send_data_impl() [2/2]

template<typename T , typename ... Rest>
void tbb::flow::interface9::gfx_factory::send_data_impl ( T &  arg,
Rest &...  args 
)
inlineprivate

Definition at line 282 of file gfx_factory.h.

282  {
283  send_arg(arg);
284  send_data_impl(args...);
285  }

References send_arg(), and send_data_impl().

Here is the call graph for this function:

◆ send_kernel()

template<typename ... Args>
void tbb::flow::interface9::gfx_factory::send_kernel ( device_type  ,
const kernel_type kernel,
Args &...  args 
)
inline

Definition at line 202 of file gfx_factory.h.

202  {
203  // Get packed T data from async_msg<T> and pass it to kernel
204  kernel_id_type id = gfx_offload::run_kernel(kernel, args.data()...);
205 
206  // Set id to async_msg
207  set_kernel_id(id, args...);
208 
209  // Extend the graph lifetime until the callback completion.
211 
212  // Mutex for future assignment
213  std::lock_guard<std::mutex> lock(future_assignment_mutex);
214 
215  // Set callback that waits for kernel execution
216  callback_future = std::async(std::launch::async, &gfx_factory::callback<Args...>, this, id, args...);
217  }
std::future< void > callback_future
Definition: gfx_factory.h:341
gfx_offload::task_id_type kernel_id_type
Definition: gfx_factory.h:190
void set_kernel_id(kernel_id_type)
Definition: gfx_factory.h:299
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
void reserve_wait() __TBB_override
Used to register that an external entity may still interact with the graph.
Definition: flow_graph.h:775
task_id_type run_kernel(F ptr, ArgType &... args)
Definition: gfx_factory.h:98

References callback_future, future_assignment_mutex, lock, m_graph, tbb::flow::interface10::graph::reserve_wait(), tbb::flow::interface9::gfx_offload::run_kernel(), and set_kernel_id().

Here is the call graph for this function:

◆ set_kernel_id() [1/2]

void tbb::flow::interface9::gfx_factory::set_kernel_id ( kernel_id_type  )
inlineprivate

Definition at line 299 of file gfx_factory.h.

299 {}

Referenced by send_kernel(), and set_kernel_id().

Here is the caller graph for this function:

◆ set_kernel_id() [2/2]

template<typename T , typename ... Rest>
void tbb::flow::interface9::gfx_factory::set_kernel_id ( kernel_id_type  id,
T &  arg,
Rest &...  args 
)
inlineprivate

Definition at line 302 of file gfx_factory.h.

302  {
303  set_kernel_id_arg(id, arg);
304  set_kernel_id(id, args...);
305  }
void set_kernel_id(kernel_id_type)
Definition: gfx_factory.h:299
void set_kernel_id_arg(kernel_id_type, T)
Definition: gfx_factory.h:292

References set_kernel_id(), and set_kernel_id_arg().

Here is the call graph for this function:

◆ set_kernel_id_arg() [1/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::set_kernel_id_arg ( kernel_id_type  ,
 
)
inlineprivate

Definition at line 292 of file gfx_factory.h.

292 {}

Referenced by set_kernel_id().

Here is the caller graph for this function:

◆ set_kernel_id_arg() [2/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::set_kernel_id_arg ( kernel_id_type  id,
async_msg_type< T > &  msg 
)
inlineprivate

Definition at line 295 of file gfx_factory.h.

295  {
296  msg.set_task_id(id);
297  }

References tbb::flow::interface9::gfx_async_msg< T >::set_task_id().

Here is the call graph for this function:

◆ share_data() [1/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::share_data ( )
inlineprivate

Definition at line 264 of file gfx_factory.h.

264 {}

Referenced by send_arg().

Here is the caller graph for this function:

◆ share_data() [2/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::share_data ( gfx_buffer< T > &  buffer)
inlineprivate

Definition at line 267 of file gfx_factory.h.

267  {
268  gfx_offload::share(buffer.data(), buffer.size());
269  }
void share(DataType *p, SizeType n)
Definition: gfx_factory.h:81

References tbb::flow::interface9::gfx_buffer< T >::data(), tbb::flow::interface9::gfx_offload::share(), and tbb::flow::interface9::gfx_buffer< T >::size().

Here is the call graph for this function:

◆ unshare_data() [1/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::unshare_data ( )
inlineprivate

Definition at line 314 of file gfx_factory.h.

314 {}

Referenced by receive_arg().

Here is the caller graph for this function:

◆ unshare_data() [2/2]

template<typename T >
void tbb::flow::interface9::gfx_factory::unshare_data ( gfx_buffer< T > &  buffer)
inlineprivate

Definition at line 317 of file gfx_factory.h.

317  {
318  gfx_offload::unshare(buffer.data());
319  }

References tbb::flow::interface9::gfx_buffer< T >::data(), and tbb::flow::interface9::gfx_offload::unshare().

Here is the call graph for this function:

Member Data Documentation

◆ callback_future

std::future<void> tbb::flow::interface9::gfx_factory::callback_future
private

Definition at line 341 of file gfx_factory.h.

Referenced by send_kernel().

◆ current_task_id

int tbb::flow::interface9::gfx_factory::current_task_id
private

Definition at line 339 of file gfx_factory.h.

Referenced by callback().

◆ future_assignment_mutex

std::mutex tbb::flow::interface9::gfx_factory::future_assignment_mutex
private

Definition at line 344 of file gfx_factory.h.

Referenced by send_kernel().

◆ m_graph

tbb::flow::graph& tbb::flow::interface9::gfx_factory::m_graph
private

Definition at line 342 of file gfx_factory.h.

Referenced by callback(), and send_kernel().

◆ task_wait_mutex

std::mutex tbb::flow::interface9::gfx_factory::task_wait_mutex
private

Definition at line 345 of file gfx_factory.h.

Referenced by callback().


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.