Skip to content

Commit 6ef7d52

Browse files
author
abacus_fixer
committed
fix(exx): add explicit template instantiation in op_pw_exx_ace.cpp
op_pw_exx_ace.cpp defines ACE-specific template members (act_op_ace, construct_ace, cal_exx_energy_ace) but lacked explicit instantiations. The extern template class declaration in op_pw_exx.h suppressed implicit instantiation everywhere, and the template class instantiations in op_pw_exx.cpp could not see definitions in this translation unit, leading to linker undefined reference errors. Add template class instantiations for CPU and GPU variants at the end of op_pw_exx_ace.cpp so these members emit symbols.
1 parent ec160ec commit 6ef7d52

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

source/source_pw/module_pwdft/op_pw_exx_ace.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,13 @@ double OperatorEXXPW<T, Device>::cal_exx_energy_ace(psi::Psi<T, Device>* ppsi_)
320320
Eexx = Eexx / hybrid_alpha / 2; // This factor of 2 is from the definition of EXX energy.
321321
return Eexx;
322322
}
323+
324+
// Explicit instantiation for members defined in this translation unit.
325+
template class OperatorEXXPW<std::complex<float>, base_device::DEVICE_CPU>;
326+
template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_CPU>;
327+
#if ((defined __CUDA) || (defined __ROCM))
328+
template class OperatorEXXPW<std::complex<float>, base_device::DEVICE_GPU>;
329+
template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_GPU>;
330+
#endif
331+
323332
} // namespace hamilt

0 commit comments

Comments
 (0)