Skip to content

Commit

Permalink
Use std::vector in py_gather (rbuf).
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 20, 2024
1 parent a654d36 commit 0073f69
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/nrnpython/nrnpy_p2h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,18 +740,17 @@ static PyObject* py_gather(PyObject* psrc, int root) {
}
nrnmpi_int_gather(&scnt, rcnt, 1, root);
std::vector<int> rdispl;
char* rbuf = NULL;
std::vector<char> rbuf;
if (root == nrnmpi_myid) {
rdispl = mk_displ(rcnt);
rbuf = new char[rdispl[np]];
rbuf.resize(rdispl[np]);
}

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

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

0 comments on commit 0073f69

Please sign in to comment.