Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jdolence committed Oct 25, 2023
2 parents 50c7acf + abfae20 commit 9911aa7
Show file tree
Hide file tree
Showing 29 changed files with 406 additions and 179 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Current develop

### Added (new features/APIs/variables/...)
- [[PR 907]](https://github.com/parthenon-hpc-lab/parthenon/pull/907) PEP1: Allow subclassing StateDescriptor
- [[PR 932]](https://github.com/parthenon-hpc-lab/parthenon/pull/932) Add GetOrAddFlag to metadata
- [[PR 931]](https://github.com/parthenon-hpc-lab/parthenon/pull/931) Allow SparsePacks with subsets of blocks
- [[PR 921]](https://github.com/parthenon-hpc-lab/parthenon/pull/921) Add more flexible ways of adding and using MeshData/MeshBlockData objects to DataCollections
Expand All @@ -25,17 +26,25 @@
- [[PR 885]](https://github.com/parthenon-hpc-lab/parthenon/pull/885) Expose PackDescriptor and use uids in SparsePacks

### Fixed (not changing behavior/API/variables/...)
- [[PR 955]](https://github.com/parthenon-hpc-lab/parthenon/pull/955) Only permit rank0 to mkdir when -d flag specified
- [[PR 952]](https://github.com/parthenon-hpc-lab/parthenon/pull/954) Fix format string in sparse advection example
- [[PR 947]](https://github.com/parthenon-hpc-lab/parthenon/pull/947) Add missing ForceRemeshComm dependencies
- [[PR 928]](https://github.com/parthenon-hpc-lab/parthenon/pull/928) Fix boundary comms during refinement next to refined blocks
- [[PR 937]](https://github.com/parthenon-hpc-lab/parthenon/pull/937) Fix multiple line continuations
- [[PR 933]](https://github.com/parthenon-hpc-lab/parthenon/pull/933) Remove extraneous debug check
- [[PR 917]](https://github.com/parthenon-hpc-lab/parthenon/pull/917) Update Iterative Tasking Infrastructure
- [[PR 890]](https://github.com/parthenon-hpc-lab/parthenon/pull/890) Fix bugs in sparse communication and prolongation

### Infrastructure (changes irrelevant to downstream codes)
- [[PR 967]](https://github.com/parthenon-hpc-lab/parthenon/pull/967) Change INLINE to FORCEINLINE on par_for_inner overloads
- [[PR 938]](https://github.com/parthenon-hpc-lab/parthenon/pull/938) Restructure buffer packing/unpacking kernel hierarchical parallelism
- [[PR 944]](https://github.com/parthenon-hpc-lab/parthenon/pull/944) Move sparse pack identifier creation to descriptor
- [[PR 904]](https://github.com/parthenon-hpc-lab/parthenon/pull/904) Move to prolongation/restriction in one for AMR and communicate non-cell centered fields
- [[PR 918]](https://github.com/parthenon-hpc-lab/parthenon/pull/918) Refactor RegionSize
- [[PR 918]](https://github.com/parthenon-hpc-lab/parthenon/pull/918) Refactor RegionSize
- [[PR 901]](https://github.com/parthenon-hpc-lab/parthenon/pull/901) Implement shared element ownership model

### Removed (removing behavior/API/varaibles/...)

- [[PR 930](https://github.com/parthenon-hpc-lab/parthenon/pull/930) Remove ParthenonManager::ParthenonInit as it is error-prone and the split functions are the recommended usage.

## Release 0.8.0
Date: 2023-05-26
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/burgers/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2022-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
pman.app_input->ProblemGenerator = burgers_benchmark::ProblemGenerator;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
// make use of MPI and Kokkos

// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
// Initialize the driver
burgers_benchmark::BurgersDriver driver(pman.pinput.get(), pman.app_input.get(),
Expand Down
67 changes: 67 additions & 0 deletions doc/sphinx/src/parthenon_manager.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.. _parthenonmanager:

Parthenon Manager
=================

The ``ParthenonManager`` class helps set up a parthenon-based
application. An instance of ``ParthenonManager`` owns pointers a
number of sub-objects:

* The ``ApplicationInput`` struct, which lets users set things like
the ``ProcessPackages`` and ``ProblemGenerator`` function pointers.
* The ``ParameterInput`` class, which populates input parameters from
the input file and command line
* The ``Mesh`` object

The ``ParthenonManager`` has two important methods that usually must
be called in the ``main`` function of a parthenon-based app. The
function

.. code:: cpp
ParthenonStatus ParthenonManager::ParthenonInitEnv(int argc, char *argv);
reads the input deck and populates the ``ParameterInput`` object
pointer ``pman.pin``, and sets up the ``MPI``, and ``Kokkos``
runtimes. The function

.. code:: cpp
void ParthenonManager::ParthenonInitPackagesAndMesh();
Calls the ``Initialize(ParameterInput *pin)`` function of all packages
to be utilized and creates the grid hierarchy, including the ``Mesh``
and ``MeshBlock`` objects, and calls the ``ProblemGenerator``
initialization routines.

The reason these functions are split out is to enable decisions to be
made by the application between reading the input deck and setting up
the grid. For example, a common use-case is:

.. code:: cpp
using parthenon::ParthenonManager;
using parthenon::ParthenonStatus;
ParthenonManager pman;
// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
}
if (manager_status == ParthenonStatus::error) {
pman.ParthenonFinalize();
return 1;
}
// Redefine parthenon defaults
pman.app_input->ProcessPackages = MyProcessPackages;
std::string prob = pman.pin->GetString("app", "problem");
if (prob == "problem1") {
pman.app_input->ProblemGenerator = Problem1Generator;
} else {
pman.app_input->ProblemGenerator = Problem2Generator;
}
pman.ParthenonInitPackagesAndMesh();
6 changes: 4 additions & 2 deletions example/advection/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) {
pman.app_input->UserWorkAfterLoop = advection_example::UserWorkAfterLoop;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -35,9 +35,11 @@ int main(int argc, char *argv[]) {
pman.ParthenonFinalize();
return 1;
}

// Now that ParthenonInit has been called and setup succeeded, the code can now
// make use of MPI and Kokkos.
// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
// Initialize the driver
advection_example::AdvectionDriver driver(pman.pinput.get(), pman.app_input.get(),
Expand Down
5 changes: 3 additions & 2 deletions example/calculate_pi/pi_driver.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2020-2021. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand Down Expand Up @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
// This is called on each mesh block whenever the mesh changes.
pman.app_input->InitMeshBlockUserData = &calculate_pi::SetInOrOutBlock;

auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -50,6 +50,7 @@ int main(int argc, char *argv[]) {
}

// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
PiDriver driver(pman.pinput.get(), pman.app_input.get(), pman.pmesh.get());

Expand Down
5 changes: 3 additions & 2 deletions example/particle_leapfrog/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
pman.app_input->ProblemGenerator = particles_leapfrog::ProblemGenerator;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -37,6 +37,7 @@ int main(int argc, char *argv[]) {
// Now that ParthenonInit has been called and setup succeeded, the code can now
// make use of MPI and Kokkos

pman.ParthenonInitPackagesAndMesh();
// This needs to be scoped so that the driver object is destructed before Finalize
{
// Initialize the driver
Expand Down
5 changes: 3 additions & 2 deletions example/particle_tracers/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2021. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2021-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
pman.app_input->ProblemGenerator = tracers_example::ProblemGenerator;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
// make use of MPI and Kokkos

// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
// Initialize the driver
tracers_example::ParticleDriver driver(pman.pinput.get(), pman.app_input.get(),
Expand Down
5 changes: 3 additions & 2 deletions example/poisson/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2021. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2021-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
pman.app_input->MeshProblemGenerator = poisson_example::ProblemGenerator;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
// make use of MPI and Kokkos

// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
// Initialize the driver
poisson_example::PoissonDriver driver(pman.pinput.get(), pman.app_input.get(),
Expand Down
5 changes: 3 additions & 2 deletions example/sparse_advection/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2021. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2021-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand Down Expand Up @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
sparse_advection_example::PostStepDiagnosticsInLoop;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -43,6 +43,7 @@ int main(int argc, char *argv[]) {

DriverStatus driver_status;
// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
// Initialize the driver
sparse_advection_example::SparseAdvectionDriver driver(
Expand Down
4 changes: 2 additions & 2 deletions example/sparse_advection/parthenon_app_inputs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) (or copyright) 2021. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand Down Expand Up @@ -176,7 +176,7 @@ void PostStepDiagnosticsInLoop(Mesh *mesh, ParameterInput *pin, const SimTime &t
}
std::printf("\n");
Real mem_avg = static_cast<Real>(mem_tot) / static_cast<Real>(blocks_tot);
std::printf("\tMem used/block in bytes [min, max, avg] = [%ld, %ld, %.14e]\n",
std::printf("\tMem used/block in bytes [min, max, avg] = [%lu, %lu, %.14e]\n",
mem_min, mem_max, mem_avg);
}
}
Expand Down
5 changes: 3 additions & 2 deletions example/stochastic_subgrid/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//========================================================================================
// (C) (or copyright) 2020-2021. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) {
pman.app_input->UserWorkAfterLoop = stochastic_subgrid_example::UserWorkAfterLoop;

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInit(argc, argv);
auto manager_status = pman.ParthenonInitEnv(argc, argv);
if (manager_status == ParthenonStatus::complete) {
pman.ParthenonFinalize();
return 0;
Expand All @@ -39,6 +39,7 @@ int main(int argc, char *argv[]) {
// make use of MPI and Kokkos

// This needs to be scoped so that the driver object is destructed before Finalize
pman.ParthenonInitPackagesAndMesh();
{
// Initialize the driver
stochastic_subgrid_example::StochasticSubgridDriver driver(
Expand Down
8 changes: 6 additions & 2 deletions src/bvals/bvals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <memory>
#include <string>
#include <unordered_set>
#include <vector>

#include "basic_types.hpp"
Expand Down Expand Up @@ -78,7 +79,9 @@ class BoundaryBase {
static int BufferID(int dim, bool multilevel);
static int FindBufferID(int ox1, int ox2, int ox3, int fi1, int fi2);

void SearchAndSetNeighbors(MeshBlockTree &tree, int *ranklist, int *nslist);
void
SearchAndSetNeighbors(MeshBlockTree &tree, int *ranklist, int *nslist,
const std::unordered_set<LogicalLocation> &newly_refined = {});

protected:
// 1D refined or unrefined=2
Expand All @@ -90,7 +93,8 @@ class BoundaryBase {
RegionSize block_size_;
ParArrayND<Real> sarea_[2];

void SetNeighborOwnership();
void
SetNeighborOwnership(const std::unordered_set<LogicalLocation> &newly_refined = {});

private:
// calculate 3x shared static data members when constructing only the 1st class instance
Expand Down
Loading

0 comments on commit 9911aa7

Please sign in to comment.