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

Integrate the Cabana load balancer #29

Draft
wants to merge 68 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f3f1997
add vim temp files to gitignore
aetx Jul 20, 2021
7a5cc30
add initial rough integration of all lb
aetx Jul 20, 2021
cf45af4
Create proper domain output using all lb
aetx Jul 20, 2021
fb54b27
retrieve local grid dimensions and location and output via liball vtk…
aetx Jul 21, 2021
aeace1e
very dirty incorporation of lb
aetx Jul 21, 2021
09df0c9
make sure the created arrays are also updated
aetx Jul 22, 2021
09f3704
add primitive VTK writer for domains
aetx Jul 22, 2021
fad1d73
use the mutable version of global grid and some debug output
aetx Jul 22, 2021
408bab2
reenable silo particle output
aetx Jul 23, 2021
a7f86d5
remove debug output
aetx Jul 23, 2021
2befc54
update VTKDomainWriter to allow for arbitrary basename
aetx Jul 23, 2021
dba154b
output actual and load balancing domain structure
aetx Jul 23, 2021
d4877b8
VTKDomainWriter fix parallel file piece filename composition
aetx Jul 23, 2021
f014469
to not miss cells, first convert lb vertices to cells, then apply to …
aetx Jul 23, 2021
cb15e1f
ci: include ALL checkout and build
aetx Jul 23, 2021
5a9bf54
disable ALL internal VTK output for now
aetx Jul 23, 2021
9d0a2aa
move load balancing interface into LoadBalancer
aetx Jul 23, 2021
e83988b
remove spurious debug output
aetx Jul 23, 2021
897ff8a
fix errors and re-enable vtk output
aetx Jul 26, 2021
41fe692
change decomposition to y direction
aetx Jul 26, 2021
9ab5cf1
also enable ALL vertex output
aetx Jul 26, 2021
25e21aa
Revert "also enable ALL vertex output"
aetx Jul 26, 2021
64b55bf
try new CI workflow to update apt-get
aetx Jul 26, 2021
b27821a
Merge branch 'master' into all_lb
junghans Jul 26, 2021
9a7bda1
CI: install ALL in home
junghans Jul 26, 2021
5c11bf1
use more recent ALL version
aetx Jul 26, 2021
d53e661
remove unneeded methods
aetx Jul 26, 2021
662eae5
remove trailing whitespace
aetx Jul 26, 2021
c1e53cc
run clang-format
aetx Jul 26, 2021
ee32eeb
CI: use modified cabana for now.
junghans Jul 26, 2021
82801b0
Merge branch 'all_lb' of github.com:aetx/ExaMPM into all_lb
aetx Jul 26, 2021
d03eb08
disable ALL VTK output
aetx Jul 26, 2021
697ff10
fix warning in printf
aetx Jul 26, 2021
490b3df
fix documentation in VTKDomainWriter
aetx Jul 27, 2021
47213d7
update constness
aetx Jul 28, 2021
00c9239
update for cabana refactoring
aetx Jul 29, 2021
6e1389b
update format
aetx Jul 29, 2021
f1c50b9
update to new cabana api
aetx Jul 29, 2021
f0b9ca1
Merge branch 'master' into all_lb
aetx Aug 2, 2021
57a5242
Update CI.yml
junghans Aug 5, 2021
078227b
make ALL optional
aetx Aug 13, 2021
0880566
Merge branch 'all_lb' of github.com:aetx/ExaMPM into all_lb
aetx Aug 13, 2021
3486851
get loadbalancer to compile
aetx Aug 23, 2021
ff993d4
build ALL before cabana and require ALL in cabana
aetx Aug 23, 2021
75726d4
make format
aetx Aug 23, 2021
61bee26
make sure cabana finds all
aetx Aug 23, 2021
8f549db
cmake syntax mistake
aetx Aug 23, 2021
901be36
yaml syntax mistake
aetx Aug 23, 2021
ebdd9d6
make sure new mesh is actually used
aetx Aug 26, 2021
d415dcb
add debug output
aetx Aug 26, 2021
3181c0f
update to new Cabana lb interface
aetx Aug 26, 2021
3292ef7
Revert "add debug output"
aetx Aug 26, 2021
aca7063
format
aetx Aug 26, 2021
979a39e
fix output time step for domain output
aetx Aug 26, 2021
c2e7061
add todo regarding Silo writer and empty domains
aetx Aug 26, 2021
b91bfb6
use Cabana_ENABLE_ALL and clean up
aetx Aug 29, 2021
dcc9337
explicitly setting Cabana_ENABLE_ALL no longer required
aetx Aug 30, 2021
0981e1f
fix warning
aetx Sep 1, 2021
17d3ebc
fix warnings
aetx Sep 1, 2021
6014371
make format
aetx Sep 1, 2021
bb6526e
Use ExaMPM_ENABLE_LB to force lb on or off
aetx Sep 2, 2021
034e5f5
only balance every 10 steps
aetx Sep 8, 2021
fd35d8e
add basic timing info
aetx Sep 15, 2021
9babd7c
allow run time selection of lb frequency
aetx Sep 21, 2021
75bc0bf
add continuous perf output
aetx Sep 22, 2021
a9d9433
update for Quality->Imbalance rename
aetx Oct 7, 2021
69bebc6
move LoadBalancer into Experimental namespace
aetx Oct 21, 2021
f380494
remove some redundancy
aetx Nov 18, 2021
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
17 changes: 13 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,32 @@ jobs:
cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/kokkos -DKokkos_CXX_STANDARD=14 -DKokkos_ENABLE_${{ matrix.backend }}=ON
cmake --build build --parallel 2
cmake --install build
- name: Checkout ALL
run: |
git clone --depth 1 --branch master https://gitlab.jsc.fz-juelich.de/SLMS/loadbalancing ALL
- name: Build ALL
working-directory: ALL
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/ALL
cmake --build build --parallel 2
cmake --install build
- name: Checkout Cabana
uses: actions/[email protected]
with:
repository: ECP-copa/Cabana
ref: master
repository: aetx/Cabana
ref: cajita_loadbalancer
path: Cabana
- name: Build Cabana
working-directory: Cabana
run: |
cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/Cabana -DCMAKE_PREFIX_PATH="$HOME/kokkos" -DCabana_REQUIRE_${{ matrix.backend }}=ON
cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/Cabana -DCMAKE_PREFIX_PATH="$HOME/kokkos" -DCabana_REQUIRE_${{ matrix.backend }}=ON -DCabana_REQUIRE_ALL=ON
streeve marked this conversation as resolved.
Show resolved Hide resolved
cmake --build build --parallel 2
cmake --install build
- name: Checkout code
uses: actions/[email protected]
- name: Build
run: |
cmake -B build -DCMAKE_PREFIX_PATH="$HOME/kokkos;$HOME/Cabana"
cmake -B build -DCMAKE_PREFIX_PATH="$HOME/kokkos;$HOME/Cabana;$HOME/ALL"
cmake --build build --parallel 2
cd build && ctest --output-on-failure
- name: Format
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.mp4
*.mp4
*.swp
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ if( NOT Cabana_ENABLE_CAJITA )
endif()
find_package(Silo REQUIRED)

# optional dependencies (taken from Cabana)
macro(ExaMPM_add_dependency)
cmake_parse_arguments(EXAMPM_DEPENDENCY "" "PACKAGE;VERSION" "" ${ARGN})
find_package( ${EXAMPM_DEPENDENCY_PACKAGE} ${EXAMPM_DEPENDENCY_VERSION} QUIET )
string(TOUPPER "${EXAMPM_DEPENDENCY_PACKAGE}" EXAMPM_DEPENDENCY_OPTION )
option(
ExaMPM_REQUIRE_${EXAMPM_DEPENDENCY_OPTION}
"Require ExaMPM to build with ${EXAMPM_DEPENDENCY_PACKAGE} support" ${EXAMPM_DEPENDENCY_PACKAGE}_FOUND)
if(ExaMPM_REQUIRE_${EXAMPM_DEPENDENCY_OPTION})
find_package( ${EXAMPM_DEPENDENCY_PACKAGE} ${EXAMPM_DEPENDENCY_VERSION} REQUIRED )
endif()
set(ExaMPM_ENABLE_${EXAMPM_DEPENDENCY_OPTION} ${${EXAMPM_DEPENDENCY_PACKAGE}_FOUND})
endmacro()

ExaMPM_add_dependency( PACKAGE "ALL" VERSION 0.9.2 )

# find Clang Format
find_package( CLANG_FORMAT 10 )

Expand Down
3 changes: 2 additions & 1 deletion examples/dam_break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ void damBreak( const double cell_size, const int ppc, const int halo_size,
int comm_size;
MPI_Comm_size( MPI_COMM_WORLD, &comm_size );
std::array<int, 3> ranks_per_dim = { 1, comm_size, 1 };
Cajita::ManualPartitioner partitioner( ranks_per_dim );
std::shared_ptr<Cajita::ManualPartitioner> partitioner =
std::make_shared<Cajita::ManualPartitioner>( ranks_per_dim );

// Material properties.
double bulk_modulus = 1.0e5;
Expand Down
3 changes: 2 additions & 1 deletion examples/free_fall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ void freeFall( const double cell_size, const int ppc, const int halo_size,
int comm_size;
MPI_Comm_size( MPI_COMM_WORLD, &comm_size );
std::array<int, 3> ranks_per_dim = { 1, comm_size, 1 };
Cajita::ManualPartitioner partitioner( ranks_per_dim );
std::shared_ptr<Cajita::ManualPartitioner> partitioner =
std::make_shared<Cajita::ManualPartitioner>( ranks_per_dim );

// Material properties.
double bulk_modulus = 5.0e5;
Expand Down
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ set(HEADERS
ExaMPM_Solver.hpp
ExaMPM_TimeIntegrator.hpp
ExaMPM_Types.hpp
ExaMPM_VTKDomainWriter.hpp
ExaMPM_VelocityInterpolation.hpp
)

if(ExaMPM_ENABLE_ALL)
list(APPEND HEADERS
ExaMPM_LoadBalancer.hpp
)
endif()

set(SOURCES
ExaMPM_Mesh.cpp
)
Expand All @@ -22,6 +29,10 @@ target_link_libraries(exampm
Cabana::Cajita
Silo::silo )

if(ExaMPM_ENABLE_ALL)
target_link_libraries(exampm ALL::ALL)
endif()

target_include_directories(exampm
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
73 changes: 73 additions & 0 deletions src/ExaMPM_LoadBalancer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/****************************************************************************
* Copyright (c) 2018-2020 by the ExaMPM authors *
* All rights reserved. *
* *
* This file is part of the ExaMPM library. ExaMPM is distributed under a *
* BSD 3-clause license. For the licensing terms see the LICENSE file in *
* the top-level directory. *
* *
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/

#ifndef EXAMPM_LOADBALANCER_HPP
#define EXAMPM_LOADBALANCER_HPP

#include <ExaMPM_Mesh.hpp>
#include <ExaMPM_ProblemManager.hpp>
#include <ExaMPM_VTKDomainWriter.hpp>

#include <Cajita_LoadBalancer.hpp>

#include <string>

#include <mpi.h>

namespace ExaMPM
{
template <class MemorySpace>
class LoadBalancer
{
public:
using mesh_type = Mesh<MemorySpace>;
// todo(sschulz): Allow for arbitrary dimension
LoadBalancer( MPI_Comm comm, std::shared_ptr<mesh_type>& mesh )
: _comm( comm )
, _mesh( mesh )
{
MPI_Comm_rank( comm, &_rank );
_lb = std::make_shared<Cajita::LoadBalancer<UniformMesh<double>>>(
_mesh->localGrid()->globalGrid(), 3. * _mesh->cellSize() );
}

// This will update the domain decomposition and also update the mesh
void balance( std::shared_ptr<ProblemManager<MemorySpace>> pm )
{
double work = pm->numParticle();
// todo(sschulz): How to save the partitioner, without requiring a
// shared ptr everywhere?
auto partitioner = auto global_grid =
_lb->createBalancedGlobalGrid( _mesh->globalMesh(), partitioner,
work )
_mesh->newGlobalGrid( global_grid );
pm->updateMesh( _mesh );
}

// Output the actual and internal load balancing grid to VTK files
void output( const int t ) const
{
std::string vtk_actual_domain_basename( "domain_act" );
std::string vtk_lb_domain_basename( "domain_lb" );
VTKDomainWriter::writeDomain( _comm, t, _lb->getVertices(),
vtk_actual_domain_basename );
VTKDomainWriter::writeDomain( _comm, t, _lb->getInternalVertices(),
vtk_lb_domain_basename );
}

private:
MPI_Comm _comm;
std::shared_ptr<mesh_type> _mesh;
std::shared_ptr<ALL::ALL<double, double>> _liball;
int _rank;
};
} // end namespace ExaMPM
#endif // EXAMPM_LOADBALANCER_HPP
38 changes: 33 additions & 5 deletions src/ExaMPM_Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,25 @@ class Mesh
}

// Create the global mesh.
auto global_mesh = Cajita::createUniformGlobalMesh(
_global_mesh = Cajita::createUniformGlobalMesh(
global_low_corner, global_high_corner, num_cell );

// Build the global grid.
auto global_grid = Cajita::createGlobalGrid( comm, global_mesh,
periodic, partitioner );
_global_grid = Cajita::createGlobalGrid( comm, _global_mesh, periodic,
partitioner );

// Build the local grid.
int halo_width = std::max( minimum_halo_cell_width, halo_cell_width );
_local_grid = Cajita::createLocalGrid( global_grid, halo_width );
_halo_width = std::max( minimum_halo_cell_width, halo_cell_width );
_local_grid = Cajita::createLocalGrid( _global_grid, _halo_width );
}

// Global grid updated and update local values
void newGlobalGrid(
std::shared_ptr<Cajita::GlobalGrid<Cajita::UniformMesh<double>>>&
global_grid )
{
_global_grid = global_grid;
_local_grid = Cajita::createLocalGrid( _global_grid, _halo_width );
}

// Get the local grid.
Expand All @@ -110,6 +119,19 @@ class Mesh
return _local_grid;
}

// Get the mutable global grid.
const std::shared_ptr<Cajita::GlobalGrid<Cajita::UniformMesh<double>>>&
globalGrid()
{
return _global_grid;
}

const std::shared_ptr<Cajita::GlobalMesh<Cajita::UniformMesh<double>>>&
globalMesh() const
{
return _global_mesh;
}

// Get the cell size.
double cellSize() const
{
Expand All @@ -130,6 +152,12 @@ class Mesh

public:
std::shared_ptr<Cajita::LocalGrid<Cajita::UniformMesh<double>>> _local_grid;
std::shared_ptr<Cajita::GlobalGrid<Cajita::UniformMesh<double>>>
_global_grid;
std::shared_ptr<Cajita::GlobalMesh<Cajita::UniformMesh<double>>>
_global_mesh;

int _halo_width;

Kokkos::Array<int, 3> _min_domain_global_node_index;
Kokkos::Array<int, 3> _max_domain_global_node_index;
Expand Down
33 changes: 33 additions & 0 deletions src/ExaMPM_ProblemManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,39 @@ class ProblemManager
*cell_scalar_layout, Cajita::FullHaloPattern() );
}

void updateMesh( const std::shared_ptr<mesh_type>& mesh )
{
auto node_vector_layout =
Cajita::createArrayLayout( _mesh->localGrid(), 3, Cajita::Node() );
auto node_scalar_layout =
Cajita::createArrayLayout( _mesh->localGrid(), 1, Cajita::Node() );
auto cell_scalar_layout =
Cajita::createArrayLayout( _mesh->localGrid(), 1, Cajita::Cell() );

_momentum = Cajita::createArray<double, MemorySpace>(
"momentum", node_vector_layout );
_mass = Cajita::createArray<double, MemorySpace>( "mass",
node_scalar_layout );
_force = Cajita::createArray<double, MemorySpace>( "force",
node_vector_layout );
_velocity = Cajita::createArray<double, MemorySpace>(
"velocity", node_vector_layout );
_position_correction = Cajita::createArray<double, MemorySpace>(
"position_correction", node_vector_layout );
_density = Cajita::createArray<double, MemorySpace>(
"density", cell_scalar_layout );

_mark = Cajita::createArray<double, MemorySpace>( "mark",
cell_scalar_layout );

_node_vector_halo = Cajita::createHalo<double, MemorySpace>(
*node_vector_layout, Cajita::FullHaloPattern() );
_node_scalar_halo = Cajita::createHalo<double, MemorySpace>(
*node_scalar_layout, Cajita::FullHaloPattern() );
_cell_scalar_halo = Cajita::createHalo<double, MemorySpace>(
*cell_scalar_layout, Cajita::FullHaloPattern() );
}

std::size_t numParticle() const { return _particles.size(); }

const std::shared_ptr<mesh_type>& mesh() const { return _mesh; }
Expand Down
Loading