Skip to content
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

device memory allocations required to have mappings/be dereferenceable? #13

Open
airlied opened this issue May 5, 2020 · 2 comments
Open

Comments

@airlied
Copy link

airlied commented May 5, 2020

Looking at the device memory allocation API,

__ze_api_export ze_result_t __zecall
zeDriverAllocDeviceMem(
ze_driver_handle_t hDriver, ///< [in] handle of the driver instance
const ze_device_mem_alloc_desc_t* device_desc, ///< [in] pointer to device mem alloc descriptor
size_t size, ///< [in] size in bytes to allocate
size_t alignment, ///< [in] minimum alignment in bytes for the allocation
ze_device_handle_t hDevice, ///< [in] handle of the device
void** pptr ///< [out] pointer to device allocation
);

It looks like it always passes back a (void *). Is this expected to be a mapped pointer accessible from the CPU?

There are GPUs out there (maybe not yet from Intel) that have limited access to the VRAM from the CPU, by forcing that *pptr is a mapped address for all allocation this will limit the amount of mapped accessible objects you can have.

This why Vulkan has VkDeviceMemory objects, and Map/Unmap APIs.

@airlied
Copy link
Author

airlied commented May 6, 2020

Okay it says device allocated ptrs should not be accessed by the host. The spec should state clearly what happens if someone tries, undefined behaviour resulting in program termination?

@bashbaug
Copy link

bashbaug commented May 8, 2020

Hi @airlied!

Thanks for the question. You're right that for device memory allocations, the pointer must be in the same virtual address space as the host application, but it does NOT need to be host-accessible so there is no requirement that the allocation be "mapped". This is different than host or shared allocations, where the pointer does need to be host-accessible.

This is documented in the programming guide, in the text and the summary table. Additionally, the API description says: "In general, a device allocation may only be accessed by the device that owns it."

I guess "may not" could be strengthened to "must" in these places? Would that be clearer, or are there other clarifications you would suggest?

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

No branches or pull requests

2 participants