Skip to content

Commit

Permalink
Use std::vector in py_allgather (rcnt).
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 20, 2024
1 parent 58d53d3 commit a654d36
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/nrnpython/nrnpy_p2h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,15 @@ static PyObject* py_allgather(PyObject* psrc) {
int np = nrnmpi_numprocs;
auto sbuf = pickle(psrc);
// what are the counts from each rank
int* rcnt = new int[np];
std::vector<int> rcnt(np);
rcnt[nrnmpi_myid] = static_cast<int>(sbuf.size());
nrnmpi_int_allgather_inplace(rcnt, 1);
auto rdispl = mk_displ(rcnt);
nrnmpi_int_allgather_inplace(rcnt.data(), 1);
auto rdispl = mk_displ(rcnt.data());
std::vector<char> rbuf(rdispl[np]);

nrnmpi_char_allgatherv(sbuf.data(), rbuf.data(), rcnt, rdispl.data());
nrnmpi_char_allgatherv(sbuf.data(), rbuf.data(), rcnt.data(), rdispl.data());

PyObject* pdest = char2pylist(rbuf.data(), np, rcnt, rdispl.data());
delete[] rcnt;
PyObject* pdest = char2pylist(rbuf.data(), np, rcnt.data(), rdispl.data());
return pdest;
}

Expand Down

0 comments on commit a654d36

Please sign in to comment.