This is an archive of the discontinued LLVM Phabricator instance.

[Libomptarget] Implement the host memory allocator with fine grained memory
ClosedPublic

Authored by jhuber6 on Feb 10 2023, 12:40 PM.

Details

Summary

This patch should enable the "Host" allocation using fine-grained
memory. As far as I understand, this is HSA managed memory that is
availible to the host, but can be accessed by the device as well.
The original patch that introduced these extensions just stipulated that
it's "non-migratable" memory, which is most likely true because it's
managed by the host but accessible by the device. This should work
sufficiently well for what we expect the "host" allocation to do.

Depends on D143771

Diff Detail

Event Timeline

jhuber6 created this revision.Feb 10 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 12:40 PM
jhuber6 requested review of this revision.Feb 10 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 12:40 PM
This revision is now accepted and ready to land.Feb 13 2023, 1:21 AM

I believe coarse/fine grain and accessibility are orthogonal concepts. If the coarse grain pool happens to have the accessibility properties of "target_host", then it'll work. That may be target specific and even order of pool iteration specific.

Much safer would be to identify a memory pool with the properties that the given allocator specifies and return that. Coarse grain means synchronised on kernel boundaries iiuc.

So what is a target_host_mem allocator?

jhuber6 added a subscriber: grokos.Feb 13 2023, 4:57 AM

I believe coarse/fine grain and accessibility are orthogonal concepts. If the coarse grain pool happens to have the accessibility properties of "target_host", then it'll work. That may be target specific and even order of pool iteration specific.

Much safer would be to identify a memory pool with the properties that the given allocator specifies and return that. Coarse grain means synchronised on kernel boundaries iiuc.

So what is a target_host_mem allocator?

Yeah, I think the problem is that target_host_mem_alloc was never fully defined by @grokos. I interpreted it to mean that it's pinned memory that the device can access. I'm pretty sure coarse memory fits the bill there, but I don't know what the exact intention was with the "non-migratable" sentence.

I interpreted it to mean that it's pinned memory that the device can access. I'm pretty sure coarse memory fits the bill there

I don't think that's what coarse grain means.

I interpreted it to mean that it's pinned memory that the device can access. I'm pretty sure coarse memory fits the bill there

I don't think that's what coarse grain means.

I think the CUDA plugin right now just allocates pinned memory. We could do the same here just using new and the hsa_amd_memory_lock. Would be consistent at least.

jhuber6 retitled this revision from [Libomptarget] Implement the host memory allocator with coarse memory to [Libomptarget] Implement the host memory allocator with fine grained memory.Feb 20 2023, 6:42 AM
jhuber6 edited the summary of this revision. (Show Details)
jhuber6 updated this revision to Diff 498834.Feb 20 2023, 6:43 AM

Changing this to just go back to fine-grained. It worked before so it's less controversial.

This revision was landed with ongoing or failed builds.Feb 20 2023, 6:44 AM
This revision was automatically updated to reflect the committed changes.