Skip to content

Commit a7766bf

Browse files
committed
Remove ctx in vector_mul_vector_op
1 parent 2ff323b commit a7766bf

File tree

12 files changed

+24
-37
lines changed

12 files changed

+24
-37
lines changed

source/module_base/blas_connector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ void vector_mul_vector(const int& dim, T* result, const T* vector1, const T* vec
668668
}
669669
else if (device_type == base_device::AbacusDevice_t::GpuDevice){
670670
#ifdef __CUDA
671-
ModuleBase::vector_mul_vector_op<T, base_device::DEVICE_GPU>()(gpu_ctx, dim, result, vector1, vector2);
671+
ModuleBase::vector_mul_vector_op<T, base_device::DEVICE_GPU>()(dim, result, vector1, vector2);
672672
#endif
673673
}
674674
}

source/module_base/kernels/cuda/math_kernel_op.cu

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,7 @@ void vector_div_constant_op<std::complex<double>, base_device::DEVICE_GPU>::oper
552552
}
553553
// vector operator: result[i] = vector1[i](not complex) * vector2[i](not complex)
554554
template <>
555-
void vector_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const base_device::DEVICE_GPU* d,
556-
const int& dim,
555+
void vector_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const int& dim,
557556
double* result,
558557
const double* vector1,
559558
const double* vector2)
@@ -566,8 +565,7 @@ void vector_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const bas
566565
}
567566
// vector operator: result[i] = vector1[i](complex) * vector2[i](not complex)
568567
template <typename FPTYPE>
569-
inline void vector_mul_vector_complex_wrapper(const base_device::DEVICE_GPU* d,
570-
const int& dim,
568+
inline void vector_mul_vector_complex_wrapper(const int& dim,
571569
std::complex<FPTYPE>* result,
572570
const std::complex<FPTYPE>* vector1,
573571
const FPTYPE* vector2)
@@ -581,23 +579,21 @@ inline void vector_mul_vector_complex_wrapper(const base_device::DEVICE_GPU* d,
581579
cudaCheckOnDebug();
582580
}
583581
template <>
584-
void vector_mul_vector_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const base_device::DEVICE_GPU* d,
585-
const int& dim,
582+
void vector_mul_vector_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const int& dim,
586583
std::complex<float>* result,
587584
const std::complex<float>* vector1,
588585
const float* vector2)
589586
{
590-
vector_mul_vector_complex_wrapper(d, dim, result, vector1, vector2);
587+
vector_mul_vector_complex_wrapper(dim, result, vector1, vector2);
591588
}
592589
template <>
593590
void vector_mul_vector_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(
594-
const base_device::DEVICE_GPU* d,
595591
const int& dim,
596592
std::complex<double>* result,
597593
const std::complex<double>* vector1,
598594
const double* vector2)
599595
{
600-
vector_mul_vector_complex_wrapper(d, dim, result, vector1, vector2);
596+
vector_mul_vector_complex_wrapper(dim, result, vector1, vector2);
601597
}
602598

603599
// vector operator: result[i] = vector1[i](not complex) / vector2[i](not complex)

source/module_base/kernels/math_kernel_op.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ template <typename T>
167167
struct vector_mul_vector_op<T, base_device::DEVICE_CPU>
168168
{
169169
using Real = typename GetTypeReal<T>::type;
170-
void operator()(const base_device::DEVICE_CPU* d, const int& dim, T* result, const T* vector1, const Real* vector2)
170+
void operator()(const int& dim, T* result, const T* vector1, const Real* vector2)
171171
{
172172
#ifdef _OPENMP
173173
#pragma omp parallel for schedule(static, 4096 / sizeof(Real))

source/module_base/kernels/math_kernel_op.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,13 @@ template <typename T, typename Device> struct vector_mul_vector_op {
140140
/// @brief result[i] = vector1[i](complex) * vector2[i](not complex)
141141
///
142142
/// Input Parameters
143-
/// \param d : the type of computing device
144143
/// \param dim : array size
145144
/// \param vector1 : input array A
146145
/// \param vector2 : input array B
147146
///
148147
/// Output Parameters
149148
/// \param result : output array
150-
void operator()(const Device *d, const int &dim, T *result, const T *vector1,
149+
void operator()(const int &dim, T *result, const T *vector1,
151150
const Real *vector2);
152151
};
153152

@@ -359,7 +358,7 @@ struct vector_div_constant_op<T, base_device::DEVICE_GPU> {
359358
// vector operator: result[i] = vector1[i](complex) * vector2[i](not complex)
360359
template <typename T> struct vector_mul_vector_op<T, base_device::DEVICE_GPU> {
361360
using Real = typename GetTypeReal<T>::type;
362-
void operator()(const base_device::DEVICE_GPU *d, const int &dim, T *result,
361+
void operator()(const int &dim, T *result,
363362
const T *vector1, const Real *vector2);
364363
};
365364

source/module_base/kernels/rocm/math_kernel_op.hip.cu

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ void vector_div_constant_op<std::complex<double>, base_device::DEVICE_GPU>::oper
475475
}
476476
// vector operator: result[i] = vector1[i](not complex) * vector2[i](not complex)
477477
template <>
478-
void vector_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const base_device::DEVICE_GPU* d,
479-
const int& dim,
478+
void vector_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const int& dim,
480479
double* result,
481480
const double* vector1,
482481
const double* vector2)
@@ -490,8 +489,7 @@ void vector_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const bas
490489

491490
// vector operator: result[i] = vector1[i](complex) * vector2[i](not complex)
492491
template <typename FPTYPE>
493-
inline void vector_mul_vector_complex_wrapper(const base_device::DEVICE_GPU* d,
494-
const int& dim,
492+
inline void vector_mul_vector_complex_wrapper(const int& dim,
495493
std::complex<FPTYPE>* result,
496494
const std::complex<FPTYPE>* vector1,
497495
const FPTYPE* vector2)
@@ -505,23 +503,21 @@ inline void vector_mul_vector_complex_wrapper(const base_device::DEVICE_GPU* d,
505503
hipCheckOnDebug();
506504
}
507505
template <>
508-
void vector_mul_vector_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const base_device::DEVICE_GPU* d,
509-
const int& dim,
506+
void vector_mul_vector_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const int& dim,
510507
std::complex<float>* result,
511508
const std::complex<float>* vector1,
512509
const float* vector2)
513510
{
514-
vector_mul_vector_complex_wrapper(d, dim, result, vector1, vector2);
511+
vector_mul_vector_complex_wrapper(dim, result, vector1, vector2);
515512
}
516513
template <>
517514
void vector_mul_vector_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(
518-
const base_device::DEVICE_GPU* d,
519515
const int& dim,
520516
std::complex<double>* result,
521517
const std::complex<double>* vector1,
522518
const double* vector2)
523519
{
524-
vector_mul_vector_complex_wrapper(d, dim, result, vector1, vector2);
520+
vector_mul_vector_complex_wrapper(dim, result, vector1, vector2);
525521
}
526522
// vector operator: result[i] = vector1[i](complex) / vector2[i](not complex)
527523
template <>

source/module_base/kernels/test/math_kernel_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ TEST_F(TestModuleHsolverMathKernel, vector_div_constant_op_cpu)
275275
TEST_F(TestModuleHsolverMathKernel, vector_mul_vector_op_cpu)
276276
{
277277
std::vector<std::complex<double>> output(input.size());
278-
vector_mul_vector_op_cpu()(cpu_ctx, dim, output.data(), input.data(), input_double.data());
278+
vector_mul_vector_op_cpu()(dim, output.data(), input.data(), input_double.data());
279279
for (int i = 0; i < input.size(); i++)
280280
{
281281
EXPECT_LT(fabs(output[i].imag() - output_vector_mul_vector_op[i].imag()), 1e-8);
@@ -428,7 +428,7 @@ TEST_F(TestModuleHsolverMathKernel, vector_mul_vector_op_gpu)
428428
synchronize_memory_op_double()(input_double_dev, input_double.data(), input.size());
429429

430430
// run
431-
vector_mul_vector_op_gpu()(gpu_ctx, dim, output_dev, input_dev, input_double_dev);
431+
vector_mul_vector_op_gpu()(dim, output_dev, input_dev, input_double_dev);
432432

433433
// syn the output data in GPU to CPU
434434
synchronize_memory_op_gpu()(output.data(), output_dev, output.size());

source/module_hamilt_pw/hamilt_pwdft/operator_pw/meta_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void Meta<OperatorPW<T, Device>>::act(
7070
wfcpw->recip_to_real(this->ctx, this->porter, this->porter, this->ik);
7171

7272
if(this->vk_col != 0) {
73-
vector_mul_vector_op()(this->ctx, this->vk_col, this->porter, this->porter, this->vk + current_spin * this->vk_col);
73+
vector_mul_vector_op()(this->vk_col, this->porter, this->porter, this->vk + current_spin * this->vk_col);
7474
}
7575

7676
wfcpw->real_to_recip(this->ctx, this->porter, this->porter, this->ik);

source/module_hsolver/diago_cg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void DiagoCG<T, Device>::calc_gamma_cg(const int& iter,
342342
// }
343343
// denghui replace this 20221106
344344
// TODO: use GPU precondition instead
345-
ModuleBase::vector_mul_vector_op<T, Device>()(ctx_, this->n_basis_, g0.data<T>(), scg.data<T>(), prec.data<Real>());
345+
ModuleBase::vector_mul_vector_op<T, Device>()(this->n_basis_, g0.data<T>(), scg.data<T>(), prec.data<Real>());
346346

347347
// (3) Update gg_now!
348348
// gg_now = < g|P|scg > = < g|g0 >

source/module_hsolver/diago_dav_subspace.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ void Diago_DavSubspace<T, Device>::cal_grad(const HPsiFunc& hpsi_func,
309309
{
310310
syncmem_var_h2d_op()(e_temp_hd, e_temp_cpu.data(), nbase);
311311
}
312-
ModuleBase::vector_mul_vector_op<T, Device>()(this->ctx,
313-
nbase,
312+
ModuleBase::vector_mul_vector_op<T, Device>()(nbase,
314313
vcc + m * this->nbase_x,
315314
vcc + m * this->nbase_x,
316315
e_temp_hd);

source/module_hsolver/diago_david.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ void DiagoDavid<T, Device>::cal_grad(const HPsiFunc& hpsi_func,
416416
Real* e_temp_gpu = nullptr;
417417
resmem_var_op()(e_temp_gpu, nbase);
418418
syncmem_var_h2d_op()(e_temp_gpu, e_temp_cpu.data(), nbase);
419-
ModuleBase::vector_mul_vector_op<T, Device>()(this->ctx,
420-
nbase,
419+
ModuleBase::vector_mul_vector_op<T, Device>()(nbase,
421420
vc_ev_vector + m * nbase,
422421
vc_ev_vector + m * nbase,
423422
e_temp_gpu);
@@ -426,8 +425,7 @@ void DiagoDavid<T, Device>::cal_grad(const HPsiFunc& hpsi_func,
426425
}
427426
else
428427
{
429-
ModuleBase::vector_mul_vector_op<T, Device>()(this->ctx,
430-
nbase,
428+
ModuleBase::vector_mul_vector_op<T, Device>()(nbase,
431429
vc_ev_vector + m * nbase,
432430
vc_ev_vector + m * nbase,
433431
e_temp_cpu.data());

0 commit comments

Comments
 (0)