Skip to content

Commit 073bf24

Browse files
author
abacus_fixer
committed
Fix ODR violation from duplicate explicit instantiation of OperatorEXXPW
Move extern template declarations to op_pw_exx.h so all translation units suppress implicit instantiation, and remove the duplicate explicit instantiation in op_pw_exx_ace.cpp. The single explicit instantiation in op_pw_exx.cpp remains the sole definition.
1 parent 905f820 commit 073bf24

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

source/source_pw/module_pwdft/op_pw_exx.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ class OperatorEXXPW : public OperatorPW<T, Device>
175175

176176
};
177177

178+
extern template class OperatorEXXPW<std::complex<float>, base_device::DEVICE_CPU>;
179+
extern template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_CPU>;
180+
#if ((defined __CUDA) || (defined __ROCM))
181+
extern template class OperatorEXXPW<std::complex<float>, base_device::DEVICE_GPU>;
182+
extern template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_GPU>;
183+
#endif
184+
178185
template <typename Real, typename Device>
179186
void get_exx_potential(const K_Vectors* kv,
180187
const ModulePW::PW_Basis_K* wfcpw,

source/source_pw/module_pwdft/op_pw_exx_ace.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,4 @@ 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-
template class OperatorEXXPW<std::complex<float>, base_device::DEVICE_CPU>;
324-
template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_CPU>;
325-
#if ((defined __CUDA) || (defined __ROCM))
326-
template class OperatorEXXPW<std::complex<float>, base_device::DEVICE_GPU>;
327-
template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_GPU>;
328-
#endif
329-
}
323+
} // namespace hamilt

0 commit comments

Comments
 (0)