Skip to content

Commit 8d6cbdf

Browse files
committed
fix bug in dsp compute
1 parent c873197 commit 8d6cbdf

8 files changed

Lines changed: 24 additions & 18 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ if (USE_DSP)
281281
target_link_libraries(${ABACUS_BIN_NAME} ${MT_HOST_DIR}/hthreads/lib/libhthread_device.a)
282282
target_link_libraries(${ABACUS_BIN_NAME} ${MT_HOST_DIR}/hthreads/lib/libhthread_host.a)
283283
endif()
284+
target_link_libraries(${ABACUS_BIN_NAME} ${SCALAPACK_LIBRARY_DIR})
284285

285286
find_package(Threads REQUIRED)
286287
target_link_libraries(${ABACUS_BIN_NAME} Threads::Threads)

source/source_base/kernels/dsp/dsp_connector.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ extern "C"
1212
}
1313
namespace mtfunc
1414
{
15+
std::complex<double>* alp=nullptr;
16+
std::complex<double>* bet=nullptr;
1517
void dspInitHandle(int id)
1618
{
1719
mt_blas_init(id);
@@ -271,9 +273,9 @@ void zgemm_mth_(const char* transa,
271273
const int* ldc,
272274
int cluster_id)
273275
{
274-
std::complex<double>* alp = (std::complex<double>*)malloc_ht(sizeof(std::complex<double>), cluster_id);
276+
// std::complex<double>* alp = (std::complex<double>*)malloc_ht(sizeof(std::complex<double>), cluster_id);
275277
*alp = *alpha;
276-
std::complex<double>* bet = (std::complex<double>*)malloc_ht(sizeof(std::complex<double>), cluster_id);
278+
// std::complex<double>* bet = (std::complex<double>*)malloc_ht(sizeof(std::complex<double>), cluster_id);
277279
*bet = *beta;
278280
mt_hthread_zgemm(MTBLAS_ORDER::MtblasColMajor,
279281
convertBLASTranspose(transa),

source/source_base/kernels/dsp/dsp_connector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ void* malloc_ht(size_t bytes, int cluster_id);
1515
void free_ht(void* ptr);
1616

1717
// mtblas functions
18+
extern std::complex<double>* alp;
19+
extern std::complex<double>* bet;
1820

1921
void sgemm_mt_(const char* transa,
2022
const char* transb,

source/source_basis/module_pw/module_fft/fft_dsp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "fft_dsp.h"
22

33
#include "source_base/global_variable.h"
4-
4+
#include "source_base/tool_quit.h"
55
#include <iostream>
66
#include <string.h>
77
#include <vector>

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ ESolver_KS_PW<T, Device>::ESolver_KS_PW()
7171
#ifdef __DSP
7272
std::cout << " ** Initializing DSP Hardware..." << std::endl;
7373
mtfunc::dspInitHandle(GlobalV::MY_RANK);
74+
mtfunc::alp=(std::complex<double>*)mtfunc::malloc_ht(sizeof(std::complex<double>), GlobalV::MY_RANK);
75+
mtfunc::bet=(std::complex<double>*)mtfunc::malloc_ht(sizeof(std::complex<double>), GlobalV::MY_RANK);
7476
#endif
7577
}
7678

source/source_io/read_wf2rho_pw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ void ModuleIO::read_wf2rho_pw(
129129
{
130130
const std::complex<double>* wfc_ib = wfc_tmp.c + ib * ng_npol;
131131
const std::complex<double>* wfc_ib2 = wfc_tmp.c + ib * ng_npol + ng_npol / 2;
132-
pw_wfc->recip2real(wfc_ib, rho_tmp.data(), ik);
133-
pw_wfc->recip2real(wfc_ib2, rho_tmp2.data(), ik);
132+
pw_wfc->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(wfc_ib, rho_tmp.data(), ik);
133+
pw_wfc->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(wfc_ib2, rho_tmp2.data(), ik);
134134
const double w1 = wg_tmp(ikstot, ib) / pw_wfc->omega;
135135

136136
if (w1 != 0.0)
@@ -152,7 +152,7 @@ void ModuleIO::read_wf2rho_pw(
152152
for (int ib = 0; ib < nbands; ++ib)
153153
{
154154
const std::complex<double>* wfc_ib = wfc_tmp.c + ib * ng_npol;
155-
pw_wfc->recip2real(wfc_ib, rho_tmp.data(), ik);
155+
pw_wfc->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(wfc_ib, rho_tmp.data(), ik);
156156

157157
const double w1 = wg_tmp(ikstot, ib) / pw_wfc->omega;
158158

source/source_io/to_wannier90_pw.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void toWannier90_PW::out_unk(
253253
{
254254
int ib = cal_band_index[ib_w];
255255

256-
wfcpw->recip2real(&psi_pw(ik, ib, 0), porter, ik);
256+
wfcpw->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(&psi_pw(ik, ib, 0), porter, ik);
257257

258258
if (GlobalV::RANK_IN_POOL == 0)
259259
{
@@ -383,7 +383,7 @@ void toWannier90_PW::unkdotkb(
383383
}
384384
}
385385

386-
wfcpw->recip2real(phase, phase, cal_ik);
386+
wfcpw->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(phase, phase, cal_ik);
387387

388388
if (PARAM.inp.nspin == 4)
389389
{
@@ -396,17 +396,17 @@ void toWannier90_PW::unkdotkb(
396396
// (2) fft and get value
397397
// int npw_ik = wfcpw->npwk[cal_ik];
398398
int npwx = wfcpw->npwk_max;
399-
wfcpw->recip2real(&psi_pw(cal_ik, im, 0), psir_up, cal_ik);
400-
// wfcpw->recip2real(&psi_pw(cal_ik, im, npw_ik), psir_dn, cal_ik);
401-
wfcpw->recip2real(&psi_pw(cal_ik, im, npwx), psir_dn, cal_ik);
399+
wfcpw->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(&psi_pw(cal_ik, im, 0), psir_up, cal_ik);
400+
// wfcpw->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(&psi_pw(cal_ik, im, npw_ik), psir_dn, cal_ik);
401+
wfcpw->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(&psi_pw(cal_ik, im, npwx), psir_dn, cal_ik);
402402
for (int ir = 0; ir < wfcpw->nrxx; ir++)
403403
{
404404
psir_up[ir] *= phase[ir];
405405
psir_dn[ir] *= phase[ir];
406406
}
407407

408-
wfcpw->real2recip(psir_up, psir_up, cal_ikb);
409-
wfcpw->real2recip(psir_dn, psir_dn, cal_ikb);
408+
wfcpw->real_to_recip<std::complex<double>,base_device::DEVICE_CPU>(psir_up, psir_up, cal_ikb);
409+
wfcpw->real_to_recip<std::complex<double>,base_device::DEVICE_CPU>(psir_dn, psir_dn, cal_ikb);
410410

411411
for (int n = 0; n < num_bands; n++)
412412
{
@@ -447,13 +447,12 @@ void toWannier90_PW::unkdotkb(
447447
ModuleBase::GlobalFunc::ZEROS(psir, wfcpw->nmaxgr);
448448

449449
// (2) fft and get value
450-
wfcpw->recip2real(&psi_pw(cal_ik, im, 0), psir, cal_ik);
450+
wfcpw->recip_to_real<std::complex<double>,base_device::DEVICE_CPU>(&psi_pw(cal_ik, im, 0), psir, cal_ik);
451451
for (int ir = 0; ir < wfcpw->nrxx; ir++)
452452
{
453453
psir[ir] *= phase[ir];
454454
}
455-
456-
wfcpw->real2recip(psir, psir, cal_ikb);
455+
wfcpw->real_to_recip<std::complex<double>,base_device::DEVICE_CPU>(psir, psir, cal_ikb);
457456

458457
for (int n = 0; n < num_bands; n++)
459458
{

source/source_pw/module_pwdft/stress_func_exx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void Stress_PW<FPTYPE, Device>::stress_exx(ModuleBase::matrix& sigma,
260260
// psi_nk in real space
261261
d_psi_in->fix_kb(ik, nband);
262262
T* psi_nk = d_psi_in->get_pointer();
263-
wfcpw->recip2real(psi_nk, psi_nk_real, ik);
263+
wfcpw->recip_to_real<std::complex<FPTYPE>,Device>(psi_nk, psi_nk_real, ik);
264264

265265
for (int iq = 0; iq < nqs; iq++)
266266
{
@@ -269,7 +269,7 @@ void Stress_PW<FPTYPE, Device>::stress_exx(ModuleBase::matrix& sigma,
269269
// psi_mq in real space
270270
d_psi_in->fix_kb(iq, mband);
271271
T* psi_mq = d_psi_in->get_pointer();
272-
wfcpw->recip2real(psi_mq, psi_mq_real, iq);
272+
wfcpw->recip_to_real<std::complex<FPTYPE>,Device>(psi_mq, psi_mq_real, iq);
273273

274274
// overlap density in real space
275275
setmem_complex_op()(density_real, 0.0, rhopw->nrxx);

0 commit comments

Comments
 (0)