Skip to content

Commit 2623735

Browse files
committed
Merge branch 'develop' into fft1
2 parents f07a97d + cead7ce commit 2623735

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

source/module_base/blas_connector.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ float BlasConnector::dot( const int n, const float *X, const int incX, const flo
6969
{
7070
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
7171
return sdot_(&n, X, &incX, Y, &incY);
72+
}
7273
return sdot_(&n, X, &incX, Y, &incY);
7374
}
74-
}
7575

7676
double BlasConnector::dot( const int n, const double *X, const int incX, const double *Y, const int incY, base_device::AbacusDevice_t device_type)
7777
{
7878
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
7979
return ddot_(&n, X, &incX, Y, &incY);
80+
}
8081
return ddot_(&n, X, &incX, Y, &incY);
8182
}
82-
}
8383

8484
// C = a * A.? * B.? + b * C
8585
void BlasConnector::gemm(const char transa, const char transb, const int m, const int n, const int k,
@@ -196,39 +196,39 @@ float BlasConnector::nrm2( const int n, const float *X, const int incX, base_dev
196196
{
197197
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
198198
return snrm2_( &n, X, &incX );
199+
}
199200
return snrm2_( &n, X, &incX );
200201
}
201-
}
202202

203203

204204
double BlasConnector::nrm2( const int n, const double *X, const int incX, base_device::AbacusDevice_t device_type )
205205
{
206206
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
207207
return dnrm2_( &n, X, &incX );
208+
}
208209
return dnrm2_( &n, X, &incX );
209210
}
210-
}
211211

212212

213213
double BlasConnector::nrm2( const int n, const std::complex<double> *X, const int incX, base_device::AbacusDevice_t device_type )
214214
{
215215
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
216216
return dznrm2_( &n, X, &incX );
217+
}
217218
return dznrm2_( &n, X, &incX );
218219
}
219-
}
220220

221221
// copies a into b
222222
void BlasConnector::copy(const long n, const double *a, const int incx, double *b, const int incy, base_device::AbacusDevice_t device_type)
223223
{
224224
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
225225
dcopy_(&n, a, &incx, b, &incy);
226-
}
226+
}
227227
}
228228

229229
void BlasConnector::copy(const long n, const std::complex<double> *a, const int incx, std::complex<double> *b, const int incy, base_device::AbacusDevice_t device_type)
230230
{
231231
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
232232
zcopy_(&n, a, &incx, b, &incy);
233-
}
233+
}
234234
}

source/module_elecstate/module_charge/charge_mixing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,11 +1708,6 @@ bool Charge_Mixing::if_scf_oscillate(const int iteration, const double drho, con
17081708
ModuleBase::TITLE("Charge_Mixing", "if_scf_oscillate");
17091709
ModuleBase::timer::tick("Charge_Mixing", "if_scf_oscillate");
17101710

1711-
if(threshold >= 0) // close the function
1712-
{
1713-
return false;
1714-
}
1715-
17161711
if(this->_drho_history.size() == 0)
17171712
{
17181713
this->_drho_history.resize(PARAM.inp.scf_nmax);
@@ -1721,8 +1716,13 @@ bool Charge_Mixing::if_scf_oscillate(const int iteration, const double drho, con
17211716
// add drho into history
17221717
this->_drho_history[iteration - 1] = drho;
17231718

1719+
if(threshold >= 0) // close the function
1720+
{
1721+
return false;
1722+
}
1723+
17241724
// check if the history is long enough
1725-
if(iteration < iternum_used)
1725+
if(iteration < iternum_used + this->mixing_restart_last)
17261726
{
17271727
return false;
17281728
}

source/module_elecstate/module_charge/charge_mixing.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ class Charge_Mixing
102102
Base_Mixing::Mixing* get_mixing() const {return mixing;}
103103

104104
// for mixing restart
105-
int mixing_restart_step = 0; //which step to restart mixing during SCF
105+
int mixing_restart_step = 0; //which step to restart mixing during SCF, always equal to scf_namx except for the mixing restart
106106
int mixing_restart_count = 0; // the number of restart mixing during SCF. Do not set mixing_restart_count as bool since I want to keep some flexibility in the future
107+
int mixing_restart_last = 0; // the label of mixing restart step, store the step number of the last mixing restart
107108

108109
// to calculate the slope of drho curve during SCF, which is used to determine if SCF oscillate
109110
bool if_scf_oscillate(const int iteration, const double drho, const int iternum_used, const double threshold);

source/module_esolver/esolver_ks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ void ESolver_KS<T, Device>::iter_finish(const int istep, int& iter)
681681
// notice for restart
682682
if (PARAM.inp.mixing_restart > 0 && iter == this->p_chgmix->mixing_restart_step - 1 && iter != PARAM.inp.scf_nmax)
683683
{
684+
this->p_chgmix->mixing_restart_last = iter;
684685
std::cout << " SCF restart after this step!" << std::endl;
685686
}
686687
}

source/module_hsolver/kernels/cuda/math_kernel_op.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace hsolver
1313
{
1414
const int warp_size = 32;
15-
const unsigned int full_mask = 0xffffffff;
15+
// const unsigned int full_mask = 0xffffffff;
1616
const int thread_per_block = 256;
1717
}
1818

@@ -65,11 +65,11 @@ void destoryBLAShandle(){
6565
}
6666
}
6767

68-
template <typename FPTYPE>
69-
__forceinline__ __device__ void warp_reduce(FPTYPE& val) {
70-
for (int offset = 16; offset > 0; offset >>= 1)
71-
val += __shfl_down_sync(full_mask, val, offset);
72-
}
68+
// template <typename FPTYPE>
69+
// __forceinline__ __device__ void warp_reduce(FPTYPE& val) {
70+
// for (int offset = 16; offset > 0; offset >>= 1)
71+
// val += __shfl_down_sync(full_mask, val, offset);
72+
// }
7373

7474
template <typename Real>
7575
__global__ void line_minimize_with_block(

0 commit comments

Comments
 (0)