diff --git a/bfps/cpp/full_code/NSVEcomplex_particles.cpp b/bfps/cpp/full_code/NSVEcomplex_particles.cpp index c7bc9424b27d9b8ce66be5fdf163f61a02daac62..3bd27102d7495b39dfa92bb5b7975b3f64d6cca5 100644 --- a/bfps/cpp/full_code/NSVEcomplex_particles.cpp +++ b/bfps/cpp/full_code/NSVEcomplex_particles.cpp @@ -229,10 +229,9 @@ int NSVEcomplex_particles<rnumber>::do_stats() this->ps->get_step_idx()-1); // deallocate temporary data array - // TODO: is it required/safe to call the release method here? - pdata0.release(); - pdata1.release(); - pdata2.release(); + delete[] pdata0.release(); + delete[] pdata1.release(); + delete[] pdata2.release(); return EXIT_SUCCESS; } diff --git a/bfps/cpp/full_code/NSVEparticles.cpp b/bfps/cpp/full_code/NSVEparticles.cpp index c8918996da0e9726136a0ef4b732f9dfc0bccfec..9b8743cdb48a5f3575931dfcc200fe1f0362778d 100644 --- a/bfps/cpp/full_code/NSVEparticles.cpp +++ b/bfps/cpp/full_code/NSVEparticles.cpp @@ -105,7 +105,7 @@ int NSVEparticles<rnumber>::finalize(void) { TIMEZONE("NSVEparticles::finalize"); delete this->pressure; - this->ps.release(); + delete this->ps.release(); delete this->particles_output_writer_mpi; delete this->particles_sample_writer_mpi; this->NSVE<rnumber>::finalize(); @@ -134,7 +134,7 @@ int NSVEparticles<rnumber>::do_stats() // allocate temporary data array std::unique_ptr<double[]> pdata(new double[3*this->ps->getLocalNbParticles()]); - // copy position data + /// copy position data /// sample position std::copy(this->ps->getParticlesState(), @@ -183,8 +183,7 @@ int NSVEparticles<rnumber>::do_stats() this->ps->get_step_idx()-1); // deallocate temporary data array - // TODO: is it required/safe to call the release method here? - pdata.release(); + delete[] pdata.release(); return EXIT_SUCCESS; } diff --git a/bfps/cpp/full_code/test_interpolation.cpp b/bfps/cpp/full_code/test_interpolation.cpp index 2acd3c27426a4cdd2af244dfaa6b1779b2871f61..c3103fb4cb0c6a5cf29d408142bdd4da943cce10 100644 --- a/bfps/cpp/full_code/test_interpolation.cpp +++ b/bfps/cpp/full_code/test_interpolation.cpp @@ -92,7 +92,7 @@ int test_interpolation<rnumber>::finalize(void) delete this->nabla_u; delete this->velocity; delete this->vorticity; - this->ps.release(); + delete this->ps.release(); delete this->kk; delete particles_output_writer_mpi; delete particles_sample_writer_mpi; @@ -198,7 +198,9 @@ int test_interpolation<rnumber>::do_work() this->ps->getLocalNbParticles(), this->ps->get_step_idx()-1); - // no need to deallocate because we used "unique_ptr" + // deallocate temporary arrays + delete[] p3data.release(); + delete[] p9data.release(); return EXIT_SUCCESS; } diff --git a/bfps/cpp/hdf5_tools.cpp b/bfps/cpp/hdf5_tools.cpp index 25acaf21b662501948616236ee1d441df2527ad3..5a3aef39caa2824f4d08e579d35734a1438ba5ec 100644 --- a/bfps/cpp/hdf5_tools.cpp +++ b/bfps/cpp/hdf5_tools.cpp @@ -213,6 +213,9 @@ std::string hdf5_tools::read_string( hid_t dset = H5Dopen(group, dset_name.c_str(), H5P_DEFAULT); hid_t space = H5Dget_space(dset); hid_t memtype = H5Dget_type(dset); + // fsanitize complains unless I have a static array here + // but that doesn't actually work (data is read incorrectly). + // this is caught by bfps.test_NSVEparticles char *string_data = (char*)malloc(256); H5Dread(dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string_data); std::string std_string_data = std::string(string_data); diff --git a/bfps/cpp/particles/abstract_particles_output.hpp b/bfps/cpp/particles/abstract_particles_output.hpp index 4fc344d3b102c7af2f3669854718861f0de5c8e8..a457689a606fa0f004667dc142c0f44d81e16e93 100644 --- a/bfps/cpp/particles/abstract_particles_output.hpp +++ b/bfps/cpp/particles/abstract_particles_output.hpp @@ -137,15 +137,15 @@ public: } void releaseMemory(){ - buffer_indexes_send.release(); - buffer_particles_positions_send.release(); + delete[] buffer_indexes_send.release(); + delete[] buffer_particles_positions_send.release(); size_buffers_send = 0; - buffer_indexes_recv.release(); - buffer_particles_positions_recv.release(); + delete[] buffer_indexes_recv.release(); + delete[] buffer_particles_positions_recv.release(); size_buffers_recv = 0; for(int idx_rhs = 0 ; idx_rhs < nb_rhs ; ++idx_rhs){ - buffer_particles_rhs_send[idx_rhs].release(); - buffer_particles_rhs_recv[idx_rhs].release(); + delete[] buffer_particles_rhs_send[idx_rhs].release(); + delete[] buffer_particles_rhs_recv[idx_rhs].release(); } buffers_size_particle_rhs_send = 0; buffers_size_particle_rhs_recv = 0; diff --git a/bfps/cpp/particles/p2p_distr_mpi.hpp b/bfps/cpp/particles/p2p_distr_mpi.hpp index 965f8ba8e99856b2e3c2f4c69e0cb63d36d9eb9a..9b8a5b1318bb213484eca81e11d764234a994937 100644 --- a/bfps/cpp/particles/p2p_distr_mpi.hpp +++ b/bfps/cpp/particles/p2p_distr_mpi.hpp @@ -625,7 +625,7 @@ public: AssertMpi(MPI_Isend(descriptor.results.get(), int(NbParticlesToReceive*size_particle_rhs), particles_utils::GetMpiType(real_number()), destProc, TAG_RESULT_PARTICLES, current_com, &mpiRequests.back())); - descriptor.toCompute.release(); + delete[] descriptor.toCompute.release(); } ////////////////////////////////////////////////////////////////////// /// Release memory that was sent back @@ -634,7 +634,7 @@ public: NeighborDescriptor& descriptor = neigDescriptors[releasedAction.second]; assert(descriptor.results != nullptr); assert(descriptor.isRecv); - descriptor.results.release(); + delete[] descriptor.results.release(); } ////////////////////////////////////////////////////////////////////// /// Merge @@ -646,7 +646,7 @@ public: assert(descriptor.toRecvAndMerge != nullptr); in_computer.template reduce_particles_rhs<size_particle_rhs>(&particles_current_rhs[particles_offset_layers[my_nb_cell_levels-descriptor.nbLevelsToExchange]*size_particle_rhs], descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToExchange); - descriptor.toRecvAndMerge.release(); + delete[] descriptor.toRecvAndMerge.release(); } } } diff --git a/bfps/cpp/particles/particles_distr_mpi.hpp b/bfps/cpp/particles/particles_distr_mpi.hpp index cec734e1ed8c3616bb281d375ee6cf6af3c77948..8a2b77ca4d8f4dd7f566868898a4af1fc78e7cb5 100644 --- a/bfps/cpp/particles/particles_distr_mpi.hpp +++ b/bfps/cpp/particles/particles_distr_mpi.hpp @@ -418,7 +418,7 @@ public: if(releasedAction.first == RELEASE_BUFFER_PARTICLES){ NeighborDescriptor& descriptor = neigDescriptors[releasedAction.second]; assert(descriptor.toCompute != nullptr); - descriptor.toCompute.release(); + delete[] descriptor.toCompute.release(); } ////////////////////////////////////////////////////////////////////// /// Merge @@ -430,14 +430,14 @@ public: TIMEZONE("reduce"); assert(descriptor.toRecvAndMerge != nullptr); in_computer.template reduce_particles_rhs<size_particle_rhs>(&particles_current_rhs[0], descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToSend); - descriptor.toRecvAndMerge.release(); + delete[] descriptor.toRecvAndMerge.release(); } else { TIMEZONE("reduce"); assert(descriptor.toRecvAndMerge != nullptr); in_computer.template reduce_particles_rhs<size_particle_rhs>(&particles_current_rhs[(current_offset_particles_for_partition[current_partition_size]-descriptor.nbParticlesToSend)*size_particle_rhs], descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToSend); - descriptor.toRecvAndMerge.release(); + delete[] descriptor.toRecvAndMerge.release(); } } } @@ -475,14 +475,14 @@ public: TIMEZONE("reduce_later"); assert(descriptor.toRecvAndMerge != nullptr); in_computer.template reduce_particles_rhs<size_particle_rhs>(&particles_current_rhs[0], descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToSend); - descriptor.toRecvAndMerge.release(); + delete[] descriptor.toRecvAndMerge.release(); } else { TIMEZONE("reduce_later"); assert(descriptor.toRecvAndMerge != nullptr); in_computer.template reduce_particles_rhs<size_particle_rhs>(&particles_current_rhs[(current_offset_particles_for_partition[current_partition_size]-descriptor.nbParticlesToSend)*size_particle_rhs], descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToSend); - descriptor.toRecvAndMerge.release(); + delete[] descriptor.toRecvAndMerge.release(); } } } diff --git a/bfps/cpp/particles/particles_input_hdf5.hpp b/bfps/cpp/particles/particles_input_hdf5.hpp index e10377bff97812ebee186ee721aeeb32e91d8fec..33406314236ad8a10d97eeef331819ee0d8f6261 100644 --- a/bfps/cpp/particles/particles_input_hdf5.hpp +++ b/bfps/cpp/particles/particles_input_hdf5.hpp @@ -302,13 +302,13 @@ public: my_particles_positions.reset(new real_number[exchanger.getTotalToRecv()*size_particle_positions]); } exchanger.alltoallv<real_number>(split_particles_positions.get(), my_particles_positions.get(), size_particle_positions); - split_particles_positions.release(); + delete[] split_particles_positions.release(); if(nb_particles_for_me){ my_particles_indexes.reset(new partsize_t[exchanger.getTotalToRecv()]); } exchanger.alltoallv<partsize_t>(split_particles_indexes.get(), my_particles_indexes.get()); - split_particles_indexes.release(); + delete[] split_particles_indexes.release(); my_particles_rhs.resize(nb_rhs); for(int idx_rhs = 0 ; idx_rhs < int(nb_rhs) ; ++idx_rhs){