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

Forcefield params do not match between CPU and GPU #535

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
8 changes: 4 additions & 4 deletions src/BlockOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ struct BlockAverages : OutputableBase {
stepsPerOut = event.frequency;
invSteps = 1.0 / stepsPerOut;
firstInvSteps = invSteps;
//Handle the case where we are restarting from a checkpoint and the first
//interval is smaller than expected because we create a checkpoint more
//often than the Block output frequency.
// Handle the case where we are restarting from a checkpoint and the first
// interval is smaller than expected because we create a checkpoint more
// often than the Block output frequency.
if (startStep != 0 && (startStep % stepsPerOut) != 0) {
ulong diff;
diff = stepsPerOut - (startStep % stepsPerOut);
firstInvSteps = 1.0/diff;
firstInvSteps = 1.0 / diff;
}
enableOut = event.enable;
}
Expand Down
59 changes: 33 additions & 26 deletions src/ConfigSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,15 +1897,13 @@ void ConfigSetup::verifyInputs(void) {
std::cout << "ERROR: Impulse Pressure Correction cannot be "
<< "used with LJ long-range corrections." << std::endl;
exit(EXIT_FAILURE);

}
if (((sys.ff.VDW_KIND == sys.ff.VDW_SHIFT_KIND) ||
(sys.ff.VDW_KIND == sys.ff.VDW_SWITCH_KIND)) &&
sys.ff.doImpulsePressureCorr) {
std::cout << "ERROR: Impulse Pressure Correction is not supported "
<< "for SWITCH or SHIFT potentials." << std::endl;
exit(EXIT_FAILURE);

}
if (sys.ff.doImpulsePressureCorr && sys.ff.doTailCorr) {
std::cout << "ERROR: Both LRC (Long Range Correction) and "
Expand Down Expand Up @@ -2104,9 +2102,10 @@ void ConfigSetup::verifyInputs(void) {
if (in.restart.restartFromBinaryCoorFile) {
for (i = 0; i < BOX_TOTAL; i++) {
if (!in.files.binaryCoorInput.defined[i]) {
std::cout << "ERROR: Binary coordinate file was not specified for box "
"number "
<< i << "!" << std::endl;
std::cout
<< "ERROR: Binary coordinate file was not specified for box "
"number "
<< i << "!" << std::endl;
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -2174,25 +2173,30 @@ void ConfigSetup::verifyInputs(void) {
if ((sys.memcVal.MEMC1 && sys.memcVal.MEMC2) ||
(sys.memcVal.MEMC1 && sys.memcVal.MEMC3) ||
(sys.memcVal.MEMC2 && sys.memcVal.MEMC3)) {
std::cout << "ERROR: Multiple MEMC methods were specified, but only one is allowed!\n";
std::cout << "ERROR: Multiple MEMC methods were specified, but only one "
"is allowed!\n";
exit(EXIT_FAILURE);
}
if ((sys.intraMemcVal.MEMC1 && sys.intraMemcVal.MEMC2) ||
(sys.intraMemcVal.MEMC1 && sys.intraMemcVal.MEMC3) ||
(sys.intraMemcVal.MEMC2 && sys.intraMemcVal.MEMC3)) {
std::cout << "ERROR: Multiple Intra-MEMC methods are specified, but only one is allowed!\n";
std::cout << "ERROR: Multiple Intra-MEMC methods are specified, but only "
"one is allowed!\n";
exit(EXIT_FAILURE);
}
if (!sys.memcVal.readVol || !sys.intraMemcVal.readVol) {
std::cout << "ERROR: In the MEMC method, the Sub-Volume was not specified!\n";
std::cout
<< "ERROR: In the MEMC method, the Sub-Volume was not specified!\n";
exit(EXIT_FAILURE);
}
if (!sys.memcVal.readRatio || !sys.intraMemcVal.readRatio) {
std::cout << "ERROR: In the MEMC method, Exchange Ratio was not specified!\n";
std::cout
<< "ERROR: In the MEMC method, Exchange Ratio was not specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.largeKind.size() != sys.memcVal.exchangeRatio.size()) {
std::cout << "ERROR: In the MEMC method, the specified number of Large Kinds was "
std::cout << "ERROR: In the MEMC method, the specified number of Large "
"Kinds was "
<< sys.memcVal.largeKind.size() << ", but "
<< sys.memcVal.exchangeRatio.size()
<< " exchange ratio was specified!\n";
Expand All @@ -2209,49 +2213,52 @@ void ConfigSetup::verifyInputs(void) {
if ((sys.memcVal.largeKind.size() != sys.memcVal.smallKind.size()) ||
(sys.intraMemcVal.largeKind.size() !=
sys.intraMemcVal.smallKind.size())) {
std::cout
<< "ERROR: In the MEMC method, the specified number of Large Kinds is not "
<< " equal as specified number of Small Kinds!\n";
std::cout << "ERROR: In the MEMC method, the specified number of Large "
"Kinds is not "
<< " equal as specified number of Small Kinds!\n";
exit(EXIT_FAILURE);
}
if (!sys.memcVal.readLargeBB || !sys.intraMemcVal.readLargeBB) {
std::cout
<< "ERROR: In the MEMC method, Large Kind BackBone was not specified!\n";
std::cout << "ERROR: In the MEMC method, Large Kind BackBone was not "
"specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.largeKind.size() != sys.memcVal.largeBBAtom1.size()) {
std::cout << "ERROR: In the MEMC method, the specified number of Large Kinds was "
std::cout << "ERROR: In the MEMC method, the specified number of Large "
"Kinds was "
<< sys.memcVal.largeKind.size() << ", but "
<< sys.memcVal.largeBBAtom1.size()
<< " sets of Large Molecule BackBone was specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.MEMC2 && !sys.memcVal.readSmallBB) {
std::cout
<< "ERROR: In the MEMC-2 method, Small Kind BackBone was not specified!\n";
std::cout << "ERROR: In the MEMC-2 method, Small Kind BackBone was not "
"specified!\n";
exit(EXIT_FAILURE);
}

if (sys.memcVal.MEMC2 &&
(sys.memcVal.smallKind.size() != sys.memcVal.smallBBAtom1.size())) {
std::cout
<< "ERROR: In the MEMC-2 method, the specified number of Small Kinds was "
<< sys.memcVal.smallKind.size() << ", but "
<< sys.memcVal.smallBBAtom1.size()
<< " sets of Small Molecule BackBone was specified!\n";
std::cout << "ERROR: In the MEMC-2 method, the specified number of Small "
"Kinds was "
<< sys.memcVal.smallKind.size() << ", but "
<< sys.memcVal.smallBBAtom1.size()
<< " sets of Small Molecule BackBone was specified!\n";
exit(EXIT_FAILURE);
}

if (sys.intraMemcVal.MEMC2 && !sys.intraMemcVal.readSmallBB) {
std::cout << "ERROR: In the Intra-MEMC-2 method, Small Kind BackBone was not "
"specified!\n";
std::cout
<< "ERROR: In the Intra-MEMC-2 method, Small Kind BackBone was not "
"specified!\n";
exit(EXIT_FAILURE);
}
if (sys.memcVal.enable && sys.intraMemcVal.enable) {
if ((sys.memcVal.MEMC1 && !sys.intraMemcVal.MEMC1) ||
(sys.memcVal.MEMC2 && !sys.intraMemcVal.MEMC2) ||
(sys.memcVal.MEMC3 && !sys.intraMemcVal.MEMC3)) {
std::cout << "ERROR: The selected intra-MEMC method was not same as the inter-MEMC method!\n";
std::cout << "ERROR: The selected intra-MEMC method was not same as "
"the inter-MEMC method!\n";
exit(EXIT_FAILURE);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Ewald.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,7 @@ void Ewald::BoxForceReciprocal(XYZArray const &molCoords,
CallBoxForceReciprocalGPU(
ff.particles->getCUDAVars(), atomForceRec, molForceRec, particleCharge,
particleMol, particleHasNoCharge, particleUsed, startMol, lengthMol,
ff.alpha[box], ff.alphaSq[box], constValue, imageSizeRef[box],
molCoords, currentAxes, box);
constValue, imageSizeRef[box], molCoords, currentAxes, box);
delete[] particleUsed;
#else
// molecule iterator
Expand Down
7 changes: 4 additions & 3 deletions src/FFParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ void FFParticle::Init(ff_setup::Particle const &mie,
double diElectric_1 = 1.0 / forcefield.dielectric;
InitGPUForceField(*varCUDA, sigmaSq, epsilon_cn, n, forcefield.vdwKind,
forcefield.isMartini, count, forcefield.rCut,
forcefield.rCutCoulomb, forcefield.rCutLow,
forcefield.rswitch, forcefield.alpha, forcefield.ewald,
diElectric_1);
forcefield.rCutSq, forcefield.rCutCoulomb,
forcefield.rCutCoulombSq, forcefield.rCutLow,
forcefield.rswitch, forcefield.alpha, forcefield.alphaSq,
forcefield.ewald, diElectric_1);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/Forcefield.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ class Forcefield {
double tolerance; // Ewald sum terms
double rswitch; // Switch distance
double dielectric; // dielectric for martini
double scaling_14; //!< Scaling factor for 1-4 pairs' ewald interactions
double scaling_14; //!< Scaling factor for 1-4 pairs' Ewald interactions
double sc_alpha; // Free energy parameter
double sc_sigma, sc_sigma_6; // Free energy parameter

bool OneThree, OneFour, OneN; // To include 1-3, 1-4 and more interaction
bool electrostatic, ewald; // To consider columb interaction
bool electrostatic, ewald; // To consider coulomb interaction
bool vdwGeometricSigma; // For sigma combining rule
bool isMartini;
bool exp6;
Expand Down
19 changes: 11 additions & 8 deletions src/GPU/CUDAMemoryManager.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@
GPU OPTIMIZED MONTE CARLO (GOMC) 2.75
Copyright (C) 2022 GOMC Group
A copy of the MIT License can be found in License.txt
along with this program, also can be found at <https://opensource.org/licenses/MIT>.
along with this program, also can be found at
<https://opensource.org/licenses/MIT>.
********************************************************************************/
#pragma once
#ifdef GOMC_CUDA
#include <cuda.h>
#include <cuda_runtime.h>
#include <unordered_map>
#include <iostream>
#include <unordered_map>

#define CUMALLOC(address,size) CUDAMemoryManager::mallocMemory(address,size,#address)
#define CUFREE(address) CUDAMemoryManager::freeMemory(address,#address)
#define CUMALLOC(address, size) \
CUDAMemoryManager::mallocMemory(address, size, #address)
#define CUFREE(address) CUDAMemoryManager::freeMemory(address, #address)

class CUDAMemoryManager
{
class CUDAMemoryManager {
public:
static cudaError_t mallocMemory(void **address, unsigned int size, std::string var_name);
static cudaError_t mallocMemory(void **address, unsigned int size,
std::string var_name);
static cudaError_t freeMemory(void *address, std::string var_name);
static bool isFreed();

private:
static long long totalAllocatedBytes;
static std::unordered_map<void *, std::pair<unsigned int, std::string> > allocatedPointers;
static std::unordered_map<void *, std::pair<unsigned int, std::string>>
allocatedPointers;
};

#endif
Loading
Loading