Why AMD GCN uses non-zero NULL?

前端 未结 1 472
闹比i
闹比i 2021-01-28 02:17

This commit says:

In amdgcn target, null pointers in global, constant, and generic address space take value 0 but null pointers in private and local addre

1条回答
  •  失恋的感觉
    2021-01-28 03:08

    As to why: I don't know this for a fact, but local/private address space pointers are almost certainly just implemented as offsets/indices in a flat physical register file/memory area. There's no virtual memory-like address remapping, just a big array. You still want to be able to access array index 0, so "invalid pointer" (invalid index) needs to be something else.

    Don't forget, NULL = non-dereferenceable pointer = 0 is just a convention in regular C, too - some non-OpenCL systems also have valid memory at address 0. There's some complication in the standard regarding memset and so on, so you're probably best off reading the document yourself if you're interested in the exact specification.

    I'm not sure what exactly you're asking regarding "how" - you can't sensibly convert between pointers in different OpenCL address spaces, so there's no conflict there.

    0 讨论(0)
提交回复
热议问题