-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPU: Fix data transfers if already on device #131
base: develop
Are you sure you want to change the base?
Conversation
@lukasm91 could you rebase this branch against latest develop? |
f917d3e
to
1449faf
Compare
done |
Co-authored-by: Sam Hatfield <[email protected]>
One thing I don't get about this change: first time we call In other words, don't we always have to do a host->device update for all |
Let me explain in more detail: I can think of using ectrans in two modes of operations.
In the current main branch, ectrans is behaving very weirdly: On the grid-point space it does the copy in any case, in the spectral space it only copies if the data is not present. This PR changes the behaviour for both spaces to "only copy if not present". |
Okay, let me put what you're saying in other terms to see if I understand: Current behaviour
New behaviour
But writing out all that only raises more questions...
|
Let me modify your explanation and correct it (current behaviour is not consistent):
To answer the other questions:
Yes, they are arguments. PGP can be made present by the callee: !$ACC DATA CREATE(PGP, ...)
Same reason. This is not about the first/second/third call, it is about what happens if the data is managed outside of ectrans. Assume the whole code of IFS is ported to GPU, in this case all data always live on the GPU, including PGP, PSPVOR, ... There should be 0 copies, which is why the "current behaviour" is not what we want. |
@samhatfield is @lukasm91 explanation sufficient? Is there anything else blocking, besides conflicts that need to be resolved (rebase please)? |
To the best of my memory, I didn't feel confident we could merge this as what Lukas is proposing (which is reasonable of course!) has implications outside of just ecTrans, and influences our overall strategy for device-side memory handling in the IFS. I need to refresh my memory though - let me take a look again. |
So what Sam understood is that PGP could be present (acc_mapped) on device just because of previous calls to inv_trans or dir_trans. The IFS currently has no notion of any device copy and only works with host data, treating the GPU as an offload-accelerator for ectrans. Notwithstanding there are inconsistencies discovered by @lukasm91 about the treatment of PSPVOR that should be corrected. Probably to the safe side where the copy has to be made always ? |
I could easily rebase this branch if needed, and I can do that if we consider it for merging.
That's fine. If it only works with host data, there is no issue with this implementation. This implementation is only causing issues if you call it with PGP already allocated on GPU, e.g.
If you do that you run into trouble, because if the data exists on the device, this implementation assumes that the "live" copy of the data is on the device. But this is not a very obvious use-case and I believe it is reasonable to assume that a user makes the "device" copy alive if a "device" version of data exists. The current We could revert the behaviour and say: Even if you pass data that exists on the device, ectrans is always assuming it is a host pointer, but that would trigger double copies: The user has to update the host data, in order to call ectrans, which does the device copy.
That won't happen. If the present counter of PGP is 0 when we call ectrans, it is incremented when it is copied in, before the end of ectrans it becomes 0 again, and PGP won't be mapped again. I am happy to explain this in more detail how this works. |
(requested by Judicael Grasset)
If data is already on device, we should not make an extra copy (similar to the openacc semantics: copy means copy if not present)
Should go after #127