monolish
0.16.0
MONOlithic LInear equation Solvers for Highly-parallel architecture
|
Go to the documentation of this file.
40 template <
typename Float>
class vector {
45 std::vector<Float>
val;
75 vector(
const size_t N,
const Float value);
85 vector(
const std::vector<Float> &vec);
95 vector(
const std::initializer_list<Float> &list);
148 vector(
const Float *start,
const Float *
end);
160 vector(
const size_t N,
const Float
min,
const Float
max);
174 vector(
const size_t N,
const Float
min,
const Float
max,
175 const std::uint32_t seed);
249 [[nodiscard]]
const Float *
data()
const {
return val.data(); }
257 [[nodiscard]] Float *
data() {
return val.data(); }
269 throw std::runtime_error(
"Error, GPU vector cant use resize");
282 throw std::runtime_error(
"Error, GPU vector cant use push_back");
293 [[nodiscard]]
const Float *
begin()
const {
return val.data(); }
301 [[nodiscard]] Float *
begin() {
return val.data(); }
309 [[nodiscard]]
const Float *
end()
const {
return val.data() +
size(); }
325 [[nodiscard]]
size_t size()
const {
return val.size(); }
343 void fill(Float value);
353 void print_all(
bool force_cpu =
false)
const;
363 void print_all(std::string filename)
const;
419 void operator=(
const std::vector<Float> &vec);
442 throw std::runtime_error(
"Error, GPU vector cant use operator[]");
458 bool compare_cpu_and_device =
false)
const;
471 bool compare_cpu_and_device =
false)
const;
484 bool compare_cpu_and_device =
false)
const;
void min(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
Create a new CRS matrix with smallest elements of two matrices (C[0:nnz] = min(A[0:nnz],...
std::vector< Float > val
size N vector data
void max(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
Create a new CRS matrix with greatest elements of two matrices (C[0:nnz] = max(A[0:nnz],...
void print_all(bool force_cpu=false) const
print all elements to standart I/O
Float * data()
returns a direct pointer to the vector
size_t get_offset() const
const Float * end() const
returns a end iterator
Float * end()
returns a end iterator
void nonfree_recv()
recv data from GPU (w/o free)
const Float * data() const
returns a direct pointer to the vector
void operator=(const vector< Float > &vec)
copy vector, It is same as copy ( Copy the memory on CPU and GPU )
void recv()
recv data from GPU, and free data on GPU
Float & operator[](size_t i)
reference to the element at position (v[i])
void push_back(Float val)
Add a new element at the end of the vector (only CPU)
void send() const
send data to GPU
vector< Float > operator-()
Sign inversion.
~vector()
destructor of vector, free GPU memory
bool get_device_mem_stat() const
true: sended, false: not send
void fill(Float value)
fill vector elements with a scalar value
size_t size() const
get vector size
size_t get_nnz() const
get vector size
const Float * begin() const
returns a begin iterator
bool operator!=(const vector< Float > &vec) const
Comparing vectors (v != vec)
Float * begin()
returns a begin iterator
bool operator==(const vector< Float > &vec) const
Comparing vectors (v == vec)
bool equal(const vector< Float > &vec, bool compare_cpu_and_device=false) const
Comparing matrices (A == mat)
void device_free() const
free data on GPU
void resize(size_t N)
resize vector (only CPU)
bool gpu_status
true: sended, false: not send