• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 30662130446

31 Jul 2026 08:14PM UTC coverage: 81.463% (+0.06%) from 81.4%
30662130446

Pull #3934

github

web-flow
Merge c44d91937 into a8152672b
Pull Request #3934: Fix virtual surface crossing

18514 of 26799 branches covered (69.08%)

Branch coverage included in aggregate %.

23 of 23 new or added lines in 1 file covered. (100.0%)

1004 existing lines in 27 files now uncovered.

60272 of 69915 relevant lines covered (86.21%)

50336961.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.87
/src/message_passing.cpp
1
#include "openmc/message_passing.h"
2

3
#include <algorithm>
4
#include <climits>
5
#include <limits>
6

7
namespace openmc {
8
namespace mpi {
9

10
int rank {0};
11
int n_procs {1};
12
bool master {true};
13

14
#ifdef OPENMC_MPI
15
MPI_Comm intracomm {MPI_COMM_NULL};
16
MPI_Datatype source_site {MPI_DATATYPE_NULL};
17
MPI_Datatype collision_track_site {MPI_DATATYPE_NULL};
18
#endif
19

20
extern "C" bool openmc_master()
10,230✔
21
{
22
  return mpi::master;
10,230✔
23
}
24

25
vector<int64_t> calculate_parallel_index_vector(int64_t size)
1,369✔
26
{
27
  vector<int64_t> result;
1,369✔
28
  result.resize(n_procs + 1);
1,369✔
29
  result[0] = 0;
1,369✔
30

31
#ifdef OPENMC_MPI
32

33
  // Populate the result with cumulative sum of the number of
34
  // surface source banks per process
35
  int64_t scan_total;
520✔
36
  MPI_Scan(&size, &scan_total, 1, MPI_INT64_T, MPI_SUM, intracomm);
520✔
37
  MPI_Allgather(
520✔
38
    &scan_total, 1, MPI_INT64_T, result.data() + 1, 1, MPI_INT64_T, intracomm);
520✔
39
#else
40
  result[1] = size;
849✔
41
#endif
42

43
  return result;
1,369✔
UNCOV
44
}
×
45

46
#ifdef OPENMC_MPI
47
void reduce_buffer(const void* sendbuf, void* recvbuf, std::size_t count,
57,992✔
48
  MPI_Datatype datatype, std::size_t type_size, MPI_Op op, int root,
49
  MPI_Comm comm)
50
{
51
  // Determine the maximum number of elements accepted by the selected API.
52
#ifdef OPENMC_HAVE_MPI_REDUCE_C
53
  const std::size_t chunk_limit {
57,992✔
54
    static_cast<std::size_t>(std::numeric_limits<MPI_Count>::max())};
55
#else
56
  constexpr std::size_t chunk_limit {INT_MAX};
57
#endif
58

59
  // A legacy MPI reduction accepts an int count, so split the logical buffer
60
  // into bounded chunks before converting the count.
61
  for (std::size_t offset = 0; offset < count; offset += chunk_limit) {
115,984✔
62
    const std::size_t chunk_size = std::min(count - offset, chunk_limit);
57,992!
63

64
    // MPI_IN_PLACE must be passed unchanged on the root. Other buffers are
65
    // advanced by the chunk offset in bytes because their element type is
66
    // represented by an MPI datatype rather than a C++ pointer type here.
67
    const void* send_chunk =
115,984✔
68
      sendbuf == MPI_IN_PLACE
69
        ? MPI_IN_PLACE
57,992✔
70
        : static_cast<const char*>(sendbuf) + offset * type_size;
57,988✔
71
    void* recv_chunk = recvbuf == nullptr
115,984✔
72
                         ? nullptr
57,992✔
73
                         : static_cast<char*>(recvbuf) + offset * type_size;
57,988✔
74

75
#ifdef OPENMC_HAVE_MPI_REDUCE_C
76
    MPI_Reduce_c(send_chunk, recv_chunk, static_cast<MPI_Count>(chunk_size),
57,992✔
77
      datatype, op, root, comm);
78
#else
79
    MPI_Reduce(send_chunk, recv_chunk, static_cast<int>(chunk_size), datatype,
80
      op, root, comm);
81
#endif
82
  }
83
}
57,992✔
84

85
// Specializations of the MPITypeMap template struct
86
template<>
87
const MPI_Datatype MPITypeMap<int>::mpi_type = MPI_INT;
88
template<>
89
const MPI_Datatype MPITypeMap<double>::mpi_type = MPI_DOUBLE;
90
template<>
91
const MPI_Datatype MPITypeMap<int64_t>::mpi_type = MPI_INT64_T;
92
#endif
93

94
} // namespace mpi
95

96
} // namespace openmc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc