From 86b7560740f2b03262458e0025eb6c5c42d6282e Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 27 Feb 2024 14:13:27 -0700 Subject: [PATCH] Init pointers, etc. --- src/KOKKOS/comm_tiled_kokkos.cpp | 3 +- src/comm_tiled.cpp | 74 ++++++++++++++++++++++---------- src/comm_tiled.h | 3 +- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/KOKKOS/comm_tiled_kokkos.cpp b/src/KOKKOS/comm_tiled_kokkos.cpp index bd65bcf221..60e7f7d9a8 100644 --- a/src/KOKKOS/comm_tiled_kokkos.cpp +++ b/src/KOKKOS/comm_tiled_kokkos.cpp @@ -36,7 +36,6 @@ static constexpr int BUFEXTRA = 1000; CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp) { - sendlist = nullptr; } /* ---------------------------------------------------------------------- */ @@ -48,7 +47,6 @@ CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp) CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp, Comm *oldcomm) : CommTiled(_lmp,oldcomm) { - sendlist = nullptr; } /* ---------------------------------------------------------------------- */ @@ -59,6 +57,7 @@ CommTiledKokkos::~CommTiledKokkos() sendlist = nullptr; buf_send = nullptr; buf_recv = nullptr; + maxswap = 0; } /* ---------------------------------------------------------------------- */ diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index 0c12fc268b..59ab993655 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -47,14 +47,9 @@ CommTiled::CommTiled(LAMMPS *lmp) : Comm(lmp) { style = Comm::TILED; layout = Comm::LAYOUT_UNIFORM; - pbc_flag = nullptr; - buf_send = nullptr; - buf_recv = nullptr; - overlap = nullptr; - rcbinfo = nullptr; - cutghostmulti = nullptr; - cutghostmultiold = nullptr; - init_buffers_flag = 1; + init_pointers(); + init_buffers_flag = 0; + maxswap = 0; } /* ---------------------------------------------------------------------- */ @@ -69,7 +64,9 @@ CommTiled::CommTiled(LAMMPS * /*lmp*/, Comm *oldcomm) : Comm(*oldcomm) style = Comm::TILED; layout = oldcomm->layout; Comm::copy_arrays(oldcomm); - init_buffers_flag = 1; + init_pointers(); + init_buffers_flag = 0; + maxswap = 0; } /* ---------------------------------------------------------------------- */ @@ -85,24 +82,59 @@ CommTiled::~CommTiled() memory->destroy(cutghostmultiold); } +/* ---------------------------------------------------------------------- + initialize comm pointers to nullptr +------------------------------------------------------------------------- */ + +void CommTiled::init_pointers() +{ + buf_send = buf_recv = nullptr; + overlap = nullptr; + rcbinfo = nullptr; + cutghostmulti = nullptr; + cutghostmultiold = nullptr; + + nsendproc = nullptr; + nrecvproc = nullptr; + sendother = nullptr; + recvother = nullptr; + sendself = nullptr; + sendproc = nullptr; + recvproc = nullptr; + sendnum = nullptr; + recvnum = nullptr; + size_forward_recv = nullptr; + firstrecv = nullptr; + size_reverse_send = nullptr; + size_reverse_recv = nullptr; + forward_recv_offset = nullptr; + reverse_recv_offset = nullptr; + pbc_flag = nullptr; + pbc = nullptr; + sendbox = nullptr; + sendbox_multi = nullptr; + sendbox_multiold = nullptr; + maxsendlist = nullptr; + sendlist = nullptr; + requests = nullptr; + nprocmax = nullptr; + nexchproc = nullptr; + nexchprocmax = nullptr; + exchproc = nullptr; + exchnum = nullptr; +} + /* ---------------------------------------------------------------------- initialize comm buffers and other data structs local to CommTiled ------------------------------------------------------------------------- */ void CommTiled::init_buffers() { - buf_send = buf_recv = nullptr; maxsend = maxrecv = BUFMIN; grow_send(maxsend,2); grow_recv(maxrecv,1); maxoverlap = 0; - overlap = nullptr; - rcbinfo = nullptr; - cutghostmulti = nullptr; - cutghostmultiold = nullptr; - sendbox_multi = nullptr; - sendbox_multiold = nullptr; // Note this may skip growing multi arrays, will call again in init() maxswap = 6; @@ -113,9 +145,9 @@ void CommTiled::init_buffers() void CommTiled::init() { - if (init_buffers_flag) { + if (!init_buffers_flag) { init_buffers(); - init_buffers_flag = 0; + init_buffers_flag = 1; } Comm::init(); @@ -2436,10 +2468,8 @@ void CommTiled::deallocate_swap(int n) delete [] maxsendlist[i]; - if (sendlist && sendlist[i]) { - for (int j = 0; j < nprocmax[i]; j++) memory->destroy(sendlist[i][j]); - delete [] sendlist[i]; - } + for (int j = 0; j < nprocmax[i]; j++) memory->destroy(sendlist[i][j]); + delete [] sendlist[i]; } delete [] sendproc; diff --git a/src/comm_tiled.h b/src/comm_tiled.h index 095e7bf5aa..857cddf033 100644 --- a/src/comm_tiled.h +++ b/src/comm_tiled.h @@ -117,8 +117,9 @@ class CommTiled : public Comm { double *sublo, *subhi; int dimension; - int init_buffers_flag; + void init_pointers(); void init_buffers(); + int init_buffers_flag; // box drop and other functions