1#ifndef MODULE_DEVICE_MEMORY_H_
2#define MODULE_DEVICE_MEMORY_H_
15template <
typename FPTYPE,
typename Device>
26 void operator()(FPTYPE*& arr,
const size_t size,
const char* record_in =
nullptr);
29template <
typename FPTYPE,
typename Device>
40 void operator()(FPTYPE* arr,
const int var,
const size_t size);
43template <
typename FPTYPE,
typename Device_out,
typename Device_in>
59template <
typename FPTYPE_out,
typename FPTYPE_in,
typename Device_out,
typename Device_in>
71 const FPTYPE_in* arr_in,
75template <
typename FPTYPE,
typename Device>
85template <
typename FPTYPE>
88template <
typename FPTYPE>
91template <
typename FPTYPE>
94template <
typename FPTYPE_out,
typename FPTYPE_in>
97template <
typename FPTYPE>
100#if __CUDA || __UT_USE_CUDA || __ROCM || __UT_USE_ROCM
102template <
typename FPTYPE>
107 const char* record_in =
nullptr);
110template <
typename FPTYPE>
111struct set_memory_op<FPTYPE,
base_device::DEVICE_GPU>
113 void operator()(FPTYPE* arr,
const int var,
const size_t size);
116template <
typename FPTYPE>
117struct synchronize_memory_op<FPTYPE,
base_device::DEVICE_CPU, base_device::DEVICE_GPU>
120 const FPTYPE* arr_in,
123template <
typename FPTYPE>
124struct synchronize_memory_op<FPTYPE,
base_device::DEVICE_GPU, base_device::DEVICE_CPU>
127 const FPTYPE* arr_in,
130template <
typename FPTYPE>
131struct synchronize_memory_op<FPTYPE,
base_device::DEVICE_GPU, base_device::DEVICE_GPU>
134 const FPTYPE* arr_in,
139template <
typename FPTYPE>
140struct delete_memory_op<FPTYPE,
base_device::DEVICE_GPU>
148template <
typename FPTYPE,
typename Device>
149struct resize_memory_op_mt
159 void operator()(FPTYPE*& arr,
const size_t size,
const char* record_in =
nullptr);
162template <
typename FPTYPE,
typename Device>
163struct delete_memory_op_mt
169 void operator()(FPTYPE* arr);
247 cast_memory_op<std::complex<double>, std::complex<float>, base_device::DEVICE_CPU, base_device::DEVICE_CPU>;
249 cast_memory_op<std::complex<double>, std::complex<float>, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
251 cast_memory_op<std::complex<double>, std::complex<float>, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
253 cast_memory_op<std::complex<float>, std::complex<double>, base_device::DEVICE_CPU, base_device::DEVICE_CPU>;
255 cast_memory_op<std::complex<float>, std::complex<double>, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
257 cast_memory_op<std::complex<float>, std::complex<double>, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
259static base_device::DEVICE_CPU* cpu_ctx = {};
260static base_device::DEVICE_GPU* gpu_ctx = {};
void cast_memory(FPTYPE_out *arr_out, const FPTYPE_in *arr_in, const size_t size, base_device::AbacusDevice_t device_type_out, base_device::AbacusDevice_t device_type_in)
Definition memory_op.cpp:424
void synchronize_memory(FPTYPE *arr_out, const FPTYPE *arr_in, const size_t size, base_device::AbacusDevice_t device_type_out, base_device::AbacusDevice_t device_type_in)
Definition memory_op.cpp:408
void resize_memory(FPTYPE *arr, const size_t size, base_device::AbacusDevice_t device_type)
Definition memory_op.cpp:387
void set_memory(FPTYPE *arr, const int var, const size_t size, base_device::AbacusDevice_t device_type)
Definition memory_op.cpp:398
void delete_memory(FPTYPE *arr, base_device::AbacusDevice_t device_type)
Definition memory_op.cpp:441
AbacusDevice_t
Definition types.h:12
@ CpuDevice
Definition types.h:14
Definition memory_op.h:61
void operator()(FPTYPE_out *arr_out, const FPTYPE_in *arr_in, const size_t size)
memcpy for multi-device
Definition memory_op.h:77
void operator()(FPTYPE *arr)
free memory for multi-device
Definition memory_op.h:17
void operator()(FPTYPE *&arr, const size_t size, const char *record_in=nullptr)
Allocate memory for a given pointer. Note this op will free the pointer first.
Definition memory_op.h:31
void operator()(FPTYPE *arr, const int var, const size_t size)
memset for multi-device
Definition memory_op.h:45
void operator()(FPTYPE *arr_out, const FPTYPE *arr_in, const size_t size)
memcpy for multi-device