Skip to content
Open
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
10 changes: 5 additions & 5 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
graphviz \
python3-numpy \
python3-vtk7
- uses: actions/checkout@v2
- uses: actions/checkout@v4.1.7
with:
lfs: true
- name: Build project
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
libtbb-dev \
python3-numpy \
python3-vtk7
- uses: actions/checkout@v2
- uses: actions/checkout@v4.1.7
with:
lfs: true
- name: Build project
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
libtbb-dev \
python3-numpy \
python3-vtk7
- uses: actions/checkout@v2
- uses: actions/checkout@v4.1.7
with:
lfs: true
- name: Build project
Expand All @@ -127,8 +127,8 @@ jobs:
format_check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.12
- uses: actions/checkout@v4.1.7
- uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: 'src tests'
# exclude: 'none'
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
#at least 3.14 for FetchContent_MakeAvailable
#at least 3.19 for a correctly working FindHDF5 cmake module
#at least 3.5 because CMake drops compatibility at some point
project(LADDS)

set(EXECUTABLE_NAME ladds)
Expand Down
14 changes: 9 additions & 5 deletions cmake/modules/autopas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ if (GIT_SUBMODULES_SSH)
set(autopasRepoPath git@github.com:AutoPas/AutoPas.git)
endif ()

# TODO: fix this as soon as that branch is merged
set(AUTOPAS_TAG AoSRemainderTraversal CACHE STRING "AutoPas Git tag or commit id to use.")

# Download and install autopas
FetchContent_Declare(
autopasfetch
GIT_REPOSITORY ${autopasRepoPath}
# merge of md-flex/diffuse-loadbalancing 12.07.22
GIT_TAG 71fa505172bce4ee422556018f2dc444e04fca12
autopasfetch
GIT_REPOSITORY ${autopasRepoPath}
GIT_TAG ${AUTOPAS_TAG}
)

# Populate dependency
FetchContent_MakeAvailable(autopasfetch)

# Disable warnings from the library target
target_compile_options(autopas PRIVATE -w)
# Disable warnings from included headers
get_target_property(propval autopas INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(autopas SYSTEM PUBLIC "${propval}")
target_include_directories(autopas SYSTEM PUBLIC "${propval}")
5 changes: 4 additions & 1 deletion notebooks/getTimers.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# This script parses an arbitrary number of files each containing the CLI output of LADDS,
# extracts the timer information and merges it into one CSV for further processing.

Expand Down Expand Up @@ -57,7 +58,9 @@ paste -d ',' \
<(get MPI Ranks) \
<(get OpenMP Threads per Rank) \
<(get Container) \
<(get Traversal) \
<(get desiredCellsPerDimension) \
<(get timestepsPerCollisionDetection) \
<(get 'Total (ranks accumulated)') \
<(get Initialization) \
<(get Simulation) \
Expand All @@ -67,7 +70,7 @@ paste -d ',' \
<(get Communication) \
<(get Collision detection) \
<(get Collision detection immigrants) \
<(get Collision detection emmigrants) \
<(get Collision detection emigrants) \
<(get Collision writer) \
<(get Evasion writer) \
<(get Container update) \
Expand Down
8 changes: 4 additions & 4 deletions src/ladds/CollisionFunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CollisionFunctor::CollisionFunctor(double cutoff,
double collisionDistanceFactor,
double minDetectionRadius,
double evasionTrackingCutoffInKM)
: Functor(cutoff),
: PairwiseFunctor(cutoff),
_cutoffSquare(cutoff * cutoff),
_dt(dt),
_collisionDistanceFactor(collisionDistanceFactor / 1000.), // also imply conversion from m to km
Expand Down Expand Up @@ -137,13 +137,13 @@ void CollisionFunctor::SoAFunctorSingle(autopas::SoAView<SoAArraysType> soa, boo
void CollisionFunctor::SoAFunctorPair(autopas::SoAView<SoAArraysType> soa1,
autopas::SoAView<SoAArraysType> soa2,
bool newton3) {
if (soa1.getNumberOfParticles() == 0 or soa2.getNumberOfParticles() == 0) return;
if (soa1.size() == 0 or soa2.size() == 0) return;

// get pointers to the SoA
const auto *const __restrict ownedStatePtr1 = soa1.template begin<Particle::AttributeNames::ownershipState>();

// outer loop over SoA1
for (size_t i = 0; i < soa1.getNumberOfParticles(); ++i) {
for (size_t i = 0; i < soa1.size(); ++i) {
if (ownedStatePtr1[i] == autopas::OwnershipState::dummy) {
// If the i-th particle is a dummy, skip this loop iteration.
continue;
Expand All @@ -157,7 +157,7 @@ void CollisionFunctor::SoAFunctorPair(autopas::SoAView<SoAArraysType> soa1,
// TODO add evadedCollisions when refactoring this
auto &thisCollisions = _threadData[autopas::autopas_get_thread_num()].collisions;
#pragma omp simd reduction(vecMerge : thisCollisions)
for (size_t j = 0; j < soa2.getNumberOfParticles(); ++j) {
for (size_t j = 0; j < soa2.size(); ++j) {
SoAKernel(i, j, soa1, soa2, newton3);
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/ladds/CollisionFunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include <autopas/pairwiseFunctors/Functor.h>
#include <autopas/baseFunctors/PairwiseFunctor.h>
#include <autopas/utils/SoA.h>
#include <autopas/utils/SoAView.h>

Expand All @@ -19,7 +19,7 @@ namespace LADDS {
* Class describing the pairwise particle computation for determining whether a collision occured.
* This functor is passed to autopas::AutoPas::iteratePairwise() as the primary pairwise interaction.
*/
class CollisionFunctor final : public autopas::Functor<Particle, CollisionFunctor> {
class CollisionFunctor final : public autopas::PairwiseFunctor<Particle, CollisionFunctor> {
public:
/**
* Constructor
Expand Down Expand Up @@ -88,6 +88,10 @@ class CollisionFunctor final : public autopas::Functor<Particle, CollisionFuncto
const std::vector<size_t, autopas::AlignedAllocator<size_t>> &neighborList,
bool newton3) final;

std::string getName() final {
return "CollisionFunctor";
}

private:
void SoAKernel(
size_t i, size_t j, autopas::SoAView<SoAArraysType> &soa1, autopas::SoAView<SoAArraysType> &soa2, bool newton3);
Expand Down
31 changes: 17 additions & 14 deletions src/ladds/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Declare the main AutoPas class as extern template instantiation. It is instantiated in AutoPasClass.cpp.
extern template class autopas::AutoPas<LADDS::Particle>;
extern template bool autopas::AutoPas<LADDS::Particle>::iteratePairwise(LADDS::CollisionFunctor *);
extern template bool autopas::AutoPas<LADDS::Particle>::computeInteractions(LADDS::CollisionFunctor *);

namespace LADDS {

Expand Down Expand Up @@ -77,7 +77,7 @@ std::unique_ptr<AutoPas_t> Simulation::initAutoPas(ConfigReader &config, DomainD
autopas->setBoxMin(domainDecomp.getLocalBoxMin());
autopas->setBoxMax(domainDecomp.getLocalBoxMax());
autopas->setCutoff(cutoff);
autopas->setVerletSkin(verletSkin);
autopas->setVerletSkinPerTimestep(verletSkin / verletRebuildFrequency);
autopas->setVerletRebuildFrequency(verletRebuildFrequency);
// Scale Cell size so that we get the desired number of cells
// -2 because internally there will be two halo cells added on top of maxAltitude
Expand Down Expand Up @@ -109,7 +109,8 @@ std::unique_ptr<AutoPas_t> Simulation::initAutoPas(ConfigReader &config, DomainD
// arbitrary number. Can be changed to whatever makes sense.
autopas->setTuningInterval(std::numeric_limits<unsigned int>::max());
autopas->setSelectorStrategy(autopas::SelectorStrategyOption::fastestMean);
autopas->setNumSamples(verletRebuildFrequency);
const auto tuningSamples = config.get<unsigned int>("autopas/tuningSamples", 3);
autopas->setNumSamples(tuningSamples);
autopas::Logger::get()->set_level(spdlog::level::from_str(config.get<std::string>("autopas/logLevel", "error")));
int rank{};
autopas::AutoPas_MPI_Comm_rank(AUTOPAS_MPI_COMM_WORLD, &rank);
Expand Down Expand Up @@ -217,7 +218,7 @@ Simulation::collisionDetection(AutoPas_t &autopas,
// pairwise interaction
CollisionFunctor collisionFunctor(
autopas.getCutoff(), deltaT, collisionDistanceFactor, minDetectionRadius, evasionTrackingCutoffInKM);
bool stillTuning = autopas.iteratePairwise(&collisionFunctor);
bool stillTuning = autopas.computeInteractions(&collisionFunctor);
return {collisionFunctor.getCollisions(), collisionFunctor.getEvadedCollisions(), stillTuning};
}

Expand Down Expand Up @@ -455,7 +456,8 @@ size_t Simulation::simulationLoop(AutoPas_t &autopas,
}

vtuWriter.writeVTU(autopas);
decompositionLogger->writePayload(iteration, autopas.getCurrentConfig());
decompositionLogger->writePayload(iteration,
autopas.getCurrentConfigs().at(autopas::InteractionTypeOption::pairwise).get());
}
if (hdf5WriteFrequency and (iteration % hdf5WriteFrequency == 0 or iteration == lastIteration)) {
hdf5Writer->writeParticles(iteration, autopas);
Expand Down Expand Up @@ -549,7 +551,7 @@ void Simulation::run(ConfigReader &config) {
}

void Simulation::dumpCalibratedConfig(ConfigReader &config, const AutoPas_t &autopas) const {
auto autopasConfig = autopas.getCurrentConfig();
const auto autopasConfig = autopas.getCurrentConfigs().at(autopas::InteractionTypeOption::pairwise).get();
config.setValue("autopas/Newton3", autopasConfig.newton3.to_string());
config.setValue("autopas/DataLayout", autopasConfig.dataLayout.to_string());
config.setValue("autopas/Container", autopasConfig.container.to_string());
Expand Down Expand Up @@ -612,13 +614,14 @@ void Simulation::processCollisions(size_t iteration,
ConjuctionWriterInterface &conjunctionWriter,
BreakupWrapper *breakupWrapper) {
if (not collisions.empty()) {
SPDLOG_LOGGER_DEBUG(logger.get(), "The following particles collided between ranks:");
for (const auto &[p1, p2, _, __] : collisions) {
SPDLOG_LOGGER_DEBUG(logger.get(),
"({}, {})",
autopas::utils::ArrayUtils::to_string(p1->getPosition()),
autopas::utils::ArrayUtils::to_string(p2->getPosition()));
}
SPDLOG_LOGGER_DEBUG(logger.get(), "The following particles collided between ranks:{}", [&]() {
std::stringstream ss;
for (const auto &[p1, p2, _, __] : collisions) {
ss << "\n (" << autopas::utils::ArrayUtils::to_string(p1->getPosition()) << ", "
<< autopas::utils::ArrayUtils::to_string(p2->getPosition()) << ")";
}
return ss.str();
}());
iterationsSinceLastCollision = 0;
}
timers.collisionWriting.start();
Expand Down Expand Up @@ -695,4 +698,4 @@ void Simulation::printProgressOutput(size_t iteration,
totalEvasionsGlobal);
}

} // namespace LADDS
} // namespace LADDS
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ LADDS::RegularGridDecomposition::RegularGridDecomposition(LADDS::ConfigReader &c
using autopas::utils::ArrayMath::div;
using autopas::utils::ArrayMath::mul;
using autopas::utils::ArrayMath::sub;
using autopas::utils::ArrayUtils::static_cast_array;
using autopas::utils::ArrayUtils::static_cast_copy_array;
// calculate local box extent
const auto globalBoxLength = sub(globalBoxMax, globalBoxMin);
const auto localBoxLength = div(globalBoxLength, static_cast_array<double>(dims));
localBoxMin = add(globalBoxMin, mul(localBoxLength, static_cast_array<double>(coords)));
const auto localBoxLength = div(globalBoxLength, static_cast_copy_array<double>(dims));
localBoxMin = add(globalBoxMin, mul(localBoxLength, static_cast_copy_array<double>(coords)));
localBoxMax = add(localBoxMin, localBoxLength);

// print parallelization info
Expand All @@ -52,12 +52,12 @@ int LADDS::RegularGridDecomposition::getRank(const std::array<double, 3> &coordi
using autopas::utils::ArrayMath::abs;
using autopas::utils::ArrayMath::div;
using autopas::utils::ArrayMath::sub;
using autopas::utils::ArrayUtils::static_cast_array;
using autopas::utils::ArrayUtils::static_cast_copy_array;

// we need to translate to 0 avoid problems with negative coordinates
const auto translatedCoords = sub(coordinates, globalBoxMin);
const auto localBoxLength = abs(sub(localBoxMax, localBoxMin));
const auto rankGridCoords = static_cast_array<int>(div(translatedCoords, localBoxLength));
const auto rankGridCoords = static_cast_copy_array<int>(div(translatedCoords, localBoxLength));
int targetRank{};
autopas::AutoPas_MPI_Cart_rank(communicator, rankGridCoords.data(), &targetRank);
return targetRank;
Expand Down
4 changes: 2 additions & 2 deletions src/ladds/io/Timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Timers::printTimers(ConfigReader &config, const DomainDecomposition &decomp
printLB(collisionDetection) +
timerToString(" Collision detection immigrants ", accMPITimers(collisionDetectionImmigrants), maxNumberOfDigits, timeSimAcc) +
printLB(collisionDetectionImmigrants) +
timerToString(" Collision detection emigrants ", accMPITimers(collisionDetectionEmigrants), maxNumberOfDigits, timeSimAcc) +
timerToString(" Collision detection emigrants ", accMPITimers(collisionDetectionEmigrants), maxNumberOfDigits, timeSimAcc) +
printLB(collisionDetectionEmigrants) +
timerToString(" Collision writer ", accMPITimers(collisionWriting), maxNumberOfDigits, timeSimAcc) +
printLB(collisionWriting) +
Expand Down Expand Up @@ -135,4 +135,4 @@ std::tuple<double, double> Timers::calcImbalances(const autopas::utils::Timer &t
return std::make_tuple(avgImbalance, maxImbalance);
}

} // namespace LADDS
} // namespace LADDS
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
#include "ladds/particle/Particle.h"

//! @cond Doxygen_Suppress
template bool autopas::AutoPas<LADDS::Particle>::iteratePairwise(LADDS::CollisionFunctor *);
template bool autopas::AutoPas<LADDS::Particle>::computeInteractions(LADDS::CollisionFunctor *);
//! @endcond
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST_F(RegularGridDecompositionTests, testParticleMigrationHandler) {
using autopas::utils::ArrayMath::mul;
using autopas::utils::ArrayMath::mulScalar;
using autopas::utils::ArrayMath::sub;
using autopas::utils::ArrayUtils::static_cast_array;
using autopas::utils::ArrayUtils::static_cast_copy_array;

int numRanks{};
autopas::AutoPas_MPI_Comm_size(decomposition->getCommunicator(), &numRanks);
Expand Down Expand Up @@ -97,8 +97,8 @@ TEST_F(RegularGridDecompositionTests, testParticleMigrationHandler) {
for (int z = 0; z < 2; ++z) {
const std::array<int, 3> rankGridIndex{x, y, z};
// newPos = globalBoxMin + (localBoxLength / 2) + (localBoxLength * index)
const auto newPosition =
add(globalBoxMin, add(localBoxLengthHalf, mul(localBoxLength, static_cast_array<double>(rankGridIndex))));
const auto newPosition = add(
globalBoxMin, add(localBoxLengthHalf, mul(localBoxLength, static_cast_copy_array<double>(rankGridIndex))));
// make sure all except one particle is moved away
ASSERT_TRUE(
(x == rankGridIndex[0] and y == rankGridIndex[1] and z == rankGridIndex[2]) or
Expand Down
11 changes: 5 additions & 6 deletions tests/testladds/CollisionFunctorIntegrationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
#include "CollisionFunctorIntegrationTest.h"

#include <autopas/AutoPasDecl.h>
#include <autopasTools/generators/RandomGenerator.h>
#include <autopasTools/generators/UniformGenerator.h>
#include <gmock/gmock-matchers.h>
#include <gmock/gmock-more-matchers.h>
#include <ladds/CollisionFunctor.h>

extern template class autopas::AutoPas<LADDS::Particle>;
extern template bool autopas::AutoPas<LADDS::Particle>::iteratePairwise(LADDS::CollisionFunctor *);
extern template bool autopas::AutoPas<LADDS::Particle>::computeInteractions(LADDS::CollisionFunctor *);

void CollisionFunctorIntegrationTest::SetUpTestSuite() {
using autopasTools::generators::RandomGenerator;
constexpr size_t numDebris = 15;
LADDS::Particle defaultParticle{{
0.,
Expand All @@ -38,10 +37,10 @@ void CollisionFunctorIntegrationTest::SetUpTestSuite() {
_debris.reserve(numDebris);

// fix seed for randomPosition()
srand(42);
std::mt19937 generator(42);

for (int i = 0; i < numDebris; ++i) {
defaultParticle.setR(autopasTools::generators::RandomGenerator::randomPosition(_boxMin, _boxMax));
defaultParticle.setR(autopasTools::generators::UniformGenerator::randomPosition(generator, _boxMin, _boxMax));
defaultParticle.setID(i);
defaultParticle.setParentIdentifier(i);
_debris.push_back(defaultParticle);
Expand Down Expand Up @@ -108,7 +107,7 @@ TEST_P(CollisionFunctorIntegrationTest, testAutoPasAlgorithm) {
}

try {
autopas.iteratePairwise(&functor);
autopas.computeInteractions(&functor);
} catch (const autopas::utils::ExceptionHandler::AutoPasException &e) {
// There will be some tests generated that are invalid configurations but that is ok.
GTEST_SKIP_(e.what());
Expand Down
Loading