33 #ifndef __H__UG__CRS_ALGEBRA__VECTOR__
34 #define __H__UG__CRS_ALGEBRA__VECTOR__
36 #include "../cpu_algebra/vector.h"
49 template <
typename TValueType>
75 void resize(
size_t newSize,
bool bCopyValues=
true)
77 UG_LOG(
this <<
"GPUVector::resize(" << newSize <<
")\n");
82 void reserve(
size_t newCapacity,
bool bCopyValues=
true)
84 UG_LOG(
this <<
"GPUVector::reserve(" << newCapacity <<
")\n");
85 reserve(newCapacity, bCopyValues);
203 cublasDnrm2(CUDAHelper::get_cublasHandle(),
size(),
get_dev_ptr(), 1, &res);
212 cudaThreadSynchronize();
221 template<
typename value_type>
227 template<
typename value_type>
233 template<
typename value_type>
239 template<
typename value_type>
264 UG_LOG(
"VecScaleAssign\n");
265 for(
size_t i=0; i<dest.
size(); i++)
274 for(
size_t i=0; i<dest.
size(); i++)
302 cudaThreadSynchronize();
321 for(
int i=0; i<a.
size(); i++)
Definition: gpuvector.h:51
void assure_on_gpu() const
Definition: gpuvector.h:124
TValueType value_type
Definition: gpuvector.h:54
bool on_gpu()
Definition: gpuvector.h:148
GPUVector(size_t _length)
constructor with length
Definition: gpuvector.h:67
void operator-=(const GPUVector< value_type > &v)
Definition: gpuvector.h:184
size_t m_sizeOnGPU
Definition: gpuvector.h:218
const double * get_dev_ptr() const
Definition: gpuvector.h:169
double * m_devValues
Definition: gpuvector.h:217
void assure_on_cpu()
Definition: gpuvector.h:129
bool on_cpu()
Definition: gpuvector.h:143
GPUVector< TValueType > vector_type
Definition: gpuvector.h:55
int m_GPUState
Definition: gpuvector.h:160
void reserve(size_t newCapacity, bool bCopyValues=true)
Definition: gpuvector.h:82
void assure_on_cpu() const
Definition: gpuvector.h:138
void operator+=(const GPUVector< value_type > &v)
Definition: gpuvector.h:180
double dotprod(const GPUVector< value_type > &w) const
Definition: gpuvector.h:207
void resize(size_t newSize, bool bCopyValues=true)
Definition: gpuvector.h:75
double norm() const
return sqrt(sum values[i]^2) (euclidian norm)
Definition: gpuvector.h:200
GPUVector()
constructor
Definition: gpuvector.h:64
value_type & operator[](size_t i)
access element i of the vector
Definition: gpuvector.h:90
void add(double alpha, const GPUVector< value_type > &v)
Definition: gpuvector.h:189
void operator*=(const number &a)
Definition: gpuvector.h:194
void operator=(const GPUVector< value_type > &v)
Definition: gpuvector.h:176
void assure_on_gpu()
Definition: gpuvector.h:111
size_t size() const
Definition: vector.h:181
void reserve(size_t newCapacity, bool bCopyValues=true)
Definition: vector.h:113
Vector< TValueType > super
Definition: gpuvector.h:57
GPU_STATE
Definition: gpuvector.h:155
@ ON_GPU
Definition: gpuvector.h:156
@ ON_GPU_AND_CPU
Definition: gpuvector.h:158
@ ON_CPU
Definition: gpuvector.h:157
double * get_dev_ptr()
Definition: gpuvector.h:163
TValueType value_type
Definition: vector.h:57
value_type & operator[](size_t i)
access element i of the vector
Definition: vector_impl.h:47
void resize(size_t newSize, bool bCopyValues=true)
Definition: vector.h:109
size_t size() const
Definition: vector.h:181
void reserve(size_t newCapacity, bool bCopyValues=true)
Definition: vector.h:113
bool CUDA_VecAdd_2(FPTYPE *dest, FPTYPE alpha1, const FPTYPE *v1, FPTYPE alpha2, const FPTYPE *v2, const int N)
bool CUDA_VecAdd2(const int len, FPTYPE alpha, FPTYPE *x, FPTYPE beta, const FPTYPE *y)
bool CUDA_VecAdd_3(FPTYPE *dest, FPTYPE alpha1, const FPTYPE *v1, FPTYPE alpha2, const FPTYPE *v2, FPTYPE alpha3, const FPTYPE *v3, const int N)
SmartPtr< vector_type > clone() const
clones the vector (deep-copy) including values
Definition: gpuvector.h:228
SmartPtr< vector_type > clone_without_values() const
clones the vector (deep-copy) excluding values
Definition: gpuvector.h:240
virtual vector_type * virtual_clone_without_values() const
virtual clone using covariant return type excluding values
Definition: gpuvector.h:234
virtual vector_type * virtual_clone() const
virtual clone using covariant return type
Definition: gpuvector.h:222
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
CPUAlgebra::vector_type vector_type
void VecAssign(vector_t &dest, const vector_t &v1)
sets dest = v1 entrywise
Definition: operations_vec.h:154
double VecProd(const double &a, const double &b)
returns scal<a, b>
Definition: operations_vec.h:84
void CudaCpyToHost(T &dest, typename T::value_type *src)
Definition: cuda_manager.h:153
void CudaCpyToDevice(typename T::value_type *dest, T &vec)
Definition: cuda_manager.h:144
void VecNormSquaredAdd(const double &a, double &s)
calculates s += norm_2^2(a)
Definition: operations_vec.h:106
T::value_type * CudaCreateAndCopyToDevice(T &vec)
Definition: cuda_manager.h:163
double VecNormSquared(const double &a)
returns norm_2^2(a)
Definition: operations_vec.h:100
void VecScaleAssign(double &dest, double alpha1, const double &v1)
calculates dest = alpha1*v1. for doubles
Definition: operations_vec.h:49