Skip to content

Commit a9a13de

Browse files
committed
Fix(build): resolve merge conflicts and fix GPU compilation
- cusolver.h: remove duplicate unique_cuda_ptr/unique_host_ptr definitions (kept in cuda.h) to fix std::unique_ptr conversion error - force_op.h/cu/hip.cu: restore isk parameter in GPU DeltaSpin kernels to match updated caller in onsite_proj_tools.cpp Remove duplicate spin_sign declaration from merge - spin_constrain.h/init_sc.cpp: add cached basis_type_, ks_solver_, nbands_ member variables for governance PARAM reduction
1 parent 8791665 commit a9a13de

6 files changed

Lines changed: 19 additions & 19 deletions

File tree

source/source_base/module_container/base/third_party/cusolver.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,6 @@
2020
namespace container {
2121
namespace cuSolverConnector {
2222

23-
struct CudaDeleter {
24-
void operator()(void* ptr) const noexcept {
25-
if (ptr) cudaFree(ptr);
26-
}
27-
};
28-
29-
template <typename T>
30-
using unique_cuda_ptr = std::unique_ptr<T, CudaDeleter>;
31-
32-
struct HostDeleter {
33-
void operator()(void* ptr) const noexcept {
34-
if (ptr) free(ptr);
35-
}
36-
};
37-
38-
template <typename T>
39-
using unique_host_ptr = std::unique_ptr<T, HostDeleter>;
40-
4123
#if CUDA_VERSION >= 11000
4224
// Generic API (CUDA 11.0+)
4325
template <typename T>

source/source_lcao/module_deltaspin/init_sc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ void spinconstrain::SpinConstrain<TK>::init_sc(double sc_thr_in,
5757
this->set_input_parameters(sc_thr_in, nsc_in, nsc_min_in, alpha_trial_in, sccut_in, sc_drop_thr_in,
5858
sc_acceleration_mode_in, sc_acceleration_rms_thr_in);
5959

60+
this->basis_type_ = PARAM.inp.basis_type;
61+
this->ks_solver_ = PARAM.inp.ks_solver;
62+
this->nbands_ = PARAM.inp.nbands;
63+
6064
// Step 2: Get atom/orbital/lnchi counts from UnitCell for indexing
6165
// atomCounts: {element_type_index -> number_of_atoms_of_this_type}
6266
// orbitalCounts: {element_type_index -> number_of_orbitals_per_atom}

source/source_lcao/module_deltaspin/spin_constrain.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,10 @@ class SpinConstrain
10421042
std::vector<ModuleBase::Vector3<double>> lcao_lambda_in_sub_;
10431043
/// Acceleration mode parameters
10441044
std::string sc_acceleration_mode_ = "off"; ///< "off", "first_order", "subspace"
1045-
double sc_acceleration_rms_thr_ = -1.0; ///< RMS threshold (uB) to activate acceleration, <0 disables
1045+
double sc_acceleration_rms_thr_ = -1.0; ///< RMS threshold (uB) to activate acceleration, <0 disables
1046+
std::string basis_type_; ///< Cached basis type for LCAO/PW branching
1047+
std::string ks_solver_; ///< Cached KS solver name
1048+
int nbands_ = 0; ///< Cached number of bands
10461049
bool acceleration_active_ = false; ///< Has acceleration been activated this SCF iteration?
10471050
bool acceleration_subspace_built_ = false; ///< Has subspace been built at activation lambda?
10481051
bool subspace_just_activated_ = false; ///< Was subspace just activated? (signals BFGS to reset search direction)

source/source_pw/module_pwdft/kernels/cuda/force_op.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,16 @@ void cal_force_nl_op<FPTYPE, base_device::DEVICE_GPU>::operator()(const base_dev
545545
const FPTYPE& tpiba,
546546
const FPTYPE* d_wg,
547547
const FPTYPE* lambda,
548+
const int* isk,
548549
const std::complex<FPTYPE>* becp,
549550
const std::complex<FPTYPE>* dbecp,
550551
FPTYPE* force)
551552
{
552553
int spin_sign = 1;
554+
if (isk != nullptr && npol == 1)
555+
{
556+
spin_sign = (isk[ik] == 0) ? 1 : -1;
557+
}
553558
if (npol == 1)
554559
{
555560
cal_force_onsite<FPTYPE, 1>

source/source_pw/module_pwdft/kernels/force_op.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ struct cal_force_nl_op<FPTYPE, base_device::DEVICE_GPU>
278278
const FPTYPE& tpiba,
279279
const FPTYPE* d_wg,
280280
const FPTYPE* lambda,
281+
const int* isk,
281282
const std::complex<FPTYPE>* becp,
282283
const std::complex<FPTYPE>* dbecp,
283284
FPTYPE* force);

source/source_pw/module_pwdft/kernels/rocm/force_op.hip.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,16 @@ void cal_force_nl_op<FPTYPE, base_device::DEVICE_GPU>::operator()(const base_dev
539539
const FPTYPE& tpiba,
540540
const FPTYPE* d_wg,
541541
const FPTYPE* lambda,
542+
const int* isk,
542543
const std::complex<FPTYPE>* becp,
543544
const std::complex<FPTYPE>* dbecp,
544545
FPTYPE* force)
545546
{
546547
int spin_sign = 1;
548+
if (isk != nullptr && npol == 1)
549+
{
550+
spin_sign = (isk[ik] == 0) ? 1 : -1;
551+
}
547552
if (npol == 1)
548553
{
549554
hipLaunchKernelGGL(HIP_KERNEL_NAME(cal_force_onsite<FPTYPE, 1>),

0 commit comments

Comments
 (0)