Skip to content

Conversation

@ZedThree
Copy link
Member

Copying Field3Ds should be cheap, so copy any parallel slices from the rhs

This modifies the implementation from #1803 by just copying the parallel slice vectors themselves, rather than copying the fields in them. This removes the need to keep track of a separate bool for whether or not to copy the parallel slices of parallel slices.

I think the bool was originally there to avoid an infinite recursion when creating parallel slices using the identity transform, which just copies the field into its own slices, relying on copy-on-write to make this cheap. This implementation makes an initial copy and ensures that that doesn't have parallel slices, and uses that copy to fill in the original's parallel slices. This should all be cheap thanks to copy-on-write.

Also adds a move assignment operator to Field3D to make this even cheaper by moving the parallel slice vectors.

@ZedThree ZedThree added this to the BOUT-5.0 milestone Mar 11, 2020
@d7919
Copy link
Member

d7919 commented Mar 11, 2020

Is there any data on the performance impact (if any) on the cost of a copy?

@ZedThree
Copy link
Member Author

I compared elm-pb on 8 cores, and the difference between this and next was about 10%, in favour of this branch, but the jitter was ~20%.

@ZedThree ZedThree mentioned this pull request Mar 11, 2020
@ZedThree ZedThree merged commit 2ee9c06 into next Mar 12, 2020
@ZedThree ZedThree deleted the field3d-copy-parallel-slices branch March 12, 2020 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants