Skip to content

Commit

Permalink
Reformat source files using clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed Dec 13, 2024
1 parent f451add commit 57181f0
Show file tree
Hide file tree
Showing 14 changed files with 550 additions and 810 deletions.
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
19 changes: 11 additions & 8 deletions src/GPU/CUDAMemoryManager.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@
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>.
********************************************************************************/
#ifndef CUDA_MEMORY_MANAGER_H
#define CUDA_MEMORY_MANAGER_H

#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
Expand Down
Loading

0 comments on commit 57181f0

Please sign in to comment.