Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

In demo code, demonstrate zero-copy memory alignment #41

Open
shusheer opened this issue Dec 27, 2022 · 0 comments
Open

In demo code, demonstrate zero-copy memory alignment #41

shusheer opened this issue Dec 27, 2022 · 0 comments

Comments

@shusheer
Copy link

shusheer commented Dec 27, 2022

For many GPUs (IoT devices using unified memory models, Intel iGPUs, and GPUs with pinned memory), zero-copy buffers are really useful. You use malloc() in the examples currently, which only aligns to 8-byte boundaries typically. Intel requires 4096-byte boundaries, ARM usually requires 64-bytes, etc. Unfortunately Windows uses different alignment methods than Linux, but this stackoverflow question gives a nice example of how to #ifdef wrap a mimic of posix_memalign : https://stackoverflow.com/a/33696858 and https://stackoverflow.com/a/38291021

To make life easy for people you could create a function that extracts CL_DEVICE_MEM_BASE_ADDR_ALIGN and uses this to correctly align buffers (and have a corresponding free call, to abstract windows/linux differences).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant