SpatialField Operator= Right Hand GPU Synchronization
There is likely a bug in the operator= of SpatialField whenever the right hand side of the operator= is a SpatialField that lives on the GPU.
Currently, we copy a field on the right hand side on the GPU via a CUDA memcpy call with the left hand side's stream passed into it. This does not consider the right hand side's stream and therefore likely does not wait for operations to finish on the right hand side before starting the copy into the left hand side.
To fix this, the right hand side's stream should be used during the memcpy instead of the left hand's stream. If the left hand side is also on the GPU, then an additional step is needed to synchronize both the left hand and right hand streams. An example of how synchronizing multiple streams may be done can be found in spatialops/NeboLhs.h:gpu_assign().
Steps:
-
Create test that verifies issue exists -
Synchronize GPU -> CPU operator= -
Synchronize GPU -> GPU operator= -
Verify issue no longer exists