Skip to content

Commit

Permalink
Merge pull request #270 from ls1mardyn/updateAutoPasCombinedTuning
Browse files Browse the repository at this point in the history
Update AutoPas to Combined Tuning
  • Loading branch information
SamNewcome authored Apr 16, 2024
2 parents 5f507e4 + 7c7d7b4 commit 64002ac
Show file tree
Hide file tree
Showing 29 changed files with 164 additions and 134 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ls1_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
-DENABLE_UNIT_TESTS=ON \
..
cmake --build . --parallel 2
cmake --build . --parallel 1
cd ..
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
-DENABLE_MPI=$mpi_enabled \
..
cmake --build . --parallel 2
cmake --build . --parallel 1
#as example list of new version is used, also the example files of new version should be used
#therefore, go back to new version
Expand Down
7 changes: 4 additions & 3 deletions cmake/modules/autopas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ if (ENABLE_AUTOPAS)
set(AUTOPAS_USE_VECTORIZATION ${USE_VECTORIZATION} CACHE BOOL "Set via USE_VECTORIZATION" FORCE)
set(AUTOPAS_VECTOR_INSTRUCTIONS ${VECTOR_INSTRUCTIONS} CACHE STRING "Set via VECTOR_INSTRUCTIONS_OPTIONS" FORCE)

# Merge of fixSpacialLocksResize 2023-05-08; This includes the rewrites of remainder traversal and iterators.
set(AUTOPAS_TAG e47c9257bb8d0c6ab680d02823b1e8749b25369a CACHE STRING "AutoPas Git tag or commit id to use")
# Merge of #830 (fixRegionIterators); includes #787 (combined tuning)
set(AUTOPAS_TAG faef573 CACHE STRING "AutoPas Git tag or commit id to use")

FetchContent_Declare(
autopasfetch
Expand All @@ -41,7 +41,8 @@ if (ENABLE_AUTOPAS)
add_subdirectory(${autopasfetch_SOURCE_DIR} ${autopasfetch_BINARY_DIR} EXCLUDE_FROM_ALL)
endif ()

set(AUTOPAS_LIB "autopas")
# Linking the md lib also links AutoPas
set(AUTOPAS_LIB "molecularDynamicsLibrary")
else ()
message(STATUS "Not using AutoPas.")
set(AUTOPAS_LIB "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
<allowedTraversals>c01, c04, c08, c18, sli</allowedTraversals>
<allowedContainers>linkedCells</allowedContainers>
<selectorStrategy>fastestMedian</selectorStrategy>
<tuningStrategy>FullSearch</tuningStrategy><!--FullSearch, BayesianSearch, ...-->
<dataLayouts>SoA</dataLayouts>
<newton3>enabled</newton3>
<tuningInterval>1000</tuningInterval>
Expand Down
4 changes: 3 additions & 1 deletion examples/Argon/200K_18mol_l/config_autopas_allOptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@
</parallelisation>
-->
<datastructure type="AutoPas">
<loglevel>off</loglevel><!--Level for the AutoPas logger-->
<allowedTraversals>ds_sequential, lc_sliced, lc_sliced_balanced, lc_sliced_c02, lc_c01, lc_c01_combined_SoA, lc_c01_cuda, lc_c04, lc_c04_HCP, lc_c04_combined_SoA, lc_c08, lc_c18, vcc_cluster_iteration_cuda, vcl_cluster_iteration, vcl_c06, vcl_c01_balanced, vl_list_iteration, vlc_c01, vlc_c18, vlc_sliced, vlc_sliced_balanced, vlc_sliced_c02, vvl_as_built</allowedTraversals>
<allowedContainers>DirectSum,LinkedCells, VerletLists, VerletListsCells, VerletClusterLists,VarVerletListsAsBuild,VerletClusterCells</allowedContainers>
<selectorStrategy>fastestMean</selectorStrategy><!--fastestMedian,fastestAbs-->
<tuningStrategy>FullSearch</tuningStrategy><!--FullSearch, BayesianSearch, ...-->
<tuningStrategies>predictive,rulebased</tuningStrategies><!--Predictive, RuleBased, BayesianSearch, ...; Leave empty for full search-->
<dataLayouts>AoS, SoA</dataLayouts>
<newton3>enabled, disabled</newton3>
<tuningAcquisitionFunction>lower-confidence-bound</tuningAcquisitionFunction> <!--only relevant for BayesianSearch-->
<maxEvidence>20</maxEvidence>
<tuningInterval>1000</tuningInterval>
<tuningSamples>10</tuningSamples>
<ruleFile>AutoPas/examples/md-flexible/input/tuningRules.rule</ruleFile><!--check the AutoPas repo for examples-->
<rebuildFrequency>10</rebuildFrequency>
<skin>0.5</skin>
</datastructure>
Expand Down
1 change: 1 addition & 0 deletions examples/Argon/200K_18mol_l/config_autopas_aos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<allowedTraversals>lc_c01, lc_c08, lc_c18, lc_sli, ds_sequential</allowedTraversals>
<allowedContainers>linkedCells, verletLists, directsum</allowedContainers>
<selectorStrategy>fastestMedian</selectorStrategy>
<tuningMetric>energy</tuningMetric>
<dataLayouts>AoS</dataLayouts>
<newton3>enabled, disabled</newton3>
<tuningInterval>1000</tuningInterval>
Expand Down
2 changes: 2 additions & 0 deletions examples/Argon/200K_18mol_l/config_autopas_lc_ALL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
</loadBalancer>
</parallelisation>
<datastructure type="AutoPas">
<!-- <logLevel>info</logLevel> -->
<allowedContainers>linkedCells</allowedContainers>
<tuningStrategies>predictive,ruleBased</tuningStrategies>
<tuningInterval>10000</tuningInterval>
<tuningSamples>10</tuningSamples>
<rebuildFrequency>10</rebuildFrequency>
Expand Down
7 changes: 5 additions & 2 deletions examples/all-options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,11 @@
<!-- specify what metric the selector should use to determine the optimal traversal -->
<!-- possible values: fastetAbsolute, fastestMean, fastestMedian -->
<selectorStrategy>fastestAbsolute</selectorStrategy>
<!-- set the auto tuning algorithm -->
<tuningStrategy>fullSearch</tuningStrategy>
<!-- set the tuning auto tuning pipeline -->
<!-- Leave this empty for an exhaustive full search or add any number of strategies that are applied in the stated order -->
<tuningStrategies>ruleBasedTuning, predictiveTuning</tuningStrategies>
<!-- autopas optimizes the simulation based on tuning metric: time, energy, default option is time -->
<tuningMetric>energy</tuningMetric>
<!-- Data layouts to be used: AoS, SoA -->
<dataLayouts>SoA</dataLayouts>
<!-- Allowed choices for newton 3 optimization: enabled, disabled -->
Expand Down
15 changes: 6 additions & 9 deletions src/Domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,30 +261,27 @@ void Domain::calculateGlobalValues(
Log::global_log->debug() << "Selective thermostat will be applied to set " << thermit->first
<< " (beta_trans = " << this->_universalBTrans[thermit->first]
<< ", beta_rot = " << this->_universalBRot[thermit->first] << "!)" << std::endl;
int rot_dof;
const double limit_energy = KINLIMIT_PER_T * Ti;

#if defined(_OPENMP)
#pragma omp parallel
#endif
{

double Utrans, Urot, limit_rot_energy, vcorr, Dcorr;
for (auto tM = particleContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); tM.isValid(); ++tM) {
Utrans = tM->U_trans();
const auto Utrans = tM->U_trans();
if (Utrans > limit_energy) {
vcorr = sqrt(limit_energy / Utrans);
const auto vcorr = sqrt(limit_energy / Utrans);
Log::global_log->debug() << ": v(m" << tM->getID() << ") *= " << vcorr << std::endl;
tM->scale_v(vcorr);
tM->scale_F(vcorr);
}

rot_dof = tM->component()->getRotationalDegreesOfFreedom();
const auto rot_dof = tM->component()->getRotationalDegreesOfFreedom();
if (rot_dof > 0) {
limit_rot_energy = 3.0 * rot_dof * Ti;
Urot = tM->U_rot();
const auto limit_rot_energy = 3.0 * rot_dof * Ti;
const auto Urot = tM->U_rot();
if (Urot > limit_rot_energy) {
Dcorr = sqrt(limit_rot_energy / Urot);
const auto Dcorr = sqrt(limit_rot_energy / Urot);
Log::global_log->debug() << "D(m" << tM->getID() << ") *= " << Dcorr << std::endl;
tM->scale_D(Dcorr);
tM->scale_M(Dcorr);
Expand Down
4 changes: 2 additions & 2 deletions src/molecules/AutoPasSimpleMolecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include <autopas/molecularDynamics/MoleculeLJ.h>
#include <molecularDynamicsLibrary/MoleculeLJ.h>
#include <autopas/utils/SoAType.h>
#include <autopas/utils/inBox.h>

Expand Down Expand Up @@ -334,4 +334,4 @@ class AutoPasSimpleMolecule final : public MoleculeInterface, public autopas::Pa
static Quaternion _quaternion;
};

std::ostream& operator<<( std::ostream& os, const AutoPasSimpleMolecule& m );
std::ostream& operator<<( std::ostream& os, const AutoPasSimpleMolecule& m );
2 changes: 1 addition & 1 deletion src/parallel/CommunicationPartner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool CommunicationPartner::iprobeCount(const MPI_Comm& comm, const MPI_Datatype&
return _countReceived;
}
bool CommunicationPartner::testRecv(ParticleContainer* moleculeContainer, bool removeRecvDuplicates, bool force) {
if (_countReceived and not _msgReceived) {
if (_countReceived and not _msgReceived) {
int flag = 1;
if (_countTested > 10) {
// some MPI (Intel, IBM) implementations can produce deadlocks using MPI_Test without any MPI_Wait
Expand Down
2 changes: 1 addition & 1 deletion src/parallel/DomainDecompBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void DomainDecompBase::handleDomainLeavingParticlesDirect(const HaloRegion& halo
};

if (moleculeContainer->isInvalidParticleReturner()) {
// move all particles that will be inserted now to the end of the container
// Shift and add all invalid particles that do belong in this halo region
auto removeBegin = std::partition(invalidParticles.begin(), invalidParticles.end(), [=](const Molecule& m) {
// if this is true, it will be put in the first part of the partition, if it is false, in the second.
return not m.inBox(haloRegion.rmin, haloRegion.rmax);
Expand Down
2 changes: 1 addition & 1 deletion src/parallel/DomainDecompMPIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void DomainDecompMPIBase::assertDisjunctivity(ParticleContainer* moleculeContain
}
}
if (not isOk) {
Log::global_log->error() << "Aborting because of duplicated partices." << std::endl;
Log::global_log->error() << "Aborting because of duplicated particles." << std::endl;
MPI_Abort(_comm, 1);
}

Expand Down
1 change: 1 addition & 0 deletions src/parallel/NeighbourCommunicationScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ void DirectNeighbourCommunicationScheme::finalizeExchangeMoleculesMPI(ParticleCo
removeRecvDuplicates |= (domainDecomp->getRank() == (*_neighbours)[0][i].getRank());
}

// local helper function to apply f to all real neighbours
auto forAllRealNeighbors = [&](auto&& f) {
for (auto& neighbor : (*_neighbours)[0]) {
if (not _useSequentialFallback or domainDecomp->getRank() != neighbor.getRank()) {
Expand Down
Loading

0 comments on commit 64002ac

Please sign in to comment.