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 all 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;$HOME/ALL" -DCabana_REQUIRE_${{ matrix.backend }}=ON -DCabana_REQUIRE_ALL=ON
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.12)
project(ExaMPM LANGUAGES CXX VERSION 0.1.0)

include(GNUInstallDirs)
include(CMakeDependentOption)

# find dependencies
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
Expand All @@ -16,6 +17,8 @@ if( NOT Cabana_ENABLE_CAJITA )
endif()
find_package(Silo REQUIRED)

cmake_dependent_option(ExaMPM_ENABLE_LB "Enable Cabana load balancing" ON Cabana_ENABLE_ALL OFF)

# find Clang Format
find_package( CLANG_FORMAT 10 )

Expand Down
13 changes: 9 additions & 4 deletions examples/dam_break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct ParticleInitFunc
//---------------------------------------------------------------------------//
void damBreak( const double cell_size, const int ppc, const int halo_size,
const double delta_t, const double t_final, const int write_freq,
const std::string& device )
const std::string& device, const int lb_freq )
{
// The dam break domain is in a box on [0,1] in each dimension.
Kokkos::Array<double, 6> global_box = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 };
Expand All @@ -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 All @@ -112,7 +113,7 @@ void damBreak( const double cell_size, const int ppc, const int halo_size,
device, MPI_COMM_WORLD, global_box, global_num_cell, periodic,
partitioner, halo_size, ParticleInitFunc( cell_size, ppc, density ),
ppc, bulk_modulus, density, gamma, kappa, delta_t, gravity, bc );
solver->solve( t_final, write_freq );
solver->solve( t_final, write_freq, lb_freq );
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -143,8 +144,12 @@ int main( int argc, char* argv[] )
// device type
std::string device( argv[7] );

// optional lb frequency
int lb_freq = argc > 8 ? std::atoi( argv[8] ) : 10;

// run the problem.
damBreak( cell_size, ppc, halo_size, delta_t, t_final, write_freq, device );
damBreak( cell_size, ppc, halo_size, delta_t, t_final, write_freq, device,
lb_freq );

Kokkos::finalize();

Expand Down
13 changes: 9 additions & 4 deletions examples/free_fall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct ParticleInitFunc
//---------------------------------------------------------------------------//
void freeFall( const double cell_size, const int ppc, const int halo_size,
const double delta_t, const double t_final, const int write_freq,
const std::string& device )
const std::string& device, const int lb_freq )
{
// The dam break domain is in a box on [0,1] in each dimension.
Kokkos::Array<double, 6> global_box = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 };
Expand All @@ -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 All @@ -111,7 +112,7 @@ void freeFall( const double cell_size, const int ppc, const int halo_size,
device, MPI_COMM_WORLD, global_box, global_num_cell, periodic,
partitioner, halo_size, ParticleInitFunc( cell_size, ppc, density ),
ppc, bulk_modulus, density, gamma, kappa, delta_t, gravity, bc );
solver->solve( t_final, write_freq );
solver->solve( t_final, write_freq, lb_freq );
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -142,8 +143,12 @@ int main( int argc, char* argv[] )
// device type
std::string device( argv[7] );

// optional lb frequency
int lb_freq = argc > 8 ? std::atoi( argv[8] ) : 10;

// run the problem.
freeFall( cell_size, ppc, halo_size, delta_t, t_final, write_freq, device );
freeFall( cell_size, ppc, halo_size, delta_t, t_final, write_freq, device,
lb_freq );

Kokkos::finalize();

Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(HEADERS
ExaMPM_Solver.hpp
ExaMPM_TimeIntegrator.hpp
ExaMPM_Types.hpp
ExaMPM_VTKDomainWriter.hpp
ExaMPM_VelocityInterpolation.hpp
)

Expand All @@ -17,6 +18,10 @@ set(SOURCES

add_library(exampm ${SOURCES})

if(ExaMPM_ENABLE_LB)
target_compile_definitions(exampm PUBLIC ExaMPM_ENABLE_LB)
endif()

target_link_libraries(exampm
Cabana::cabanacore
Cabana::Cajita
Expand Down
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
8 changes: 8 additions & 0 deletions src/ExaMPM_ProblemManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ class ProblemManager
{
initializeParticles( exec_space, *( _mesh->localGrid() ),
particles_per_cell, create_functor, _particles );
updateMesh( mesh );
}

void updateMesh( const std::shared_ptr<mesh_type>& mesh )
{
_mesh = mesh;
auto node_vector_layout =
Cajita::createArrayLayout( _mesh->localGrid(), 3, Cajita::Node() );
auto node_scalar_layout =
Expand Down Expand Up @@ -259,6 +264,9 @@ class ProblemManager

void scatter( Location::Cell, Field::Density ) const
{
printf( "%s: _density extent %lu %lu %lu\n", __func__,
_density->view().extent( 0 ), _density->view().extent( 1 ),
_density->view().extent( 2 ) );
_cell_scalar_halo->scatter( execution_space(),
Cajita::ScatterReduce::Sum(), *_density );
}
Expand Down
2 changes: 2 additions & 0 deletions src/ExaMPM_SiloParticleWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ void writeTimeStep( const GlobalGridType& global_grid,
// Mirror the coordinates to the host.
auto host_coords =
Kokkos::create_mirror_view_and_copy( Kokkos::HostSpace(), view );
// todo(sschulz): Handle empty domains. Without kokkos debug build this
// seems to work. But it should still be handled properly.

// Add the point mesh.
std::string mesh_name = "particles";
Expand Down
Loading