Skip to content

Commit

Permalink
Use std::vector in py_gather (rcnt).
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 20, 2024
1 parent 0073f69 commit 1a76680
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/nrnpython/nrnpy_p2h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,24 +734,23 @@ static PyObject* py_gather(PyObject* psrc, int root) {
auto sbuf = pickle(psrc);
// what are the counts from each rank
int scnt = static_cast<int>(sbuf.size());
int* rcnt = NULL;
std::vector<int> rcnt;
if (root == nrnmpi_myid) {
rcnt = new int[np];
rcnt.resize(np);
}
nrnmpi_int_gather(&scnt, rcnt, 1, root);
nrnmpi_int_gather(&scnt, rcnt.data(), 1, root);
std::vector<int> rdispl;
std::vector<char> rbuf;
if (root == nrnmpi_myid) {
rdispl = mk_displ(rcnt);
rdispl = mk_displ(rcnt.data());
rbuf.resize(rdispl[np]);
}

nrnmpi_char_gatherv(sbuf.data(), scnt, rbuf.data(), rcnt, rdispl.data(), root);
nrnmpi_char_gatherv(sbuf.data(), scnt, rbuf.data(), rcnt.data(), rdispl.data(), root);

PyObject* pdest = Py_None;
if (root == nrnmpi_myid) {
pdest = char2pylist(rbuf.data(), np, rcnt, rdispl.data());
delete[] rcnt;
pdest = char2pylist(rbuf.data(), np, rcnt.data(), rdispl.data());
} else {
Py_INCREF(pdest);
}
Expand Down

0 comments on commit 1a76680

Please sign in to comment.