ORNL / ReSolve

Library of GPU-resident linear solvers
Other
58 stars 2 forks source link

When only host is updated, the device is out of date (and vice versa) #126

Closed pelesh closed 1 month ago

pelesh commented 11 months ago

In update methods in vector and matrix classes it is probably safer to set both update flags at the same time - i.e if cpu data gets updated, gpu data automatically should switch to NOT updated.

_Originally posted by @kswirydo in https://github.com/ORNL/ReSolve/pull/124#discussion_r1429345023_

pelesh commented 9 months ago

After looking at possible use cases, I think it is better if update methods set flags only for memory spaces they updated. A user may run updates for for host and device in separate calls and bring them both to same up-to-date values. In this case "automatic" assumption that the other memory space is out of date would be untrue.

What I suggest is that

A possible action here would be to allow setNotUpdated function to set specific memory space as not current. Other functionality is already available in ReSolve.

@maksud, please chime in, as well.

pelesh commented 1 month ago

The alternative to my earlier proposal could be to do exactly as @kswirydo suggested -- once device memory is updated alone, the host memory is automatically flagged as out of date. In that case, it would be user's responsibility to sync host and data using syncData methods in vector and matrix classes when needed. The syncData method would need to check the destination is out of date and the source is updated, and send warning/error message otherwise.