-
Christopher Woods authored
WIP - looking for a way to optimise performance of creating contexts by removing temporary arrays (and their associated mallocs/frees) (#4261) * Suggesting a "haveSameParameters" function for CustomNonbondedForce which could be used to avoid creating temporary copies of arrays when testing if particles are the same. Also updating "getParticleParameters" so that it re-uses the memory of the passed vector argument, rather than deallocating and reallocating it via a copy. * Revert "Suggesting a "haveSameParameters" function for CustomNonbondedForce which could be" This reverts commit e80ec2d2e9981abb90711636bf3a78d0c49e43fc. * Moved to `thread_local static` as suggested to prevent new vector allocations on each function call. Updated `getParameters` and `getBondParameters` to re-use the memory from the argument rather than re-allocating via the copy. * Forgot to reuse the memory for the groups... * Reverted back the manual copies via memcpy as they aren't needed. Looking at the header file and benchmarking shows that std::vector does the right thing. * Confined `thread_local static` only to ForceInfo methods, and have also put declarations for multiple variables back onto a single line * Removed `thread_local static` from the constructor * Moved constructor declarations back into the for loop
03ed8ff2