Coverage Report

Created: 2023-10-30 17:15

/builds/2mk6rsew/0/parcoach/parcoach/src/rma/RMAStatisticsAnalysis.cpp
Line
Count
Source (jump to first uncovered line)
1
#include "parcoach/RMAPasses.h"
2
#include "llvm/IR/InstIterator.h"
3
4
using namespace llvm;
5
namespace parcoach::rma {
6
7
namespace {
8
void CountMPIfuncs(RMAStatisticsAnalysis::Result &Res, Instruction &I,
9
697
                   StringRef Name) {
10
11
697
  if (Name == "MPI_Get" || Name == "mpi_get_") {
12
32
    Res.Get++;
13
665
  } else if (Name == "MPI_Put" || Name == "mpi_put_") {
14
48
    Res.Put++;
15
617
  } else if (Name == "MPI_Win_create" || Name == "mpi_win_create_") {
16
67
    Res.Win++;
17
550
  } else if (Name == "MPI_Win_allocate" || Name == "mpi_win_allocate_") {
18
0
    Res.Win++;
19
550
  } else if (Name == "MPI_Accumulate" || Name == "mpi_accumulate_") {
20
0
    Res.Acc++;
21
550
  } else if (Name == "MPI_Win_fence" || Name == "mpi_win_fence_") {
22
0
    Res.Fence++;
23
550
  } else if (Name == "MPI_Win_flush" || Name == "mpi_win_flush_") {
24
0
    Res.Flush++;
25
550
  } else if (Name == "MPI_Win_lock" || Name == "mpi_win_lock_") {
26
0
    Res.Lock++;
27
550
  } else if (Name == "MPI_Win_unlock" || Name == "mpi_win_unlock_") {
28
0
    Res.Unlock++;
29
550
  } else if (Name == "MPI_Win_unlock_all" || Name == "mpi_win_unlock_all_") {
30
67
    Res.Unlockall++;
31
483
  } else if (Name == "MPI_Win_lock_all" || Name == "mpi_win_lock_all_") {
32
67
    Res.Lockall++;
33
416
  } else if (Name == "MPI_Win_free" || Name == "mpi_win_free_") {
34
67
    Res.Free++;
35
349
  } else if (Name == "MPI_Barrier" || Name == "mpi_barrier_") {
36
4
    Res.Barrier++;
37
4
  }
38
697
}
39
} // namespace
40
41
AnalysisKey RMAStatisticsAnalysis::Key;
42
43
RMAStatisticsAnalysis::Statistics
44
67
RMAStatisticsAnalysis::run(Function &F, FunctionAnalysisManager &) {
45
67
  TimeTraceScope TTS("RMAStatisticsAnalysis");
46
67
  Statistics Res{};
47
5.14k
  for (Instruction &I : instructions(F)) {
48
5.14k
    DebugLoc dbg = I.getDebugLoc(); // get debug infos
49
5.14k
    if (CallBase *cb = dyn_cast<CallBase>(&I)) {
50
1.75k
      if (Function *calledFunction = cb->getCalledFunction()) {
51
1.75k
        StringRef FName = calledFunction->getName();
52
1.75k
        if (FName.startswith("MPI_") || FName.startswith("mpi_")) {
53
697
          Res.Mpi++;
54
697
          CountMPIfuncs(Res, I, calledFunction->getName());
55
697
        }
56
1.75k
      }
57
1.75k
    }
58
5.14k
  }
59
67
  return Res;
60
67
}
61
62
67
size_t RMAStatisticsAnalysis::Statistics::getTotalRMA() const {
63
67
  return Win + Put + Get + Fence + Acc + Lock + Lockall + Unlock + Unlockall +
64
67
         Free + Flush;
65
67
}
66
67
67
size_t RMAStatisticsAnalysis::Statistics::getTotalOneSided() const {
68
67
  return Put + Get + Acc;
69
67
}
70
71
} // namespace parcoach::rma