1616#include " module_hamilt_general/module_surchem/surchem.h"
1717#include " module_hamilt_general/module_vdw/vdw.h"
1818#include " kernels/force_op.h"
19-
19+ # include < type_traits >
2020#ifdef _OPENMP
2121#include < omp.h>
2222#endif
@@ -579,7 +579,7 @@ void Forces<FPTYPE, Device>::cal_force_loc(const UnitCell& ucell,
579579 syncmem_var_h2d_op ()(this ->ctx , this ->cpu_ctx , forcelc_d, forcelc.c , this ->nat * 3 );
580580 syncmem_var_h2d_op ()(this ->ctx , this ->cpu_ctx , vloc_d, vloc.c , vloc.nr * vloc.nc );
581581
582- hamilt::cal_force_loc_op<FPTYPE , Device>()(
582+ /* hamilt::cal_force_loc_op<FPTYPE, Device>()(
583583 this->nat,
584584 rho_basis->npw,
585585 ucell.tpiba * ucell.omega,
@@ -590,7 +590,35 @@ void Forces<FPTYPE, Device>::cal_force_loc(const UnitCell& ucell,
590590 aux_d,
591591 vloc_d,
592592 vloc.nc,
593- forcelc_d);
593+ forcelc_d);*/
594+
595+ #if defined(__ROCM) || defined(__UT_USE_ROCM)
596+ hamilt::cal_force_loc_sincos_op<FPTYPE , Device>()(
597+ this ->ctx ,
598+ this ->nat ,
599+ rho_basis->npw ,
600+ ucell.ntype ,
601+ gcar_d,
602+ tau_d,
603+ vloc_d,
604+ aux_d,
605+ static_cast <FPTYPE >(ucell.tpiba * ucell.omega ),
606+ forcelc_d);
607+ #else
608+ hamilt::cal_force_loc_op<FPTYPE , Device>()(
609+ this ->nat ,
610+ rho_basis->npw ,
611+ ucell.tpiba * ucell.omega ,
612+ iat2it_d,
613+ ig2gg_d,
614+ gcar_d,
615+ tau_d,
616+ aux_d,
617+ vloc_d,
618+ vloc.nc ,
619+ forcelc_d);
620+ #endif
621+
594622 syncmem_var_d2h_op ()(this ->cpu_ctx , this ->ctx , forcelc.c , forcelc_d, this ->nat * 3 );
595623
596624 delmem_int_op ()(this ->ctx ,iat2it_d);
@@ -788,7 +816,7 @@ void Forces<FPTYPE, Device>::cal_force_ew(const UnitCell& ucell,
788816 syncmem_complex_h2d_op ()(this ->ctx , this ->cpu_ctx , aux_d, aux.data (), rho_basis->npw );
789817 syncmem_var_h2d_op ()(this ->ctx , this ->cpu_ctx , forceion_d, forceion.c , this ->nat * 3 );
790818
791- hamilt::cal_force_ew_op<FPTYPE , Device>()(
819+ /* hamilt::cal_force_ew_op<FPTYPE, Device>()(
792820 this->nat,
793821 rho_basis->npw,
794822 rho_basis->ig_gge0,
@@ -798,7 +826,31 @@ void Forces<FPTYPE, Device>::cal_force_ew(const UnitCell& ucell,
798826 it_fact_d,
799827 aux_d,
800828 forceion_d);
801-
829+ */
830+
831+ #if defined(__ROCM) || defined(__UT_USE_ROCM)
832+ hamilt::cal_force_ew_sincos_op<FPTYPE , Device>()(
833+ this ->ctx ,
834+ this ->nat ,
835+ rho_basis->npw ,
836+ rho_basis->ig_gge0 ,
837+ gcar_d,
838+ tau_d,
839+ it_fact_d,
840+ aux_d,
841+ forceion_d);
842+ #else
843+ hamilt::cal_force_ew_op<FPTYPE , Device>()(
844+ this ->nat ,
845+ rho_basis->npw ,
846+ rho_basis->ig_gge0 ,
847+ iat2it_d,
848+ gcar_d,
849+ tau_d,
850+ it_fact_d,
851+ aux_d,
852+ forceion_d);
853+ #endif
802854 syncmem_var_d2h_op ()(this ->cpu_ctx , this ->ctx , forceion.c , forceion_d, this ->nat * 3 );
803855 delmem_int_op ()(this ->ctx ,iat2it_d);
804856 delmem_var_op ()(this ->ctx ,gcar_d);
@@ -917,8 +969,25 @@ void Forces<FPTYPE, Device>::cal_force_ew(const UnitCell& ucell,
917969 return ;
918970}
919971
972+ namespace hamilt {
973+
974+ #if defined(__ROCM) || defined(__HIP_PLATFORM_AMD__)
975+ template struct cal_force_ew_sincos_op <double , base_device::DEVICE_GPU >;
976+ template struct cal_force_ew_sincos_op <float , base_device::DEVICE_GPU >;
977+
978+ template struct cal_force_loc_sincos_op <double , base_device::DEVICE_GPU >;
979+ template struct cal_force_loc_sincos_op <float , base_device::DEVICE_GPU >;
980+ #endif
981+
982+ #if defined(__CUDA) || defined(__NVCC__)
983+ template struct cal_force_ew_op <double , base_device::DEVICE_GPU >;
984+ template struct cal_force_ew_op <float , base_device::DEVICE_GPU >;
920985
986+ template struct cal_force_loc_op <double , base_device::DEVICE_GPU >;
987+ template struct cal_force_loc_op <float , base_device::DEVICE_GPU >;
988+ #endif
921989
990+ } // namespace hamilt
922991template class Forces <double , base_device::DEVICE_CPU >;
923992#if ((defined __CUDA) || (defined __ROCM))
924993template class Forces <double , base_device::DEVICE_GPU >;
0 commit comments