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

Applied the new astyle to master #1180

Merged
merged 19 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ea3b17f
Proposing: removing lines with more than one statements. (#1114)
Iximiel Jan 16, 2025
7bbb431
backport of #1165
carlocamilloni Jan 16, 2025
017b9ef
Revert "Proposing: removing lines with more than one statements. (#11…
carlocamilloni Jan 17, 2025
53d5819
formatted astyle.sh + removed shellcheck warnings
Iximiel Sep 19, 2024
2cd41d1
restyle v2.9
Iximiel Oct 4, 2024
6062dd6
added .git-blame-ignore-revs file
Iximiel Jan 17, 2025
c86000e
Merge pull request #1179 from Iximiel/v2.9-astyle
carlocamilloni Jan 17, 2025
c82f2b4
Merge commit '53d5819fb75447905afcac66ae76ee2c14b6a514' into v2.10-as…
Iximiel Jan 17, 2025
852d195
Merge commit '2cd41d16623b7a062b2a716eaf5c91a741cc19ea' into v2.10-as…
Iximiel Jan 17, 2025
df88917
updated astyle options (plain merge or rebase this)
Iximiel Jan 17, 2025
df781b4
applyed astyle to v2.10 (merge with `-s ours`)
Iximiel Jan 17, 2025
5695b72
Merge remote-tracking branch 'upstream/v2.9' into v2.10-astyle-bis
Iximiel Jan 17, 2025
a0e76d0
udpated .git-blame-ignore-revs for v2.10
Iximiel Jan 17, 2025
29c3fd1
Merge pull request #1118 from Iximiel/v2.10-astyle
carlocamilloni Jan 17, 2025
9adf661
Merge commit 'df889170c00ea0ce6b69c2c6f690e6643b027a3e' into master-n…
Iximiel Jan 17, 2025
2c1e52d
Merge commit 'df781b48652d8cdde2994dae1197cdb623f3f3fa' into master-n…
Iximiel Jan 17, 2025
380bb46
applyed astyle to v2.11 (merge with `-s ours`)
Iximiel Jan 17, 2025
9e58467
Merge remote-tracking branch 'upstream/v2.10' into master-new-astyle
Iximiel Jan 17, 2025
d628684
udpated .git-blame-ignore-revs for v2.11
Iximiel Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 13 additions & 1 deletion .astyle.options
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
-n --indent=spaces=2 --keep-one-line-statements --keep-one-line-blocks
# long options can be written without the preceding '--'
suffix=none #equivalent to "-n"
style=attach
add-braces
indent=spaces=2
break-one-line-headers

# old options
#suffix=none
#indent=spaces=2
#keep-one-line-statements
#keep-one-line-blocks
# end old options
9 changes: 9 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# .git-blame-ignore-revs
# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
# please comment the hashes that you add to this
# new astyle applied to v2.9.3
2cd41d16623b7a062b2a716eaf5c91a741cc19ea
# new astyle applied to v2.10
df781b48652d8cdde2994dae1197cdb623f3f3fa
# new astyle applied to v2.11
380bb46eea1bc2a38fba94f3f72af2d8d6e41669
24 changes: 16 additions & 8 deletions plugins/cudaCoord/Coordination.cu
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,17 @@ void CudaCoordination<calculateFloat>::calculate() {
}

// in this way we do not resize with additional memory allocation
if (reductionMemoryCoord.size() > cudaCoordination.size())
if (reductionMemoryCoord.size() > cudaCoordination.size()) {
reductionMemoryCoord.swap (cudaCoordination);
if (reductionMemoryVirial.size() > cudaVirial.size())
}
if (reductionMemoryVirial.size() > cudaVirial.size()) {
reductionMemoryVirial.swap (cudaVirial);
}
// this ensures that the memory is fully in the host ram
cudaDeviceSynchronize();
for (unsigned i = 0; i < deriv.size(); ++i)
for (unsigned i = 0; i < deriv.size(); ++i) {
setAtomsDerivatives (i, deriv[i]);
}

setValue (coordination);
setBoxDerivatives (virial);
Expand Down Expand Up @@ -349,8 +352,9 @@ getSelfCoord (const unsigned nat,
// const unsigned j = threadIdx.y + blockIdx.y * blockDim.y;

// Safeguard
if (idx == trueIndexes[j])
if (idx == trueIndexes[j]) {
continue;
}

d_0 = calculatePBC<usePBC> (coordinates[X (j)] - x, myPBC.X);
d_1 = calculatePBC<usePBC> (coordinates[Y (j)] - y, myPBC.Y);
Expand Down Expand Up @@ -493,8 +497,9 @@ getCoordDual (const unsigned natActive,
// const unsigned j = threadIdx.y + blockIdx.y * blockDim.y;

// Safeguard
if (idx == trueIndexes[j])
if (idx == trueIndexes[j]) {
continue;
}

d_0 = calculatePBC<usePBC> (coordLoop[X (j)] - x, myPBC.X);
d_1 = calculatePBC<usePBC> (coordLoop[Y (j)] - y, myPBC.Y);
Expand Down Expand Up @@ -597,8 +602,9 @@ getDerivDual (const unsigned natLoop,
// const unsigned j = threadIdx.y + blockIdx.y * blockDim.y;

// Safeguard
if (idx == trueIndexes[j])
if (idx == trueIndexes[j]) {
continue;
}

d_0 = calculatePBC<usePBC> (coordLoop[X (j)] - x, myPBC.X);
d_1 = calculatePBC<usePBC> (coordLoop[Y (j)] - y, myPBC.Y);
Expand Down Expand Up @@ -880,7 +886,8 @@ CudaCoordination<calculateFloat>::CudaCoordination (const ActionOptions &ao)
}
std::string sw, errors;

{ // loading data to the GPU
{
// loading data to the GPU
int nn_ = 6;
int mm_ = 0;

Expand All @@ -895,8 +902,9 @@ CudaCoordination<calculateFloat>::CudaCoordination (const ActionOptions &ao)
if (mm_ == 0) {
mm_ = 2 * nn_;
}
if (mm_ % 2 != 0 || mm_ % 2 != 0)
if (mm_ % 2 != 0 || mm_ % 2 != 0) {
error (" this implementation only works with both MM and NN even");
}

switchingParameters.nn = nn_;
switchingParameters.mm = mm_;
Expand Down
6 changes: 4 additions & 2 deletions plugins/cudaCoord/Coordination.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ __device__ __forceinline__ calculateFloat pcuda_fastpow (calculateFloat base,
}
calculateFloat result = 1.0;
while (expo) {
if (expo & 1)
if (expo & 1) {
result *= base;
}
expo >>= 1;
base *= base;
}
Expand Down Expand Up @@ -156,8 +157,9 @@ __global__ void getpcuda_Rational (const calculateFloat *rdists,
if (rdists[i] <= 0.) {
res[i] = 1.;
dfunc[i] = 0.0;
} else
} else {
res[i] = pcuda_Rational (rdists[i], NN, MM, dfunc[i]);
}
// printf("stretch: %i: %f -> %f\n",i,rdists[i],res[i]);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/cudaCoord/cudaHelpers.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct DataInterface {
double *ptr = nullptr;
size_t size = 0;
DataInterface() = delete;

// VectorGeneric is a "memory map" on an n linear array
// &vg[0] gets the pointer to the first double in memory
// C++ vectors align memory so we can safely use the vector variant of
Expand Down
12 changes: 8 additions & 4 deletions plugins/pycv/PlumedPythonEmbeddedModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ PYBIND11_EMBEDDED_MODULE(plumedCommunications, m) {
auto retAccessor = atomIndexes.mutable_unchecked<1>();
for (decltype(nat) i=0; i < nat; ++i) {
//at time of writing getAbsoluteIndexes returns const std::vector<AtomNumber> &
retAccessor(i)=self->getAbsoluteIndexes()[i].index();
retAccessor(i)
=self->getAbsoluteIndexes()[i].index();
}
return atomIndexes;
},
Expand All @@ -129,7 +130,8 @@ PYBIND11_EMBEDDED_MODULE(plumedCommunications, m) {
py::array_t<double> masses(shape);
auto retAccessor = masses.mutable_unchecked<1>();
for (decltype(nat) i=0; i < nat; ++i) {
retAccessor(i)=self->getMass(i);
retAccessor(i)
=self->getMass(i);
}
return masses;
},
Expand All @@ -142,7 +144,8 @@ PYBIND11_EMBEDDED_MODULE(plumedCommunications, m) {
py::array_t<double> charges(shape);
auto retAccessor = charges.mutable_unchecked<1>();
for (decltype(nat) i=0; i < nat; ++i) {
retAccessor(i)=self->getCharge(i);
retAccessor(i)
=self->getCharge(i);
}
return charges;
},
Expand Down Expand Up @@ -196,7 +199,8 @@ return toRet;
py::array_t<unsigned long> couples(shape);
auto retAccessor = couples.mutable_unchecked<2>();
for(size_t c=0; c< ncouples; ++c) {
retAccessor(c,0) = self->getClosePair(c).first;
retAccessor(c,0)
= self->getClosePair(c).first;
retAccessor(c,1) = self->getClosePair(c).second;
}
return couples;
Expand Down
51 changes: 34 additions & 17 deletions plugins/pycv/PythonCVInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,21 @@ PythonCVInterface::PythonCVInterface(const ActionOptions&ao) ://the catch only a
std::vector<AtomNumber> groupB;
pyParseAtomList("GROUPB",initDict,groupB);

if(atoms.size() !=0 && groupA.size()!=0)
if(atoms.size() !=0 && groupA.size()!=0) {
error("you can choose only between using the neigbourlist OR the atoms");
}

if(atoms.size()==0&& groupA.size()==0 && groupB.size()==0)
if(atoms.size()==0&& groupA.size()==0 && groupB.size()==0) {
error("At least one atom is required");
}

if (atoms.size() != 0 && groupA.size() != 0)
if (atoms.size() != 0 && groupA.size() != 0) {
error("you can choose only between using the neigbourlist OR the atoms");
}

if (atoms.size() == 0 && groupA.size() == 0 && groupB.size() == 0)
if (atoms.size() == 0 && groupA.size() == 0 && groupB.size() == 0) {
error("At least one atom is required");
}

bool nopbc;
pyParseFlag("NOPBC",initDict, nopbc);
Expand All @@ -551,11 +555,13 @@ PythonCVInterface::PythonCVInterface(const ActionOptions&ao) ://the catch only a
int nl_st = 0;
if (doneigh) {
pyParse("NL_CUTOFF", initDict, nl_cut);
if (nl_cut <= 0.0)
if (nl_cut <= 0.0) {
error("NL_CUTOFF should be explicitly specified and positive");
}
pyParse("NL_STRIDE",initDict, nl_st);
if (nl_st <= 0)
if (nl_st <= 0) {
error("NL_STRIDE should be explicitly specified and positive");
}
}
// endof WIP
if (groupB.size() > 0) {
Expand Down Expand Up @@ -607,8 +613,9 @@ void PythonCVInterface::prepare() {
error("Neighbor lists should be updated on exchange steps - choose a "
"NL_STRIDE which divides the exchange stride!");
}
if (getExchangeStep())
if (getExchangeStep()) {
firsttime = true;
}
}
}
if (hasPrepare) {
Expand Down Expand Up @@ -680,8 +687,9 @@ void PythonCVInterface::readReturn(const py::object &r, Value* valPtr) {
//shape returns long int
auto natoms = static_cast<long int > (getPositions().size());
if (rl.size() > 1) {
if(!valPtr->hasDerivatives())
if(!valPtr->hasDerivatives()) {
error(valPtr->getName()+" was declared without derivatives, but python returned with derivatives");
}
// 2nd return value: gradient: numpy array of (natoms, 3)
py::array_t<pycvComm_t> grad(rl[1]);
// Assert correct gradient shape
Expand All @@ -697,12 +705,14 @@ void PythonCVInterface::readReturn(const py::object &r, Value* valPtr) {
Vector3d gi(grad.at(i, 0), grad.at(i, 1), grad.at(i, 2));
setAtomsDerivatives(valPtr, i, gi);
}
} else if (valPtr->hasDerivatives())
} else if (valPtr->hasDerivatives()) {
error(valPtr->getName()+" was declared with derivatives, but python returned none");
}

if (rl.size() > 2) {
if(!valPtr->hasDerivatives())
if(!valPtr->hasDerivatives()) {
plumed_merror(valPtr->getName()+" was declared without derivatives, but python returned with box derivatives");
}
py::array_t<pycvComm_t> pyBoxDev(rl[2]);
// expecting the box derivatives
Tensor boxDev;
Expand All @@ -724,18 +734,21 @@ void PythonCVInterface::readReturn(const py::object &r, Value* valPtr) {
error("Python CV returned wrong box derivatives shape error");
}
setBoxDerivatives(valPtr, boxDev);
} else if (valPtr->hasDerivatives())
} else if (valPtr->hasDerivatives()) {
warning(valPtr->getName()+" was declared with derivatives, but python returned no box derivatives");
}
} else {
// Only value returned. Might be an error as well.
if (valPtr->hasDerivatives())
if (valPtr->hasDerivatives()) {
warning(BIASING_DISABLED);
}
pycvComm_t value = r.cast<pycvComm_t>();
valPtr->set(value);
}
//TODO: is this ok?
if (!pbc)
if (!pbc) {
setBoxDerivativesNoPbc(valPtr);
}
}


Expand All @@ -750,10 +763,11 @@ void PythonCVInterface::calculateMultiComponent(py::object &r) {
std::string key=component->getName().substr(
2 + getLabel().size()
+PYCV_COMPONENTPREFIX.size());
if (dataDict.contains(key.c_str()))
if (dataDict.contains(key.c_str())) {
readReturn(dataDict[key.c_str()], component);
else
} else {
error( "python did not returned " + key );
}
}
} else {
// In principle one could handle a "list" return case.
Expand All @@ -765,15 +779,18 @@ void PythonCVInterface::pyParseAtomList(const char* key, const ::pybind11::dict
parseAtomList(key,myatoms);

if(initDict.contains(key)) {
if (myatoms.size()>0)
if (myatoms.size()>0) {
error(std::string("you specified the same keyword ").append(key)+ " both in python and in the settings file");
}
auto atomlist=PLMD::Tools::getWords(
py::str(initDict[key]).cast<std::string>(),
"\t\n ,");
interpretAtomList( atomlist, myatoms );
}
}

NeighborList &PythonCVInterface::getNL() { return *nl; }
NeighborList &PythonCVInterface::getNL() {
return *nl;
}
} // namespace pycvs
} // namespace PLMD
11 changes: 7 additions & 4 deletions plugins/pycv/PythonFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ void PythonFunction::readReturn(const py::object &r, Value* valPtr) {
valPtr->set(value);
if (rl.size() > 1) {
auto nargs = getNumberOfArguments();
if(!valPtr->hasDerivatives())
if(!valPtr->hasDerivatives()) {
error(valPtr->getName()+" was declared without derivatives, but python returned with derivatives");
}
// 2nd return value: gradient: numpy array
py::array_t<pycvComm_t> grad(rl[1]);
if(grad.ndim() != 1 || grad.shape(0) != nargs) {
Expand All @@ -241,8 +242,9 @@ void PythonFunction::readReturn(const py::object &r, Value* valPtr) {
for(size_t i=0; i<nargs; i++) {
valPtr->setDerivative(i,grad.at(i));
}
} else if (valPtr->hasDerivatives())
} else if (valPtr->hasDerivatives()) {
plumed_merror(valPtr->getName()+" was declared with derivatives, but python returned none");
}

} else {
// Only value returned. Might be an error as well.
Expand All @@ -263,10 +265,11 @@ void PythonFunction::calculateMultiComponent(py::object &r) {
std::string key=component->getName().substr(
2 + getLabel().size()
+PYCV_COMPONENTPREFIX.size());
if (dataDict.contains(key.c_str()))
if (dataDict.contains(key.c_str())) {
readReturn(dataDict[key.c_str()], component);
else
} else {
error( "python did not returned " + key );
}
}
} else {
// In principle one could handle a "list" return case.
Expand Down
Loading
Loading