diff --git a/.github/workflows/ls1_test.yml b/.github/workflows/ls1_test.yml index 9086f5a367..4d4475c18e 100644 --- a/.github/workflows/ls1_test.yml +++ b/.github/workflows/ls1_test.yml @@ -91,7 +91,7 @@ jobs: -DENABLE_UNIT_TESTS=ON \ .. - cmake --build . --parallel 2 + cmake --build . --parallel 1 cd .. @@ -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 diff --git a/cmake/modules/autopas.cmake b/cmake/modules/autopas.cmake index 07c71e194b..99a02230fc 100644 --- a/cmake/modules/autopas.cmake +++ b/cmake/modules/autopas.cmake @@ -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 @@ -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 "") diff --git a/examples/Adsorption/Generator/adsorption_autopas_tuning.xml b/examples/Adsorption/Generator/adsorption_autopas_tuning.xml index 27a09db982..db11eef8b4 100644 --- a/examples/Adsorption/Generator/adsorption_autopas_tuning.xml +++ b/examples/Adsorption/Generator/adsorption_autopas_tuning.xml @@ -87,7 +87,6 @@ c01, c04, c08, c18, sli linkedCells fastestMedian - FullSearch SoA enabled 1000 diff --git a/examples/Argon/200K_18mol_l/config_autopas_allOptions.xml b/examples/Argon/200K_18mol_l/config_autopas_allOptions.xml index 5e29ce127b..3ce57eac7e 100644 --- a/examples/Argon/200K_18mol_l/config_autopas_allOptions.xml +++ b/examples/Argon/200K_18mol_l/config_autopas_allOptions.xml @@ -44,16 +44,18 @@ --> + off 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 DirectSum,LinkedCells, VerletLists, VerletListsCells, VerletClusterLists,VarVerletListsAsBuild,VerletClusterCells fastestMean - FullSearch + predictive,rulebased AoS, SoA enabled, disabled lower-confidence-bound 20 1000 10 + AutoPas/examples/md-flexible/input/tuningRules.rule 10 0.5 diff --git a/examples/Argon/200K_18mol_l/config_autopas_aos.xml b/examples/Argon/200K_18mol_l/config_autopas_aos.xml index 2542cc05d4..cbd7ff39a0 100644 --- a/examples/Argon/200K_18mol_l/config_autopas_aos.xml +++ b/examples/Argon/200K_18mol_l/config_autopas_aos.xml @@ -35,6 +35,7 @@ lc_c01, lc_c08, lc_c18, lc_sli, ds_sequential linkedCells, verletLists, directsum fastestMedian + energy AoS enabled, disabled 1000 diff --git a/examples/Argon/200K_18mol_l/config_autopas_lc_ALL.xml b/examples/Argon/200K_18mol_l/config_autopas_lc_ALL.xml index 0314d8902d..41a774c00f 100644 --- a/examples/Argon/200K_18mol_l/config_autopas_lc_ALL.xml +++ b/examples/Argon/200K_18mol_l/config_autopas_lc_ALL.xml @@ -38,7 +38,9 @@ + linkedCells + predictive,ruleBased 10000 10 10 diff --git a/examples/all-options.xml b/examples/all-options.xml index 50e46eb6c8..432a50647f 100644 --- a/examples/all-options.xml +++ b/examples/all-options.xml @@ -242,8 +242,11 @@ fastestAbsolute - - fullSearch + + + ruleBasedTuning, predictiveTuning + + energy SoA diff --git a/src/Domain.cpp b/src/Domain.cpp index b64528cdf9..879a2d5f71 100644 --- a/src/Domain.cpp +++ b/src/Domain.cpp @@ -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); diff --git a/src/molecules/AutoPasSimpleMolecule.h b/src/molecules/AutoPasSimpleMolecule.h index ab4cb31415..20a97ff3b3 100644 --- a/src/molecules/AutoPasSimpleMolecule.h +++ b/src/molecules/AutoPasSimpleMolecule.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -336,4 +336,4 @@ class AutoPasSimpleMolecule final : public MoleculeInterface, public autopas::Pa static Quaternion _quaternion; }; -std::ostream& operator<<( std::ostream& os, const AutoPasSimpleMolecule& m ); \ No newline at end of file +std::ostream& operator<<( std::ostream& os, const AutoPasSimpleMolecule& m ); diff --git a/src/parallel/CommunicationPartner.cpp b/src/parallel/CommunicationPartner.cpp index de7141bf55..c43812d911 100644 --- a/src/parallel/CommunicationPartner.cpp +++ b/src/parallel/CommunicationPartner.cpp @@ -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 diff --git a/src/parallel/DomainDecompBase.cpp b/src/parallel/DomainDecompBase.cpp index da4e876af4..3478ae79d6 100644 --- a/src/parallel/DomainDecompBase.cpp +++ b/src/parallel/DomainDecompBase.cpp @@ -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); diff --git a/src/parallel/DomainDecompMPIBase.cpp b/src/parallel/DomainDecompMPIBase.cpp index 173856045d..be61e34858 100644 --- a/src/parallel/DomainDecompMPIBase.cpp +++ b/src/parallel/DomainDecompMPIBase.cpp @@ -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); } diff --git a/src/parallel/NeighbourCommunicationScheme.cpp b/src/parallel/NeighbourCommunicationScheme.cpp index c138410d59..750d24e427 100644 --- a/src/parallel/NeighbourCommunicationScheme.cpp +++ b/src/parallel/NeighbourCommunicationScheme.cpp @@ -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()) { diff --git a/src/particleContainer/AutoPasContainer.cpp b/src/particleContainer/AutoPasContainer.cpp index 6baec85f95..014c5faf9d 100644 --- a/src/particleContainer/AutoPasContainer.cpp +++ b/src/particleContainer/AutoPasContainer.cpp @@ -18,7 +18,7 @@ //! @cond Doxygen_Suppress extern template class autopas::AutoPas; extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ true, /*mixing*/ true, @@ -26,7 +26,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ true, /*mixing*/ false, @@ -34,7 +34,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ false, /*mixing*/ true, @@ -42,7 +42,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ false, /*mixing*/ false, @@ -51,7 +51,7 @@ extern template bool autopas::AutoPas::iteratePairwise( > *); #ifdef __AVX__ extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ true, /*mixing*/ true, @@ -59,7 +59,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ true, /*mixing*/ false, @@ -67,7 +67,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ false, /*mixing*/ true, @@ -75,7 +75,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ false, /*mixing*/ false, @@ -85,7 +85,7 @@ extern template bool autopas::AutoPas::iteratePairwise( #endif #ifdef __ARM_FEATURE_SVE extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ true, /*mixing*/ true, @@ -93,7 +93,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ true, /*mixing*/ false, @@ -101,7 +101,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ false, /*mixing*/ true, @@ -109,7 +109,7 @@ extern template bool autopas::AutoPas::iteratePairwise( /*calculateGlobals*/ true > *); extern template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ false, /*mixing*/ false, @@ -129,7 +129,8 @@ AutoPasContainer::AutoPasContainer(double cutoff) : _cutoff(cutoff), _particlePr _traversalChoices = _autopasContainer.getAllowedTraversals(); _containerChoices = _autopasContainer.getAllowedContainers(); _selectorStrategy = _autopasContainer.getSelectorStrategy(); - _tuningStrategyOption = _autopasContainer.getTuningStrategyOption(); + _tuningStrategyOptions = _autopasContainer.getTuningStrategyOptions(); + _tuningMetricOption = _autopasContainer.getTuningMetricOption(); _tuningAcquisitionFunction = _autopasContainer.getAcquisitionFunction(); _dataLayoutChoices = _autopasContainer.getAllowedDataLayouts(); _newton3Choices = _autopasContainer.getAllowedNewton3Options(); @@ -171,15 +172,15 @@ AutoPasContainer::AutoPasContainer(double cutoff) : _cutoff(cutoff), _particlePr * @param defaultValue Set of options that is returned if nothing was found in the xml * @return */ -template +template > auto parseAutoPasOption(XMLfileUnits &xmlconfig, const std::string &xmlString, - const std::set &defaultValue) { + const OutputContainer &defaultValue) { auto stringInXml = string_utils::toLowercase(xmlconfig.getNodeValue_string(xmlString)); if (stringInXml.empty()) { return defaultValue; } try { - return OptionType::parseOptions(stringInXml); + return OptionType::template parseOptions(stringInXml); } catch (const std::exception &e) { Log::global_log->error() << "AutoPasContainer: error when parsing " << xmlString << ":" << std::endl; Log::global_log->error() << e.what() << std::endl; @@ -187,7 +188,7 @@ auto parseAutoPasOption(XMLfileUnits &xmlconfig, const std::string &xmlString, << autopas::utils::ArrayUtils::to_string(OptionType::getAllOptions()) << std::endl; Simulation::exit(4432); // dummy return - return decltype(OptionType::parseOptions(""))(); + return decltype(OptionType::template parseOptions(""))(); } } @@ -201,9 +202,9 @@ void AutoPasContainer::readXML(XMLfileUnits &xmlconfig) { _selectorStrategy = *parseAutoPasOption(xmlconfig, "selectorStrategy", {_selectorStrategy}) .begin(); - _tuningStrategyOption = - *parseAutoPasOption(xmlconfig, "tuningStrategy", {_tuningStrategyOption}) - .begin(); + _tuningStrategyOptions = + parseAutoPasOption>(xmlconfig, "tuningStrategies", {_tuningStrategyOptions}); + _tuningMetricOption = *parseAutoPasOption(xmlconfig, "tuningMetric", {_tuningMetricOption}).begin(); _extrapolationMethod = *parseAutoPasOption(xmlconfig, "extrapolationMethod", {_extrapolationMethod}) .begin(); @@ -243,15 +244,17 @@ void AutoPasContainer::readXML(XMLfileUnits &xmlconfig) { _relativeOptimumRange = xmlconfig.getNodeValue_double("optimumRange", _relativeOptimumRange); _relativeBlacklistRange = xmlconfig.getNodeValue_double("blacklistRange", _relativeBlacklistRange); + // string + xmlconfig.getNodeValue("ruleFile", _ruleFileName); std::string functorChoiceStr{}; xmlconfig.getNodeValue("functor", functorChoiceStr); - if (functorChoiceStr.empty()) { + if (functorChoiceStr.empty()) { #ifdef __ARM_FEATURE_SVE - functorChoiceStr = "sve"; + functorChoiceStr = "sve"; #elif defined(__AVX__) - functorChoiceStr = "avx"; + functorChoiceStr = "avx"; #endif - } + } if (functorChoiceStr.find("avx") != std::string::npos) { functorOption = FunctorOption::AVX; Log::global_log->info() << "Selected AVX Functor." << std::endl; @@ -318,7 +321,9 @@ bool AutoPasContainer::rebuild(double *bBoxMin, double *bBoxMax) { _autopasContainer.setAllowedTraversals(_traversalChoices); _autopasContainer.setAllowedDataLayouts(_dataLayoutChoices); _autopasContainer.setAllowedNewton3Options(_newton3Choices); - _autopasContainer.setTuningStrategyOption(_tuningStrategyOption); + _autopasContainer.setTuningStrategyOption(_tuningStrategyOptions); + _autopasContainer.setTuningMetricOption(_tuningMetricOption); + _autopasContainer.setRuleFileName(_ruleFileName); _autopasContainer.setAcquisitionFunction(_tuningAcquisitionFunction); _autopasContainer.setMaxEvidence(_maxEvidence); _autopasContainer.setRelativeOptimumRange(_relativeOptimumRange); @@ -331,50 +336,55 @@ bool AutoPasContainer::rebuild(double *bBoxMin, double *bBoxMax) { _autopasContainerIsInitialized = true; // print full configuration to the command line - int valueOffset = 28; - Log::global_log->info() << "AutoPas configuration:" << std::endl + constexpr int valueOffset = 28; + Log::global_log->info() << "AutoPas configuration:\n" << std::setw(valueOffset) << std::left << "Data Layout " << ": " << autopas::utils::ArrayUtils::to_string(_autopasContainer.getAllowedDataLayouts()) - << std::endl + << "\n" << std::setw(valueOffset) << std::left << "Container " << ": " << autopas::utils::ArrayUtils::to_string(_autopasContainer.getAllowedContainers()) - << std::endl + << "\n" << std::setw(valueOffset) << std::left << "Cell size Factor " - << ": " << _autopasContainer.getAllowedCellSizeFactors() << std::endl + << ": " << _autopasContainer.getAllowedCellSizeFactors() << "\n" << std::setw(valueOffset) << std::left << "Traversals " << ": " << autopas::utils::ArrayUtils::to_string(_autopasContainer.getAllowedTraversals()) - << std::endl + << "\n" << std::setw(valueOffset) << std::left << "Newton3" << ": " << autopas::utils::ArrayUtils::to_string(_autopasContainer.getAllowedNewton3Options()) - << std::endl - << std::setw(valueOffset) << std::left << "Tuning strategy " - << ": " << _autopasContainer.getTuningStrategyOption() << std::endl + << "\n" + << std::setw(valueOffset) << std::left << "Tuning Metric" + << ": " << _autopasContainer.getTuningMetricOption() << "\n" + << std::setw(valueOffset) << std::left << "Tuning strategies " + << ": " << autopas::utils::ArrayUtils::to_string(_autopasContainer.getTuningStrategyOptions()) + << "\n" << std::setw(valueOffset) << std::left << "Selector strategy " - << ": " << _autopasContainer.getSelectorStrategy() << std::endl + << ": " << _autopasContainer.getSelectorStrategy() << "\n" << std::setw(valueOffset) << std::left << "Tuning frequency" - << ": " << _autopasContainer.getTuningInterval() << std::endl + << ": " << _autopasContainer.getTuningInterval() << "\n" << std::setw(valueOffset) << std::left << "Number of samples " - << ": " << _autopasContainer.getNumSamples() << std::endl + << ": " << _autopasContainer.getNumSamples() << "\n" << std::setw(valueOffset) << std::left << "Tuning Acquisition Function" - << ": " << _autopasContainer.getAcquisitionFunction() << std::endl + << ": " << _autopasContainer.getAcquisitionFunction() << "\n" << std::setw(valueOffset) << std::left << "Number of evidence " - << ": " << _autopasContainer.getMaxEvidence() << std::endl + << ": " << _autopasContainer.getMaxEvidence() << "\n" << std::setw(valueOffset) << std::left << "Verlet Cluster size " - << ": " << _autopasContainer.getVerletClusterSize() << std::endl + << ": " << _autopasContainer.getVerletClusterSize() << "\n" << std::setw(valueOffset) << std::left << "Rebuild frequency " - << ": " << _autopasContainer.getVerletRebuildFrequency() << std::endl + << ": " << _autopasContainer.getVerletRebuildFrequency() << "\n" << std::setw(valueOffset) << std::left << "Verlet Skin " - << ": " << _autopasContainer.getVerletSkin() << std::endl + << ": " << _autopasContainer.getVerletSkin() << "\n" << std::setw(valueOffset) << std::left << "Optimum Range " - << ": " << _autopasContainer.getRelativeOptimumRange() << std::endl + << ": " << _autopasContainer.getRelativeOptimumRange() << "\n" << std::setw(valueOffset) << std::left << "Tuning Phases without test " - << ": " << _autopasContainer.getMaxTuningPhasesWithoutTest() << std::endl + << ": " << _autopasContainer.getMaxTuningPhasesWithoutTest() << "\n" << std::setw(valueOffset) << std::left << "Blacklist Range " - << ": " << _autopasContainer.getRelativeBlacklistRange() << std::endl + << ": " << _autopasContainer.getRelativeBlacklistRange() << "\n" << std::setw(valueOffset) << std::left << "Evidence for prediction " - << ": " << _autopasContainer.getEvidenceFirstPrediction() << std::endl + << ": " << _autopasContainer.getEvidenceFirstPrediction() << "\n" << std::setw(valueOffset) << std::left << "Extrapolation method " - << ": " << _autopasContainer.getExtrapolationMethodOption() << std::endl; + << ": " << _autopasContainer.getExtrapolationMethodOption() << "\n" + << std::setw(valueOffset) << std::left << "Rule File " + << ": " << _autopasContainer.getRuleFileName() << std::endl; /// @todo return sendHaloAndLeavingTogether, (always false) for simplicity. return false; @@ -420,8 +430,8 @@ template std::pair AutoPasContainer::iterateWithFunctor(F &&functor) { // here we call the actual autopas' iteratePairwise method to compute the forces. _autopasContainer.iteratePairwise(&functor); - double upot = functor.getUpot(); - double virial = functor.getVirial(); + const double upot = functor.getPotentialEnergy(); + const double virial = functor.getVirial(); return std::make_pair(upot, virial); } @@ -438,23 +448,22 @@ void AutoPasContainer::traverseTemplateHelper() { // Check if all components have the same eps24 and sigma. If that is the case, we can skip the mixing rules, which // is faster! - auto numComponents = _particlePropertiesLibrary.getTypes().size(); - double epsilon24FirstComponent = _particlePropertiesLibrary.get24Epsilon(0); - double sigmasqFirstComponent = _particlePropertiesLibrary.getSigmaSquare(0); + const auto numComponents = _particlePropertiesLibrary.getNumberRegisteredSiteTypes(); + const double epsilonFirstComponent = _particlePropertiesLibrary.getEpsilon(0); + const double sigmaFirstComponent = _particlePropertiesLibrary.getSigma(0); bool allSame = true; for (auto i = 1ul; i < numComponents; ++i) { - allSame &= _particlePropertiesLibrary.get24Epsilon(i) == epsilon24FirstComponent; - allSame &= _particlePropertiesLibrary.getSigmaSquare(i) == sigmasqFirstComponent; + allSame &= _particlePropertiesLibrary.getEpsilon(i) == epsilonFirstComponent; + allSame &= _particlePropertiesLibrary.getSigma(i) == sigmaFirstComponent; } - bool useMixing = not allSame; - if (useMixing) { + if (not allSame) { Log::global_log->debug() << "AutoPasContainer: Using mixing." << std::endl; switch (functorOption) { case FunctorOption::SVE: { #ifdef __ARM_FEATURE_SVE // Generate the functor. Should be regenerated every iteration to wipe internally saved globals. - autopas::LJFunctorSVE functor(_cutoff, _particlePropertiesLibrary); @@ -467,7 +476,7 @@ void AutoPasContainer::traverseTemplateHelper() { case FunctorOption::AVX: { #ifdef __AVX__ // Generate the functor. Should be regenerated every iteration to wipe internally saved globals. - autopas::LJFunctorAVX functor(_cutoff, _particlePropertiesLibrary); @@ -479,7 +488,7 @@ void AutoPasContainer::traverseTemplateHelper() { } case FunctorOption::autoVec: { // Generate the functor. Should be regenerated every iteration to wipe internally saved globals. - autopas::LJFunctor functor(_cutoff, _particlePropertiesLibrary); @@ -496,10 +505,10 @@ void AutoPasContainer::traverseTemplateHelper() { case FunctorOption::SVE: { #ifdef __ARM_FEATURE_SVE // Generate the functor. Should be regenerated every iteration to wipe internally saved globals. - autopas::LJFunctorSVE functor(_cutoff); - functor.setParticleProperties(epsilon24FirstComponent, sigmasqFirstComponent); + functor.setParticleProperties(epsilonFirstComponent * 24, sigmaFirstComponent * sigmaFirstComponent); std::tie(upot, virial) = iterateWithFunctor(functor); #else throw std::runtime_error("SVE Functor not compiled due to lack of compiler support!"); @@ -509,10 +518,10 @@ void AutoPasContainer::traverseTemplateHelper() { case FunctorOption::AVX: { #ifdef __AVX__ // Generate the functor. Should be regenerated every iteration to wipe internally saved globals. - autopas::LJFunctorAVX functor(_cutoff); - functor.setParticleProperties(epsilon24FirstComponent, sigmasqFirstComponent); + functor.setParticleProperties(epsilonFirstComponent * 24, sigmaFirstComponent * sigmaFirstComponent); std::tie(upot, virial) = iterateWithFunctor(functor); #else throw std::runtime_error("AVX Functor not compiled due to lack of compiler support!"); @@ -521,10 +530,10 @@ void AutoPasContainer::traverseTemplateHelper() { } case FunctorOption::autoVec: { // Generate the functor. Should be regenerated every iteration to wipe internally saved globals. - autopas::LJFunctor functor(_cutoff); - functor.setParticleProperties(epsilon24FirstComponent, sigmasqFirstComponent); + functor.setParticleProperties(epsilonFirstComponent * 24, sigmaFirstComponent * sigmaFirstComponent); std::tie(upot, virial) = iterateWithFunctor(functor); break; } @@ -547,20 +556,20 @@ void AutoPasContainer::traverseCells(CellProcessor &cellProcessor) { bool hasShift = false; bool hasNoShift = false; - if (_particlePropertiesLibrary.getTypes().empty()) { - auto components = global_simulation->getEnsemble()->getComponents(); - for (auto &c : *components) { - _particlePropertiesLibrary.addType(c.getLookUpId(), c.ljcenter(0).eps(), c.ljcenter(0).sigma(), + if (_particlePropertiesLibrary.getNumberRegisteredSiteTypes() == 0) { + const auto components = global_simulation->getEnsemble()->getComponents(); + for (const auto &c : *components) { + _particlePropertiesLibrary.addSiteType(c.getLookUpId(), c.ljcenter(0).eps(), c.ljcenter(0).sigma(), c.ljcenter(0).m()); } _particlePropertiesLibrary.calculateMixingCoefficients(); size_t numComponentsAdded = 0; - for (auto &c : *components) { + for (const auto &c : *components) { if (c.ljcenter(0).shift6() != 0.) { hasShift = true; - double autoPasShift6 = - _particlePropertiesLibrary.mixingShift6(numComponentsAdded, numComponentsAdded); - double ls1Shift6 = c.ljcenter(0).shift6(); + const double autoPasShift6 = + _particlePropertiesLibrary.getMixingShift6(numComponentsAdded, numComponentsAdded); + const double ls1Shift6 = c.ljcenter(0).shift6(); if (std::fabs((autoPasShift6 - ls1Shift6) / ls1Shift6) > 1.e-10) { // warn if shift differs relatively by more than 1.e-10 Log::global_log->warning() << "Dangerous shift6 detected: AutoPas will use: " << autoPasShift6 @@ -624,6 +633,8 @@ double AutoPasContainer::getCutoff() const { return _cutoff; } double AutoPasContainer::getSkin() const { return _verletSkin; } +size_t AutoPasContainer::getRebuildFrequency() const {return _verletRebuildFrequency;}; + void AutoPasContainer::deleteMolecule(ParticleIterator &moleculeIter, const bool & /*rebuildCaches*/) { _autopasContainer.deleteParticle(moleculeIter); } @@ -686,7 +697,7 @@ unsigned long AutoPasContainer::initCubicGrid(std::array numMo vcp_real_calc T = global_simulation->getEnsemble()->T(); const std::array spacing = autopas::utils::ArrayMath::div(simBoxLength, - autopas::utils::ArrayUtils::static_cast_array( + autopas::utils::ArrayUtils::static_cast_copy_array( numMoleculesPerDimension)); size_t numMolecules = 0; for (int grid = 0; grid < 2; ++grid) { @@ -715,7 +726,7 @@ double *AutoPasContainer::getCellLength() { } double *AutoPasContainer::getHaloSize() { - static std::array haloLength{_verletSkin + _cutoff}; + static std::array haloLength{_verletSkin + _cutoff, _verletSkin + _cutoff, _verletSkin + _cutoff}; return haloLength.data(); } diff --git a/src/particleContainer/AutoPasContainer.h b/src/particleContainer/AutoPasContainer.h index f5b9bbe363..5167ba5818 100644 --- a/src/particleContainer/AutoPasContainer.h +++ b/src/particleContainer/AutoPasContainer.h @@ -9,7 +9,7 @@ #include "ParticleContainer.h" #include -#include +#include /** * A wrapper for the AutoPas library. @@ -32,7 +32,8 @@ class AutoPasContainer : public ParticleContainer { STRINGLIST STRINGLIST STRING - STRING + STRING + STRING STRING STRINGLIST STRINGLIST @@ -47,8 +48,8 @@ class AutoPasContainer : public ParticleContainer { DOUBLE DOUBLE STRING - INTEGER - + INTEGER + \endcode * If you are using MPI-parallel simulations, tuningSamples should be a multiple of rebuildFrequency! * A list of the different Options can be found here: @@ -94,6 +95,8 @@ class AutoPasContainer : public ParticleContainer { double getSkin() const override; + size_t getRebuildFrequency() const override; + void deleteMolecule(ParticleIterator &moleculeIter, const bool &rebuildCaches) override; double getEnergy(ParticlePairsHandler *particlePairsHandler, Molecule *m1, CellProcessor &cellProcessor) override; @@ -157,11 +160,13 @@ class AutoPasContainer : public ParticleContainer { unsigned int _evidenceForPrediction; autopas::AutoPas _autopasContainer; bool _autopasContainerIsInitialized{false}; + std::string _ruleFileName{}; std::set _traversalChoices; std::set _containerChoices; autopas::SelectorStrategyOption _selectorStrategy; - autopas::TuningStrategyOption _tuningStrategyOption; + std::vector _tuningStrategyOptions; + autopas::TuningMetricOption _tuningMetricOption; autopas::ExtrapolationMethodOption _extrapolationMethod; autopas::AcquisitionFunctionOption _tuningAcquisitionFunction; std::set _dataLayoutChoices; diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftMix.cpp index be339b752a..49d12aab2f 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftMix.cpp @@ -7,11 +7,11 @@ #ifdef __AVX__ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorAVX.h" +#include "molecularDynamicsLibrary/LJFunctorAVX.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ false, /*mixing*/ true, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftNoMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftNoMix.cpp index ee7dff515e..43a097ca23 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftNoMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXNoShiftNoMix.cpp @@ -7,11 +7,11 @@ #ifdef __AVX__ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorAVX.h" +#include "molecularDynamicsLibrary/LJFunctorAVX.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ false, /*mixing*/ false, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftMix.cpp index c57f21b34c..6a3305b67e 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftMix.cpp @@ -7,11 +7,11 @@ #ifdef __AVX__ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorAVX.h" +#include "molecularDynamicsLibrary/LJFunctorAVX.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ true, /*mixing*/ true, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftNoMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftNoMix.cpp index c609423d27..aa7e92ee7e 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftNoMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorAVXShiftNoMix.cpp @@ -7,11 +7,11 @@ #ifdef __AVX__ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorAVX.h" +#include "molecularDynamicsLibrary/LJFunctorAVX.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorAVX< + mdLib::LJFunctorAVX< Molecule, /*applyShift*/ true, /*mixing*/ false, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftMix.cpp index f318c218d4..589d9fbff4 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftMix.cpp @@ -6,11 +6,11 @@ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctor.h" +#include "molecularDynamicsLibrary/LJFunctor.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ false, /*mixing*/ true, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftNoMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftNoMix.cpp index c5351de5b5..5a83c13811 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftNoMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorNoShiftNoMix.cpp @@ -6,11 +6,11 @@ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctor.h" +#include "molecularDynamicsLibrary/LJFunctor.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ false, /*mixing*/ false, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftMix.cpp index 653dd31436..977689dbcc 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftMix.cpp @@ -7,11 +7,11 @@ #ifdef __ARM_FEATURE_SVE #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorSVE.h" +#include "molecularDynamicsLibrary/LJFunctorSVE.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ false, /*mixing*/ true, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftNoMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftNoMix.cpp index b06ee386ea..e3b83168b0 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftNoMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVENoShiftNoMix.cpp @@ -7,11 +7,11 @@ #ifdef __ARM_FEATURE_SVE #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorSVE.h" +#include "molecularDynamicsLibrary/LJFunctorSVE.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ false, /*mixing*/ false, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftMix.cpp index dbed925f86..f34f6dfba5 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftMix.cpp @@ -7,11 +7,11 @@ #ifdef __ARM_FEATURE_SVE #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorSVE.h" +#include "molecularDynamicsLibrary/LJFunctorSVE.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ true, /*mixing*/ true, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftNoMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftNoMix.cpp index f50315a46b..73a9736cf6 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftNoMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorSVEShiftNoMix.cpp @@ -7,11 +7,11 @@ #ifdef __ARM_FEATURE_SVE #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctorSVE.h" +#include "molecularDynamicsLibrary/LJFunctorSVE.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctorSVE< + mdLib::LJFunctorSVE< Molecule, /*applyShift*/ true, /*mixing*/ false, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftMix.cpp index 0d77c0e027..3ee2788ada 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftMix.cpp @@ -6,11 +6,11 @@ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctor.h" +#include "molecularDynamicsLibrary/LJFunctor.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ true, /*mixing*/ true, diff --git a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftNoMix.cpp b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftNoMix.cpp index 7d12eb6b81..f43afce07a 100644 --- a/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftNoMix.cpp +++ b/src/particleContainer/AutoPasTemplateInstantiations/iteratePairwiseLJFunctorShiftNoMix.cpp @@ -6,11 +6,11 @@ #include "autopas/AutoPasImpl.h" #include "molecules/Molecule.h" -#include "autopas/molecularDynamics/LJFunctor.h" +#include "molecularDynamicsLibrary/LJFunctor.h" //! @cond Doxygen_Suppress template bool autopas::AutoPas::iteratePairwise( - autopas::LJFunctor< + mdLib::LJFunctor< Molecule, /*applyShift*/ true, /*mixing*/ false, diff --git a/src/particleContainer/ParticleContainer.h b/src/particleContainer/ParticleContainer.h index 447bb9b709..eea8af21cc 100644 --- a/src/particleContainer/ParticleContainer.h +++ b/src/particleContainer/ParticleContainer.h @@ -199,6 +199,8 @@ class ParticleContainer: public MemoryProfilable { virtual double getSkin() const {return 0.;} + virtual size_t getRebuildFrequency() const {return 1;}; + /* TODO: Have a look on this */ virtual void deleteMolecule(ParticleIterator& moleculeIter, const bool& rebuildCaches) = 0; @@ -271,20 +273,25 @@ class ParticleContainer: public MemoryProfilable { * Only used for logging / output. * @note: Formatting rules: * - The whole configuration should be enclosed in curly brackets. - * - Different elements should be separated by a comma sourrounded by spaces: " , ". + * - Different elements should be separated by a comma surrounded by spaces: " , ". * - Every element should be in the form "key: value" * @return */ virtual std::string getConfigurationAsString() = 0; protected: - - //! coordinates of the left, lower, front corner of the bounding box + /** + * Coordinates of the left, lower, front corner of the local bounding box. + */ double _boundingBoxMin[3]; - //! coordinates of the right, upper, back corner of the bounding box + /** + * Coordinates of the right, upper, back corner of the local bounding box. + */ double _boundingBoxMax[3]; - //! Vector of particles that are about to be removed from the container. - //! Currently only used by AutoPasContainer but here for interface reasons. + /** + * Vector of particles that are about to be removed from the container. + * Currently only used by AutoPasContainer but here for interface reasons. + */ std::vector _invalidParticles{}; }; diff --git a/tools/decomp2vtkConverter.py b/tools/decomp2vtkConverter.py index deabe43b57..612ba63a14 100755 --- a/tools/decomp2vtkConverter.py +++ b/tools/decomp2vtkConverter.py @@ -88,7 +88,8 @@ def getCellPointIndices(self): line = f_in.readline() celllist = [] while line != "": - match = re.search(r'([0-9]+) ([0-9. ]+)(.*)', line) + # Matches "[int] [float] [whatever]" + match = re.search(r'([-0-9]+) ([-0-9. ]+)(.*)', line) rank = int(match.group(1).rstrip()) minMaxString = match.group(2).rstrip() configString = match.group(3)