KhronosGroup / KhronosGroup/OpenCL-Docs

Address Equivalence and the Generic Address Space

Open
#124 1 comment 0 reactions 0 assignees View on GitHub
OpenCL C Spec
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

I am creating this issues as a result of discussion on #114:

> I'm not so sure that it is true that, or we need to state that, a generic pointer to a global object has to be bitwise identical to a global pointer pointing at the same object. Which "SVM address equivalence" do you mean?

Hi @b-sumner, here is an example to motivate why I think we may want this to be the case. It walks a linked list constructed on the host from SVM allocations on the device.

This initial version does not use the generic address space. Do we agree that this is a valid OpenCL 2.0 SVM kernel?

```c
struct Node {
global struct Node* pNext; // pointer to global address space
uint Num;
};
kernel void WalkLinkedList( global struct Node* pHead )
{
global struct Node* pNode = pHead;
while( pNode ) {
pNode->Num = pNode->Num * 2 + 1;
pNode = pNode->pNext;
}
}
```

If so, here is a variant that uses the generic address space instead:

```c
struct Node {
struct Node* pNext; // pointer to generic address space
uint Num;
};
kernel void WalkLinkedList( global struct Node* pHead )
{
// implicit conversion from pointer to global to pointer to generic address space:
struct Node* pNode = pHead;
while( pNode ) {
pNode->Num = pNode->Num * 2 + 1;
pNode = pNode->pNext;
}
}
```

If we want this to be valid as well we will need bitwise equivalence between pointers to the global address space and pointers to the generic address space, since there is no implicit or explicit conversion from a pointer to the global address space to a pointer to the generic address space while walking the linked list.

Contributor guide

Open the contributing guide

Research direction

Start with the discussion in #114 and compare the two OpenCL C linked-list kernels shown here, focusing on generic and global address-space equivalence. Determine whether both kernels should be valid and what pointer-equivalence requirement the specification must state. Done means the design question has a clear resolution and the relevant specification text is updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.