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

Improving "not cyclic" solver #2314

Open
wants to merge 21 commits into
base: next
Choose a base branch
from
Open

Improving "not cyclic" solver #2314

wants to merge 21 commits into from

Conversation

bendudson
Copy link
Contributor

By default all processors are used, resulting in an all-to-all communication pattern.

An optional third argument to the constructor now specifies how many processors should be used. This reduces the number of messages, at the cost of increasing load imbalance. The processors used are evenly
distributed, in the hope that this will minimise network traffic on any given node.

bendudson and others added 5 commits May 12, 2021 17:01
By default all processors are used, resulting in an all-to-all
communication pattern.

An optional third argument to the constructor now specifies how many
processors should be used. This reduces the number of messages, at the
cost of increasing load imbalance. The processors used are evenly
distributed, in the hope that this will minimise network traffic on
any given node.
Input option to control the number of processors (in X) to gather
systems onto. This can be used to tune performance: Smaller ngather
leads to fewer messages, but more load imbalance.

Modified test, to cover more variations of nxpe and ngather.

That test found some bugs, which are fixed here.
@bendudson bendudson changed the title WIP improving "not cyclic" solver Improving "not cyclic" solver May 13, 2021
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


#include "output.hxx"

#include "bout/openmpwrap.hxx"

template <class T> class CyclicReduce {
template <class T>
class CyclicReduce {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: comm, myns, sys0 [cppcoreguidelines-pro-type-member-init]

class CyclicReduce {
      ^


#include "output.hxx"

#include "bout/openmpwrap.hxx"

template <class T> class CyclicReduce {
template <class T>
class CyclicReduce {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class CyclicReduce defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

include/cyclic_reduction.hxx Outdated Show resolved Hide resolved
include/cyclic_reduction.hxx Outdated Show resolved Hide resolved
include/cyclic_reduction.hxx Outdated Show resolved Hide resolved
src/invert/laplace/impls/cyclic/cyclic_laplace.cxx Outdated Show resolved Hide resolved
src/invert/laplace/impls/cyclic/cyclic_laplace.cxx Outdated Show resolved Hide resolved
src/invert/laplace/impls/cyclic/cyclic_laplace.cxx Outdated Show resolved Hide resolved
src/invert/laplace/impls/cyclic/cyclic_laplace.cxx Outdated Show resolved Hide resolved
tests/integrated/test-cyclic/test_cyclic.cxx Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

include/cyclic_reduction.hxx Outdated Show resolved Hide resolved
src/invert/laplace/impls/cyclic/cyclic_laplace.cxx Outdated Show resolved Hide resolved
Clang-tidy and @ZedThree suggestions
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

include/cyclic_reduction.hxx Outdated Show resolved Hide resolved

#include "output.hxx"

#include "bout/openmpwrap.hxx"

template <class T> class CyclicReduce {
template <class T>
class CyclicReduce {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: class 'CyclicReduce' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

class CyclicReduce {
      ^

include/cyclic_reduction.hxx Outdated Show resolved Hide resolved
include/cyclic_reduction.hxx Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

include/bout/cyclic_reduction.hxx Outdated Show resolved Hide resolved
include/bout/cyclic_reduction.hxx Outdated Show resolved Hide resolved
include/bout/cyclic_reduction.hxx Outdated Show resolved Hide resolved
include/bout/cyclic_reduction.hxx Outdated Show resolved Hide resolved
@bendudson bendudson changed the base branch from next to v5.1.0-rc June 14, 2023 21:10
@bendudson bendudson added this to the BOUT-5.1 milestone Jun 14, 2023
@bendudson bendudson changed the base branch from v5.1.0-rc to next June 15, 2023 01:25
@bendudson bendudson removed this from the BOUT-5.1 milestone Jun 15, 2023
@bendudson
Copy link
Contributor Author

Failing some tests for what looks like an unrelated change (bad merge?). Doesn't need to go into v5.1.0 so can go into next later.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

CyclicReduce(MPI_Comm c, int size) : comm(c), N(size) {
MPI_Comm_size(c, &nprocs);
MPI_Comm_rank(c, &myproc);
CyclicReduce(MPI_Comm c, int size, int ngather = 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length]

  CyclicReduce(MPI_Comm c, int size, int ngather = 0)
                        ^

/// @param[in] c The communicator of all processors involved in the solve
/// @param[in] size The number of rows on this processor
void setup(MPI_Comm c, int size) {
/// @param[in] gather The number of processors to gather onto. If 0, use all processors
void setup(MPI_Comm c, int size, int ngather = 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length]

  void setup(MPI_Comm c, int size, int ngather = 0) {
                      ^

BoutReal pinterval = static_cast<BoutReal>(nprocs) / ngatherprocs;

{
int ns =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable name 'ns' is too short, expected at least 3 characters [readability-identifier-length]

      int ns =
          ^

int ns =
Nsys / ngatherprocs; // Number of systems to assign to all gathering processors
int nsextra = Nsys % ngatherprocs; // Number of processors with 1 extra
int s0 = 0; // Starting system number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable name 's0' is too short, expected at least 3 characters [readability-identifier-length]

      int s0 = 0;                        // Starting system number
          ^

// Loop over gathering processors
for (int i = 0; i < ngatherprocs; i++) {

int p = i; // Gathering onto all processors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable name 'p' is too short, expected at least 3 characters [readability-identifier-length]

        int p = i; // Gathering onto all processors
            ^

if (myproc < nsextra) {
myns++;
sys0 += myproc;
int ns = nsys / ngatherprocs; // Number of systems to assign to all processors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable name 'ns' is too short, expected at least 3 characters [readability-identifier-length]

    int ns = nsys / ngatherprocs;      // Number of systems to assign to all processors
        ^


// Calculate which processors these are
for (int i = 0; i < ngatherprocs; i++) {
int proc = static_cast<int>(pinterval * i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'proc' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int proc = static_cast<int>(pinterval * i);
int const proc = static_cast<int>(pinterval * i);

@@ -96,16 +96,16 @@ LaplaceCyclic::LaplaceCyclic(Options* opt, const CELL_LOC loc, Mesh* mesh_in,
xcmplx.reallocate(nmode, n);
bcmplx.reallocate(nmode, n);

int ngather =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'ngather' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int ngather =
int const ngather =

int mype, npe;
MPI_Comm_rank(BoutComm::get(), &mype);
MPI_Comm_size(BoutComm::get(), &npe);

int ngather =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'ngather' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int ngather =
int const ngather =

options["ngather"].doc("The number of processors to gather onto").withDefault(npe);

// Create a cyclic reduction object, operating on Ts
auto cr = std::make_unique<CyclicReduce<T>>(BoutComm::get(), n, ngather);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable name 'cr' is too short, expected at least 3 characters [readability-identifier-length]

  auto cr = std::make_unique<CyclicReduce<T>>(BoutComm::get(), n, ngather);
       ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants