Why AMD GCN uses non-zero NULL?

烂漫一生 提交于 2019-12-12 03:42:45

问题


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 address space take value -1.

How do they use those two different values of NULL?


回答1:


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.



来源:https://stackoverflow.com/questions/41102947/why-amd-gcn-uses-non-zero-null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!