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

Implicit calls in nested loop #20

Open
mcopik opened this issue Apr 9, 2020 · 0 comments
Open

Implicit calls in nested loop #20

mcopik opened this issue Apr 9, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@mcopik
Copy link
Collaborator

mcopik commented Apr 9, 2020

Currently calls of implicit functions are always in the function and the loop structure is ignored.
The call should be placed in the loop.

#include <cmath>
#include <cstdlib>

#define OMPI_SKIP_MPICXX
#include <mpi.h>

#include "ExtraPInstrumenter.hpp"

// Test reproducing a bug where an impliict call is placed incorrectly - outside
// of the loop.

MPI_Request send(int * val, int rank)
{
  MPI_Request req;
  MPI_Isend(val, 1, MPI_INT, 1 - rank, 0, MPI_COMM_WORLD, &req);
  return req;
}

void f(int x1, int x2, MPI_Request req)
{
  int tmp = 0;
  for(int i = 0; i < x1; i += 1)
    tmp += i*1.1;
  for(int j = 0; j < x2; j += 1)
    MPI_Wait(&req, MPI_STATUS_IGNORE);
}

int main(int argc, char ** argv)
{
  MPI_Init(&argc, &argv);
  int rank, size;
  int val = 1;
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  int x1 EXTRAP = atoi(argv[1]);
  int x2 EXTRAP = 2*atoi(argv[2]);
  register_variable(&x1, VARIABLE_NAME(x1));
  register_variable(&x2, VARIABLE_NAME(x2));
  MPI_Request req = send(&val, rank);
  f(x1, x2, req);
  MPI_Finalize();
  return 0;
}

Produces

{
  "functions": {
    "MPI_Wait": {
      "func_idx": 1,
      "loops": [
        {
          "callstacks": [
            [
              2,
              0
            ]
          ],
          "instance": {
            "0": {
              "level": 0,
            "0": {
              "level": 0,
              "params": [
                "p"
              ]
            }
          }
        }
      ]
    },
    "_Z1fiiP14ompi_request_t": {
      "file": "bug_loop_implicit_function.cpp",
      "func_idx": 0,
      "line": 23,
      "loops": [
        {
          "callstacks": [
            [
              2
            ]
          ],
          "instance": {
            "0": {
              "level": 0,
              "params": [
                [
                  "x2"
                ]
              ]
            },
            "1": {
              "level": 0,
              "params": [
                [
                  "x1"
                ]
              ]
            },
            "2": {
              "level": 0,
              "params": [
                [
                  "p"
                ]
              ]
            }
          }
        }
      ]
    }
  },
  "functions_demangled_names": [
    "f(int, int, ompi_request_t*)",
    "MPI_Wait",
    "main",
    "void register_variable<int>(int*, char const*)",
    "send(int*, int)"
  ],
  "functions_mangled_names": [
    "_Z1fiiP14ompi_request_t",
    "MPI_Wait",
    "main",
    "_Z17register_variableIiEvPT_PKc",
    "_Z4sendPii"
  ],
  "functions_names": [
    "f",
    "MPI_Wait",
    "main",
    "register_variable<int>",
    "send"
  ],
  "parameters": [
    "x1",
    "x2",
    "p"
  ]
}
@mcopik mcopik added the bug Something isn't working label Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant