Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive Blocking (Auto) for Exchange #32

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
17 changes: 15 additions & 2 deletions src/mVMC/vmcmake.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,22 @@ void VMCMakeSample(MPI_Comm comm) {
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
// Simple stragegy for hopping.
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;
else {
const char *adaptiveBlocking = getenv("VMC_EXCHANGE_ADAPTIVE_BLOCKING");
const int adjustBlock = adaptiveBlocking && atoi(adaptiveBlocking) && Counter[2] != 0;
const double acceptance = adjustBlock ? (double)Counter[3] / Counter[2] : 1.0;
// Exchange updates may yield very low acc-ratio. Adjust block size accordingly.
if (acceptance < 0.01)
NBlockUpdateSize = 2;
else if (acceptance < 0.05)
NBlockUpdateSize = 4;
else if (acceptance < 0.10)
NBlockUpdateSize = 8;
else
NBlockUpdateSize = 20;
}

// Set one universal EleSpn.
for (mi=0; mi<Ne; mi++) EleSpn[mi] = 0;
Expand Down
17 changes: 15 additions & 2 deletions src/mVMC/vmcmake_fsz.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,22 @@ void VMCMakeSample_fsz(MPI_Comm comm) {
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
// Simple stragegy for hopping.
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;
else {
const char *adaptiveBlocking = getenv("VMC_EXCHANGE_ADAPTIVE_BLOCKING");
const int adjustBlock = adaptiveBlocking && atoi(adaptiveBlocking) && Counter[2] != 0;
const double acceptance = adjustBlock ? (double)Counter[3] / Counter[2] : 1.0;
// Exchange updates may yield very low acc-ratio. Adjust block size accordingly.
if (acceptance < 0.01)
NBlockUpdateSize = 2;
else if (acceptance < 0.05)
NBlockUpdateSize = 4;
else if (acceptance < 0.10)
NBlockUpdateSize = 8;
else
NBlockUpdateSize = 20;
}

// Initialize with free spin configuration.
updated_tdi_v_init_z(NQPFull, Nsite, Nsite2, Nsize,
Expand Down
28 changes: 23 additions & 5 deletions src/mVMC/vmcmake_fsz_real.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,29 @@ void VMCMakeSample_fsz_real(MPI_Comm comm) {
// TODO: Compute from qpStart to qpEnd to support loop splitting.
void *pfOrbital[NQPFull];
void *pfUpdator[NQPFull];
// TODO: Make it input parameter.
if (NExUpdatePath == 0)
NBlockUpdateSize = 4;
else
NBlockUpdateSize = 20;
// Read block size from input.
const char *optBlockSize = getenv("VMC_BLOCK_UPDATE_SIZE");
if (optBlockSize)
NBlockUpdateSize = atoi(optBlockSize);
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
// Simple stragegy for hopping.
NBlockUpdateSize = 2;
else {
const char *adaptiveBlocking = getenv("VMC_EXCHANGE_ADAPTIVE_BLOCKING");
const int adjustBlock = adaptiveBlocking && atoi(adaptiveBlocking) && Counter[2] != 0;
const double acceptance = adjustBlock ? (double)Counter[3] / Counter[2] : 1.0;
// Exchange updates may yield very low acc-ratio. Adjust block size accordingly.
if (acceptance < 0.01)
NBlockUpdateSize = 2;
else if (acceptance < 0.05)
NBlockUpdateSize = 4;
else if (acceptance < 0.10)
NBlockUpdateSize = 8;
else
NBlockUpdateSize = 20;
}

// Initialize with free spin configuration.
updated_tdi_v_init_d(NQPFull, Nsite, Nsite2, Nsize,
Expand Down
17 changes: 15 additions & 2 deletions src/mVMC/vmcmake_real.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,22 @@ void VMCMakeSample_real(MPI_Comm comm) {
// Fall back to default if input is invalid.
if (NBlockUpdateSize < 1 || NBlockUpdateSize > 100)
if (NExUpdatePath == 0)
// Simple stragegy for hopping.
NBlockUpdateSize = 2;
else
NBlockUpdateSize = 20;
else {
const char *adaptiveBlocking = getenv("VMC_EXCHANGE_ADAPTIVE_BLOCKING");
const int adjustBlock = adaptiveBlocking && atoi(adaptiveBlocking) && Counter[2] != 0;
const double acceptance = adjustBlock ? (double)Counter[3] / Counter[2] : 1.0;
// Exchange updates may yield very low acc-ratio. Adjust block size accordingly.
if (acceptance < 0.01)
NBlockUpdateSize = 2;
else if (acceptance < 0.05)
NBlockUpdateSize = 4;
else if (acceptance < 0.10)
NBlockUpdateSize = 8;
else
NBlockUpdateSize = 20;
}

// Set one universal EleSpn.
for (mi=0; mi<Ne; mi++) EleSpn[mi] = 0;
Expand Down