ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1#ifndef ATEN_KERNELS_MEMORY_H_
2#define ATEN_KERNELS_MEMORY_H_
3
4#include <vector>
5#include <complex>
6
9
10namespace container {
11namespace kernels {
12
18template <typename T, typename Device>
28 void operator()(T*& arr, const size_t& size, const char* record_in = nullptr);
29};
30
36template <typename T, typename Device>
37struct set_memory {
45 void operator()(T* arr, const T& var, const size_t& size);
46};
47
57template <typename T, typename Device_out, typename Device_in>
71 T* arr_out,
72 const T* arr_in,
73 const size_t& size);
74};
75
76template <typename T, typename Device_out, typename Device_in>
79 T* arr_out,
80 const T* arr_in,
81 const std::vector<int64_t>& out_size,
82 const std::vector<int64_t>& in_size)
83 {
84 REQUIRES_OK(in_size.size() == out_size.size() && in_size.size() <= 2);
85 if (in_size.size() == 1) {
86 synchronize_memory<T, Device_out, Device_in>()(arr_out, arr_in, in_size[0]);
87 }
88 else {
89 for (int64_t ii = 0; ii < out_size[0]; ii++) {
90 synchronize_memory<T, Device_out, Device_in>()(arr_out + ii * out_size[1], arr_in + ii * in_size[1], in_size[1]);
91 }
92 }
93 }
94};
95
106template <typename T_out, typename T_in, typename Device_out, typename Device_in>
120 T_out* arr_out,
121 const T_in* arr_in,
122 const size_t& size);
123};
124
125
134template <typename T, typename Device>
144 void operator()(T* arr);
145};
146
147} // namespace kernels
148} // namespace container
149
150#endif // ATEN_KERNELS_MEMORY_H_
#define T
Definition exp.cpp:237
#define REQUIRES_OK(expr,...)
Definition macros.h:60
Definition tensor.cpp:8
Casts memory between devices.
Definition memory.h:107
void operator()(T_out *arr_out, const T_in *arr_in, const size_t &size)
Casts memory between devices.
Deletes memory on a device.
Definition memory.h:135
void operator()(T *arr)
Deletes memory on a device.
A functor to resize memory allocation.
Definition memory.h:19
void operator()(T *&arr, const size_t &size, const char *record_in=nullptr)
Resize memory allocation.
A functor to set memory to a constant value.
Definition memory.h:37
void operator()(T *arr, const T &var, const size_t &size)
Set memory to a constant value.
void operator()(T *arr_out, const T *arr_in, const std::vector< int64_t > &out_size, const std::vector< int64_t > &in_size)
Definition memory.h:78
Synchronizes memory between devices.
Definition memory.h:58
void operator()(T *arr_out, const T *arr_in, const size_t &size)
Synchronizes memory between devices.
This file contains the definition of the DataType enum class.