35 typedef ValueT ValueType;
36 typedef Integer IndexType;
50 VectorInternal* internal()
52 return m_internal.get();
55 VectorInternal
const* internal()
const
57 return m_internal.get();
60 Integer blockSize()
const
64 return block()->size();
70 return m_own_block_size ;
74 void setBlockSize(Integer block_size)
76 if(this->m_multi_impl)
77 const_cast<MultiVectorImpl*
>(this->m_multi_impl)->setBlockInfos(block_size) ;
79 m_own_block_size = block_size ;
82 Integer getAllocSize()
const
84 return Integer(m_local_size*blockSize());
89 void resize(Integer alloc_size)
const;
102 m_own_distribution = dist;
103 m_local_size = m_own_distribution.
localSize();
112 void init(
const VectorDistribution& dist, Integer block_size,
const bool need_allocate)
114 alien_debug([&] { cout() <<
"Initializing SYCLVector " <<
this; });
116 setBlockSize(block_size) ;
117 if (this->m_multi_impl) {
118 if (this->vblock()) {
119 m_vblock.reset(
new VBlockImpl(*this->vblock(), this->distribution()));
121 m_local_size = this->distribution().localSize();
125 m_own_distribution = dist;
126 m_local_size = m_own_distribution.
localSize();
140 return m_own_distribution;
148 return m_own_distribution.localSize()*m_own_block_size;
156 return m_own_distribution.globalSize()*m_own_block_size;
164 return m_own_distribution.offset()*m_own_block_size;
167 ValueType* getDataPtr() {
return m_h_values.data(); }
168 ValueType* data() {
return m_h_values.data(); }
170 ValueType
const* getDataPtr()
const {
return m_h_values.data(); }
171 ValueType
const* data()
const {
return m_h_values.data(); }
172 ValueType
const* getAddressData()
const {
return m_h_values.data(); }
174 void initDevicePointers(
int** rows, ValueType** values)
const ;
176 static void allocateDevicePointers(std::size_t local_size,
180 static void allocateDevicePointers(std::size_t local_size,
183 static void freeDevicePointers(
int* rows, ValueType* values);
185 static void freeDevicePointers(ValueType* values);
187 static void initDevicePointers(std::size_t local_size,
188 ValueType
const* host_values,
190 ValueType** values) ;
192 static void copyDeviceToHost(std::size_t local_size,
193 ValueType
const* device_values,
194 ValueType* host_values) ;
196 template <
typename LambdaT>
197 void apply(LambdaT
const& lambda)
199 auto block_size = blockSize() ;
200 for (std::size_t i = 0; i < m_local_size*block_size; ++i) {
201 m_h_values[i] = lambda(i);
206 void setValues(std::size_t size, ValueType
const* ptr);
208 void setValuesFromHost(std::size_t size, ValueType
const* ptr);
210 void setValuesFromDevice(std::size_t size, ValueType
const* ptr);
212 void setValuesFromHost();
214 void copyValuesTo(std::size_t size, ValueType* ptr)
const;
216 void copyValuesToDevice(std::size_t size, ValueType* ptr)
const;
218 void copyValuesToDevice(ValueType* ptr)
const
220 copyValuesToDevice(m_local_size,ptr) ;
223 void pointWiseMult(SYCLVector
const& y, SYCLVector& z)
const ;
226 template <
typename E>
227 SYCLVector& operator=(E
const& expr);
232 mutable std::unique_ptr<VectorInternal> m_internal ;
233 mutable std::vector<ValueType> m_h_values ;
234 std::size_t m_local_size = 0;
235 Integer m_own_block_size = 1 ;
236 VectorDistribution m_own_distribution ;
237 mutable std::unique_ptr<VBlockImpl> m_vblock ;