40 #ifndef INDEX_VECTOR_DEF_H_
41 #define INDEX_VECTOR_DEF_H_
53 #include <pvsutil/Assert.h>
54 #include <pvsutil/Logger.h>
56 #include <SkelCL/IndexVector.h>
59 #include <SkelCL/detail/Device.h>
60 #include <SkelCL/detail/DeviceBuffer.h>
61 #include <SkelCL/detail/DeviceList.h>
62 #include <SkelCL/detail/Distribution.h>
63 #include <SkelCL/detail/Event.h>
72 _distribution(new skelcl::detail::Distribution <
Vector <
Index >> ())
74 LOG_DEBUG_INFO(
"Created new IndexVector object (",
this,
") with ",
79 : _maxIndex(rhs._maxIndex),
80 _distribution(detail::cloneAndConvert<
Vector<
Index>>(rhs.distribution()))
82 LOG_DEBUG_INFO(
"Created new IndexVector object (",
this,
") by copying (",
83 &rhs,
") with ", getDebugInfo());
88 LOG_DEBUG_INFO(
"IndexVector object (",
this,
") with ", getDebugInfo(),
109 ASSERT(_distribution !=
nullptr);
112 for (
auto& devicePtr : _distribution->devices()) {
113 s.push_back(this->_distribution->sizeForDevice(*
this, devicePtr));
125 if (n >= _maxIndex)
throw std::out_of_range(
"Out of range access.");
141 ASSERT(_distribution !=
nullptr);
142 return *_distribution;
148 newDistribution)
const
150 ASSERT(newDistribution !=
nullptr);
151 ASSERT(newDistribution->isValid());
153 _distribution = std::move(newDistribution);
154 ASSERT(_distribution->isValid());
156 LOG_DEBUG_INFO(
"IndexVector object (",
this,
157 ") assigned new distribution, now with ", getDebugInfo());
162 return std::string();
168 s <<
"size: " <<
size();
172 std::string Vector<Index>::getDebugInfo()
const
179 const detail::DeviceBuffer&
182 ASSERT_MESSAGE(
false,
"This function should never be called!");
183 static detail::DeviceBuffer db;
189 ASSERT_MESSAGE(
false,
"This function should never be called!");
190 static std::vector<Index> v;
196 ASSERT_MESSAGE(
false,
"This function should never be called!");
201 ASSERT_MESSAGE(
false,
"This function should never be called!");
206 #endif // INDEX_VECTOR_DEF_H_
reference at(size_type pos)
Returns a reference to the element at the specified location pos. Boundary checks are performed...
~Vector()
Destructs the Vector.
size_type size() const
Returns the number of elements in the Vector.
void setDistribution(const detail::Distribution< Vector< U >> &distribution) const
Set a new distribution to the vector.
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::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.
size_t size_type
Defines the type used to denote size of the Vector.
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...
This class defines an Index, i.e. an unsigned integer representing a value in a one-dimensional index...
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...
Vector()
Creates a new empty Vector.
The IndexVector (a.k.a. Vector) class is a special implementation of a Vector with Elements of...
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...