tbb::flow::interface11::opencl_memory< Factory > Class Template Referenceabstract

`#include <flow_graph_opencl_node.h>`

Inheritance diagram for tbb::flow::interface11::opencl_memory< Factory >:
Collaboration diagram for tbb::flow::interface11::opencl_memory< Factory >:

## Public Member Functions

| opencl_memory ()
| opencl_memory (Factory &f)
virtual | ~opencl_memory ()
cl_mem | get_cl_mem () const
void * | get_host_ptr ()
Factory * | factory () const
opencl_async_msg< void *, Factory > | receive (const cl_event *e)
opencl_async_msg< void *, Factory > | send (opencl_device device, const cl_event *e)
virtual void | map_memory (opencl_device, opencl_async_msg< void *, Factory > &)=0

## Protected Attributes

cl_mem | my_cl_mem
tbb::atomic< opencl_device::device_id_type > | my_curr_device_id
void * | my_host_ptr
Factory * | my_factory
tbb::spin_mutex | my_sending_lock
bool | my_sending_event_present
cl_event | my_sending_event

## Detailed Description

### template<typename Factory>
class tbb::flow::interface11::opencl_memory< Factory >

Definition at line 514 of file flow_graph_opencl_node.h.

## Constructor & Destructor Documentation

## opencl_memory() [1/2]

template<typename Factory >

tbb::flow::interface11::opencl_memory< Factory >::opencl_memory | ( |  | ) |

inline

Definition at line 516 of file flow_graph_opencl_node.h.

{}

## opencl_memory() [2/2]

template<typename Factory >

tbb::flow::interface11::opencl_memory< Factory >::opencl_memory | ( | Factory & | f | ) |

inline

Definition at line 517 of file flow_graph_opencl_node.h.

: my_host_ptr( NULL ), my_factory( &f ), my_sending_event_present( false ) {
my_curr_device_id = my_factory->devices().begin()->my_device_id;
}
tbb::flow::interface11::opencl_memory::my_sending_event_present
bool my_sending_event_present
Definition: flow_graph_opencl_node.h:597
tbb::flow::interface11::opencl_memory::my_curr_device_id
tbb::atomic< opencl_device::device_id_type > my_curr_device_id
Definition: flow_graph_opencl_node.h:592
tbb::flow::interface11::opencl_memory::my_host_ptr
void * my_host_ptr
Definition: flow_graph_opencl_node.h:593
tbb::flow::interface11::opencl_memory::my_factory
Factory * my_factory
Definition: flow_graph_opencl_node.h:594

References tbb::flow::interface11::opencl_memory< Factory >::my_curr_device_id, and tbb::flow::interface11::opencl_memory< Factory >::my_factory.

## ~opencl_memory()

template<typename Factory >

virtual tbb::flow::interface11::opencl_memory< Factory >::~opencl_memory | ( |  | ) |

inline virtual

Definition at line 521 of file flow_graph_opencl_node.h.

{
if ( my_sending_event_present ) enforce_cl_retcode( clReleaseEvent( my_sending_event ), "Failed to release an event for the OpenCL buffer" );
enforce_cl_retcode( clReleaseMemObject( my_cl_mem ), "Failed to release an memory object" );
}
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_memory::my_cl_mem
cl_mem my_cl_mem
Definition: flow_graph_opencl_node.h:591
tbb::flow::interface11::opencl_memory::my_sending_event
cl_event my_sending_event
Definition: flow_graph_opencl_node.h:598

References tbb::flow::interface11::enforce_cl_retcode(), tbb::flow::interface11::opencl_memory< Factory >::my_cl_mem, tbb::flow::interface11::opencl_memory< Factory >::my_sending_event, and tbb::flow::interface11::opencl_memory< Factory >::my_sending_event_present.

Here is the call graph for this function:

## Member Function Documentation

## factory()

template<typename Factory >

Factory* tbb::flow::interface11::opencl_memory< Factory >::factory | ( |  | ) | const

inline

Definition at line 539 of file flow_graph_opencl_node.h.

{ return my_factory; }

References tbb::flow::interface11::opencl_memory< Factory >::my_factory.

## get_cl_mem()

template<typename Factory >

cl_mem tbb::flow::interface11::opencl_memory< Factory >::get_cl_mem | ( |  | ) | const

inline

Definition at line 526 of file flow_graph_opencl_node.h.

{
return my_cl_mem;
}

References tbb::flow::interface11::opencl_memory< Factory >::my_cl_mem.

Referenced by tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_map_buffer(), and tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_unmap_buffer().

Here is the caller graph for this function:

## get_host_ptr()

template<typename Factory >

void* tbb::flow::interface11::opencl_memory< Factory >::get_host_ptr | ( |  | ) |

inline

Definition at line 530 of file flow_graph_opencl_node.h.

{
if ( !my_host_ptr ) {
opencl_async_msg<void*, Factory> d = receive( NULL );
d.data();
__TBB_ASSERT( d.data() == my_host_ptr, NULL );
}
return my_host_ptr;
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
d
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
Definition: ittnotify_static.h:109
tbb::flow::interface11::opencl_memory::receive
opencl_async_msg< void *, Factory > receive(const cl_event *e)
Definition: flow_graph_opencl_node.h:541

References __TBB_ASSERT, d, tbb::flow::interface11::opencl_memory< Factory >::my_host_ptr, and tbb::flow::interface11::opencl_memory< Factory >::receive().

Referenced by tbb::flow::interface11::opencl_factory< DeviceFilter >::enqueue_unmap_buffer().

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

## map_memory()

template<typename Factory >

virtual void tbb::flow::interface11::opencl_memory< Factory >::map_memory | ( | opencl_device | ,
|  | opencl_async_msg< void *, Factory > & |
| ) |  |

pure virtual

Implemented in tbb::flow::interface11::opencl_buffer_impl< Factory >.

Referenced by tbb::flow::interface11::opencl_memory< Factory >::receive().

Here is the caller graph for this function:

## receive()

template<typename Factory >

opencl_async_msg<void*, Factory> tbb::flow::interface11::opencl_memory< Factory >::receive | ( | const cl_event * | e | ) |

inline

Definition at line 541 of file flow_graph_opencl_node.h.

{
opencl_async_msg<void*, Factory> d;
if (e) {
d = opencl_async_msg<void*, Factory>(my_host_ptr, *e);
} else {
d = opencl_async_msg<void*, Factory>(my_host_ptr);
}
// Concurrent receives are prohibited so we do not worry about synchronization.
if (my_curr_device_id.load<tbb::relaxed>() != opencl_device::host) {
map_memory(*my_factory->devices().begin(), d);
my_curr_device_id.store<tbb::relaxed>(opencl_device::host);
my_host_ptr = d.data(false);
}
// Release the sending event
if (my_sending_event_present) {
enforce_cl_retcode(clReleaseEvent(my_sending_event), "Failed to release an event");
my_sending_event_present = false;
}
return d;
}
tbb::relaxed
@ relaxed
No ordering.
Definition: atomic.h:61
tbb::flow::interface11::opencl_device::host
@ host
Definition: flow_graph_opencl_node.h:124
tbb::flow::interface11::opencl_memory::map_memory
virtual void map_memory(opencl_device, opencl_async_msg< void *, Factory > &)=0

References d, tbb::flow::interface11::enforce_cl_retcode(), tbb::flow::interface11::opencl_device::host, tbb::flow::interface11::opencl_memory< Factory >::map_memory(), tbb::flow::interface11::opencl_memory< Factory >::my_curr_device_id, tbb::flow::interface11::opencl_memory< Factory >::my_factory, tbb::flow::interface11::opencl_memory< Factory >::my_host_ptr, tbb::flow::interface11::opencl_memory< Factory >::my_sending_event, tbb::flow::interface11::opencl_memory< Factory >::my_sending_event_present, and tbb::relaxed.

Referenced by tbb::flow::interface11::opencl_memory< Factory >::get_host_ptr().

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

## send()

template<typename Factory >

opencl_async_msg<void*, Factory> tbb::flow::interface11::opencl_memory< Factory >::send | ( | opencl_device | device,
|  | const cl_event * | e
| ) |  |

inline

Definition at line 563 of file flow_graph_opencl_node.h.

{
opencl_device::device_id_type device_id = device.my_device_id;
if (!my_factory->is_same_context(my_curr_device_id.load<tbb::acquire>(), device_id)) {
{
tbb::spin_mutex::scoped_lock lock(my_sending_lock);
if (!my_factory->is_same_context(my_curr_device_id.load<tbb::relaxed>(), device_id)) {
__TBB_ASSERT(my_host_ptr, "The buffer has not been mapped");
opencl_async_msg<void*, Factory> d(my_host_ptr);
my_factory->enqueue_unmap_buffer(device, *this, d);
my_sending_event = *d.get_event();
my_sending_event_present = true;
enforce_cl_retcode(clRetainEvent(my_sending_event), "Failed to retain an event");
my_host_ptr = NULL;
my_curr_device_id.store<tbb::release>(device_id);
}
}
__TBB_ASSERT(my_sending_event_present, NULL);
}
// !e means that buffer has come from the host
if (!e && my_sending_event_present) e = &my_sending_event;
__TBB_ASSERT(!my_host_ptr, "The buffer has not been unmapped");
return e ? opencl_async_msg<void*, Factory>(NULL, *e) : opencl_async_msg<void*, Factory>(NULL);
}
lock
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
Definition: ittnotify_static.h:121
void
void
Definition: ittnotify_static.h:91
tbb::release
@ release
Release.
Definition: atomic.h:59
tbb::acquire
@ acquire
Acquire.
Definition: atomic.h:57
tbb::flow::interface11::opencl_device::device_id_type
size_t device_id_type
Definition: flow_graph_opencl_node.h:121
tbb::flow::interface11::opencl_memory::my_sending_lock
tbb::spin_mutex my_sending_lock
Definition: flow_graph_opencl_node.h:596
tbb::spin_mutex::scoped_lock
Represents acquisition of a mutex.
Definition: spin_mutex.h:53

References __TBB_ASSERT, tbb::acquire, d, tbb::flow::interface11::enforce_cl_retcode(), lock, tbb::flow::interface11::opencl_memory< Factory >::my_curr_device_id, tbb::flow::interface11::opencl_device::my_device_id, tbb::flow::interface11::opencl_memory< Factory >::my_factory, tbb::flow::interface11::opencl_memory< Factory >::my_host_ptr, tbb::flow::interface11::opencl_memory< Factory >::my_sending_event, tbb::flow::interface11::opencl_memory< Factory >::my_sending_event_present, tbb::flow::interface11::opencl_memory< Factory >::my_sending_lock, tbb::relaxed, and tbb::release.

Here is the call graph for this function:

## Member Data Documentation

## my_cl_mem

template<typename Factory >

cl_mem tbb::flow::interface11::opencl_memory< Factory >::my_cl_mem

protected

Definition at line 591 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_memory< Factory >::get_cl_mem(), tbb::flow::interface11::opencl_buffer_impl< Factory >::opencl_buffer_impl(), and tbb::flow::interface11::opencl_memory< Factory >::~opencl_memory().

## my_curr_device_id

template<typename Factory >

tbb::atomic<opencl_device::device_id_type> tbb::flow::interface11::opencl_memory< Factory >::my_curr_device_id

protected

Definition at line 592 of file flow_graph_opencl_node.h.

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

## my_factory

template<typename Factory >

Factory* tbb::flow::interface11::opencl_memory< Factory >::my_factory

protected

Definition at line 594 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_memory< Factory >::factory(), tbb::flow::interface11::opencl_buffer_impl< Factory >::map_memory(), tbb::flow::interface11::opencl_buffer_impl< Factory >::opencl_buffer_impl(), tbb::flow::interface11::opencl_memory< Factory >::opencl_memory(), tbb::flow::interface11::opencl_memory< Factory >::receive(), and tbb::flow::interface11::opencl_memory< Factory >::send().

## my_host_ptr

template<typename Factory >

void* tbb::flow::interface11::opencl_memory< Factory >::my_host_ptr

protected

Definition at line 593 of file flow_graph_opencl_node.h.

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

## my_sending_event

template<typename Factory >

cl_event tbb::flow::interface11::opencl_memory< Factory >::my_sending_event

protected

Definition at line 598 of file flow_graph_opencl_node.h.

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

## my_sending_event_present

template<typename Factory >

bool tbb::flow::interface11::opencl_memory< Factory >::my_sending_event_present

protected

Definition at line 597 of file flow_graph_opencl_node.h.

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

## my_sending_lock

template<typename Factory >

tbb::spin_mutex tbb::flow::interface11::opencl_memory< Factory >::my_sending_lock

protected

Definition at line 596 of file flow_graph_opencl_node.h.

Referenced by tbb::flow::interface11::opencl_memory< Factory >::send().

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.