Skip to content

Commit cea6d8c

Browse files
authored
Merge pull request #10 from kunkunblueberry/tmp
fix the linking question of lacking function of hip
2 parents 94099e7 + dcec9d3 commit cea6d8c

1 file changed

Lines changed: 81 additions & 1 deletion

File tree

source/module_base/module_device/rocm/memory_op.hip.cu

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ void set_memory_op<FPTYPE, base_device::DEVICE_GPU>::operator()(const base_devic
6060
hipErrcheck(hipMemset(arr, var, sizeof(FPTYPE) * size));
6161
}
6262

63+
template <typename FPTYPE>
64+
void set_memory_2d_op<FPTYPE, base_device::DEVICE_GPU>::operator()(const base_device::DEVICE_GPU* dev,
65+
FPTYPE* arr,
66+
const size_t pitch,
67+
const int var,
68+
const size_t width,
69+
const size_t height)
70+
{
71+
hipErrcheck(hipMemset2D(arr, sizeof(FPTYPE) * pitch , var, sizeof(FPTYPE) * width, height));
72+
}
73+
74+
75+
6376
template <typename FPTYPE>
6477
void synchronize_memory_op<FPTYPE, base_device::DEVICE_CPU, base_device::DEVICE_GPU>::operator()(
6578
const base_device::DEVICE_CPU* dev_out,
@@ -93,6 +106,49 @@ void synchronize_memory_op<FPTYPE, base_device::DEVICE_GPU, base_device::DEVICE_
93106
hipErrcheck(hipMemcpy(arr_out, arr_in, sizeof(FPTYPE) * size, hipMemcpyDeviceToDevice));
94107
}
95108

109+
template <typename FPTYPE>
110+
void synchronize_memory_2d_op<FPTYPE, base_device::DEVICE_CPU, base_device::DEVICE_GPU>::operator()(
111+
const base_device::DEVICE_CPU* dev_out,
112+
const base_device::DEVICE_GPU* dev_in,
113+
FPTYPE* arr_out,
114+
const size_t dpitch,
115+
const FPTYPE* arr_in,
116+
const size_t spitch,
117+
const size_t width,
118+
const size_t height)
119+
{
120+
hipErrcheck(hipMemcpy2D(arr_out, dpitch * sizeof(FPTYPE), arr_in, spitch * sizeof(FPTYPE), width * sizeof(FPTYPE), height, hipMemcpyDeviceToHost));
121+
}
122+
123+
template <typename FPTYPE>
124+
void synchronize_memory_2d_op<FPTYPE, base_device::DEVICE_GPU, base_device::DEVICE_CPU>::operator()(
125+
const base_device::DEVICE_GPU* dev_out,
126+
const base_device::DEVICE_CPU* dev_in,
127+
FPTYPE* arr_out,
128+
const size_t dpitch,
129+
const FPTYPE* arr_in,
130+
const size_t spitch,
131+
const size_t width,
132+
const size_t height)
133+
{
134+
hipErrcheck(hipMemcpy2D(arr_out, dpitch * sizeof(FPTYPE), arr_in, spitch * sizeof(FPTYPE), width * sizeof(FPTYPE), height, hipMemcpyHostToDevice));
135+
}
136+
137+
template <typename FPTYPE>
138+
void synchronize_memory_2d_op<FPTYPE, base_device::DEVICE_GPU, base_device::DEVICE_GPU>::operator()(
139+
const base_device::DEVICE_GPU* dev_out,
140+
const base_device::DEVICE_GPU* dev_in,
141+
FPTYPE* arr_out,
142+
const size_t dpitch,
143+
const FPTYPE* arr_in,
144+
const size_t spitch,
145+
const size_t width,
146+
const size_t height)
147+
{
148+
hipErrcheck(hipMemcpy2D(arr_out, dpitch * sizeof(FPTYPE), arr_in, spitch * sizeof(FPTYPE), width * sizeof(FPTYPE), height, hipMemcpyDeviceToDevice));
149+
}
150+
151+
96152
template <typename FPTYPE_out, typename FPTYPE_in>
97153
struct cast_memory_op<FPTYPE_out, FPTYPE_in, base_device::DEVICE_GPU, base_device::DEVICE_GPU> {
98154
void operator()(const base_device::DEVICE_GPU* dev_out,
@@ -183,6 +239,13 @@ template struct set_memory_op<double, base_device::DEVICE_GPU>;
183239
template struct set_memory_op<std::complex<float>, base_device::DEVICE_GPU>;
184240
template struct set_memory_op<std::complex<double>, base_device::DEVICE_GPU>;
185241

242+
template struct set_memory_2d_op<int, base_device::DEVICE_GPU>;
243+
template struct set_memory_2d_op<float, base_device::DEVICE_GPU>;
244+
template struct set_memory_2d_op<double, base_device::DEVICE_GPU>;
245+
template struct set_memory_2d_op<std::complex<float>, base_device::DEVICE_GPU>;
246+
template struct set_memory_2d_op<std::complex<double>, base_device::DEVICE_GPU>;
247+
248+
186249
template struct synchronize_memory_op<int, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
187250
template struct synchronize_memory_op<int, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
188251
template struct synchronize_memory_op<int, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
@@ -199,6 +262,23 @@ template struct synchronize_memory_op<std::complex<double>, base_device::DEVICE_
199262
template struct synchronize_memory_op<std::complex<double>, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
200263
template struct synchronize_memory_op<std::complex<double>, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
201264

265+
template struct synchronize_memory_2d_op<int, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
266+
template struct synchronize_memory_2d_op<int, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
267+
template struct synchronize_memory_2d_op<int, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
268+
template struct synchronize_memory_2d_op<float, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
269+
template struct synchronize_memory_2d_op<float, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
270+
template struct synchronize_memory_2d_op<float, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
271+
template struct synchronize_memory_2d_op<double, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
272+
template struct synchronize_memory_2d_op<double, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
273+
template struct synchronize_memory_2d_op<double, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
274+
template struct synchronize_memory_2d_op<std::complex<float>, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
275+
template struct synchronize_memory_2d_op<std::complex<float>, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
276+
template struct synchronize_memory_2d_op<std::complex<float>, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
277+
template struct synchronize_memory_2d_op<std::complex<double>, base_device::DEVICE_CPU, base_device::DEVICE_GPU>;
278+
template struct synchronize_memory_2d_op<std::complex<double>, base_device::DEVICE_GPU, base_device::DEVICE_CPU>;
279+
template struct synchronize_memory_2d_op<std::complex<double>, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
280+
281+
202282
template struct cast_memory_op<float, float, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
203283
template struct cast_memory_op<double, double, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
204284
template struct cast_memory_op<float, double, base_device::DEVICE_GPU, base_device::DEVICE_GPU>;
@@ -271,4 +351,4 @@ template struct delete_memory_op<std::complex<float>*, base_device::DEVICE_GPU>;
271351
template struct delete_memory_op<std::complex<double>*, base_device::DEVICE_GPU>;
272352

273353
} // namespace memory
274-
} // end of namespace base_device
354+
} // end of namespace base_device

0 commit comments

Comments
 (0)