File tree Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -71,21 +71,6 @@ ESolver_KS_PW<T, Device>::~ESolver_KS_PW()
7171 this ->pelec = nullptr ;
7272 }
7373
74- if (this ->device == base_device::GpuDevice)
75- {
76- #if defined(__CUDA) || defined(__ROCM)
77- ModuleBase::destoryBLAShandle ();
78- hsolver::destroyGpuSolverHandle ();
79- container::kernels::destroyGpuBlasHandle ();
80- container::kernels::destroyGpuSolverHandle ();
81- #endif
82- }
83-
84- #ifdef __DSP
85- std::cout << " ** Closing DSP Hardware..." << std::endl;
86- mtfunc::dspDestoryHandle (GlobalV::MY_RANK);
87- #endif
88-
8974 if (PARAM.inp .device == " gpu" || PARAM.inp .precision == " single" )
9075 {
9176 delete this ->kspw_psi ;
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ class Driver
4040
4141 // Init harewares according to Input parameters
4242 void init_hardware ();
43+ void finalize_hardware ();
4344};
4445
4546#endif
Original file line number Diff line number Diff line change @@ -106,14 +106,16 @@ void Driver::driver_run()
106106 p_esolver->after_all_runners (ucell);
107107
108108 ModuleESolver::clean_esolver (p_esolver);
109+ this ->finalize_hardware ();
109110
110111 // ! 6: output the json file
111112 Json::create_Json (&ucell, PARAM);
112113
113114 return ;
114115}
115116
116- void Driver::init_hardware (){
117+ void Driver::init_hardware ()
118+ {
117119#if ((defined __CUDA) || (defined __ROCM))
118120 if (PARAM.inp .device == " gpu" )
119121 {
@@ -129,3 +131,21 @@ void Driver::init_hardware(){
129131 mtfunc::dspInitHandle (GlobalV::MY_RANK);
130132#endif
131133}
134+
135+ void Driver::finalize_hardware ()
136+ {
137+ #if defined(__CUDA) || defined(__ROCM)
138+ if (PARAM.inp .device == " gpu" )
139+ {
140+ ModuleBase::destoryBLAShandle ();
141+ hsolver::destroyGpuSolverHandle ();
142+ container::kernels::destroyGpuBlasHandle ();
143+ container::kernels::destroyGpuSolverHandle ();
144+ }
145+ #endif
146+
147+ #ifdef __DSP
148+ std::cout << " ** Closing DSP Hardware..." << std::endl;
149+ mtfunc::dspDestoryHandle (GlobalV::MY_RANK);
150+ #endif
151+ }
You can’t perform that action at this time.
0 commit comments