Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/source_pw/module_stodft/sto_wf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ void Stochastic_WF<T, Device>::init_sto_orbitals(const int seed_in)
{
if (seed_in == 0 || seed_in == -1)
{
srand((unsigned)time(nullptr) + GlobalV::MY_RANK * 10000); // GlobalV global variables are reserved
srand(static_cast<unsigned>(time(nullptr))
+ GlobalV::MY_RANK * GlobalConst::RANDOM_SEED_OFFSET); // GlobalV global variables are reserved
}
else
{
srand((unsigned)std::abs(seed_in) + (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * 10000);
srand((unsigned)std::abs(seed_in)
+ (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * 10000);
}

this->allocate_chi0();
Expand Down Expand Up @@ -374,9 +376,7 @@ void Stochastic_WF<T, Device>::sync_chi0()
Device* ctx = {};
if (base_device::get_device_type<Device>(ctx) == base_device::GpuDevice)
{
syncmem_h2d_op()(this->chi0->get_pointer(),
this->chi0_cpu->get_pointer(),
this->chi0_cpu->size());
syncmem_h2d_op()(this->chi0->get_pointer(), this->chi0_cpu->get_pointer(), this->chi0_cpu->size());
}
}

Expand Down
6 changes: 5 additions & 1 deletion source/source_pw/module_stodft/sto_wf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// Generate stochastic wave functions
//----------------------------------------------
template <typename T, typename Device = base_device::DEVICE_CPU>
namespace GlobalConst
{
constexpr int RANDOM_SEED_OFFSET = 10000;
}
class Stochastic_WF
{
public:
Expand All @@ -33,7 +37,7 @@ class Stochastic_WF
int npwx = 0; ///< max ngk[ik] in all processors
int nbands_diag = 0; ///< number of bands obtained from diagonalization
int nbands_total = 0; ///< number of bands in total, nbands_total=nchi+nbands_diag;
std::vector<int> ngk; ///< ngk in klist
std::vector<int> ngk; ///< ngk in klist
public:
// Tn(H)|chi>
psi::Psi<T, Device>* chiallorder = nullptr;
Expand Down