48 #define __CL_ENABLE_EXCEPTIONS
50 #undef __CL_ENABLE_EXCEPTIONS
52 #include "detail/CopyDistribution.h"
53 #include "detail/Device.h"
54 #include "detail/DeviceBuffer.h"
55 #include "detail/Distribution.h"
68 void push_back(detail::DeviceBuffer::size_type size) {
69 _sizes.push_back(size);
72 cl_uint operator[](
size_t index)
const {
73 return static_cast<cl_uint
>(_sizes[index]);
76 std::vector<detail::DeviceBuffer::size_type> _sizes;
87 class RegisterVectorDeviceFunctions {
89 RegisterVectorDeviceFunctions();
112 template <
typename T>
123 typedef typename host_buffer_type::pointer
pointer;
135 typedef typename host_buffer_type::iterator
iterator;
144 typedef typename host_buffer_type::const_reverse_iterator
180 template <
class InputIterator>
181 Vector(InputIterator first, InputIterator last);
191 template <
class InputIterator>
192 Vector(InputIterator first, InputIterator last,
307 detail::Sizes
sizes()
const;
455 template <
class InputIterator>
456 void assign(InputIterator first, InputIterator last);
510 template <
class InputIterator>
511 void insert(
iterator pos, InputIterator first, InputIterator last);
557 template <
typename U>
570 template <
typename U>
720 std::string getInfo()
const;
722 std::string getDebugInfo()
const;
724 static RegisterVectorDeviceFunctions<T> registerVectorDeviceFunctions;
728 std::unique_ptr<detail::Distribution<Vector<T>>> _distribution;
729 mutable bool _hostBufferUpToDate;
730 mutable bool _deviceBuffersUpToDate;
733 mutable std::map< detail::Device::id_type,
734 detail::DeviceBuffer > _deviceBuffers;
737 template <
typename T>
742 #include "detail/VectorDef.h"
host_buffer_type::iterator iterator
The type of an iterator.
reference at(size_type pos)
Returns a reference to the element at the specified location pos. Boundary checks are performed...
detail::Event startUpload() const
Starts copying data from the host to the devices involved in the current distribution.
void createDeviceBuffers() const
Create buffers on the devices involved in the current distribution.
void pop_back()
Removes the last element of the Vector.
detail::Event startDownload() const
Starts copying data from the devices involved in the current distribution to the host.
~Vector()
Destructs the Vector.
size_type size() const
Returns the number of elements in the Vector.
host_buffer_type::const_iterator const_iterator
The type of an const iterator.
void setDistribution(const detail::Distribution< Vector< U >> &distribution) const
Set a new distribution to the vector.
iterator begin()
Returns an iterator to the first element of the Vector.
void copyDataToHost() const
Copies data from the devices involved in the current distribution to the host.
std::vector< T > host_buffer_type
The type used to store the elements on the host.
void clear()
Removes all elements from the Vector.
void assign(InputIterator first, InputIterator last)
Replaces the contents of the Vector with copies of the elements in the range [first, last).
void resize(size_type count, T value=T())
Resizes the container to contain count elements.
const detail::DeviceBuffer & deviceBuffer(const detail::Device &device) const
Returns the buffer for the given device used to store elements of the vector accordingly to the curre...
host_buffer_type::reference reference
The type of a reference to an element.
host_buffer_type::size_type size_type
The integral type used to define the number of the elements in the Vector.
static std::string deviceFunctions()
Returns the source code of helper functions simplifying access to the vector on the device...
void dataOnDeviceModified() const
Marks the data on the device as been modified.
SKELCL_DLL detail::DeviceID device(size_t dID)
Creates an OpenCL device ID to be used as parameter of the init(detail::PlatformID, detail::DeviceID) function.
host_buffer_type::difference_type difference_type
The integral type used to define differences of two size_type values.
iterator end()
Returns an iterator to the element following the last element of the Vector.
void swap(Vector< T > &rhs)
Exchanges the contents of the Vectors with those of rhs.
reference operator[](size_type pos)
Returns a reference to the element at the specified location pos. No boundary checks are performed...
detail::Distribution< Vector< T > > & distribution() const
Returns the current distribution of the vector.
The Vector class is a one dimensional container which makes its data accessible on the host as well a...
host_buffer_type::reverse_iterator reverse_iterator
The type of a reverse iterator.
iterator insert(iterator pos, const T &value)
Inserts copy of value at the specified location in the Vector.
iterator erase(iterator pos)
Remove the specified element from the Vector.
bool hostIsUpToDate() const
Returns if the elements stored on the host are up to date, or if the elements are outdated because th...
host_buffer_type::allocator_type allocator_type
The type of the allocator used on the host.
Vector< T > & operator=(const Vector< T > &rhs)
Copy assignment operator. Replaces the content with a copy of the content of rhs. ...
void push_back(const T &value)
Appends a copy of the given element value to the end of the Vector.
host_buffer_type::const_reference const_reference
The type of a const reference to an element.
void copyDataToDevices() const
Copies data from the host to the devices involved in the current distribution.
host_buffer_type::pointer pointer
The type of a pointer to an element.
host_buffer_type::const_reverse_iterator const_reverse_iterator
The type of a const reverse iterator.
host_buffer_type::const_pointer const_pointer
The type of a const pointer to an element.
size_type capacity() const
Returns the number of elements that the Vector has currently allocated space for. ...
host_buffer_type::value_type value_type
The type of the elements.
detail::Sizes sizes() const
Returns the number of elements stored on each device.
void dataOnHostModified() const
Marks the data on the host as been modified.
reference front()
Returns a reference to the first element in the Vector. Calling front() on an empty Vector is undefin...
size_type max_size() const
Return the maximum number of elements the Vector is able to hold.
Vector()
Creates a new empty Vector.
bool empty() const
Checks if the Vector has no elements, i.e. whether begin() == end()
void reserve(size_type n)
Increases the capacity of the Vector to a value that's greater or equal to n.
void forceCreateDeviceBuffers() const
Forces the creation of buffers on the devices involved in the current distribution, even if this means replacing existing buffers.
bool devicesAreUpToDate() const
Returns if the elements stored on the devices are up to date, or if the elements are outdated because...
host_buffer_type & hostBuffer() const
Returns a reference to the underlying object storing the elements on the host.
reference back()
Returns a reference to the last element in the Vector. Calling back() on an empty Vector is undefined...