KhronosGroup / KhronosGroup/OpenCL-Docs

Clarification needed for structs with generic pointers as kernel arguments.

Open
#10 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
421
Forks
132
Avg merge
5d 13h
Merged PRs (30d)
11

Description

Starting with OpenCL 2.0 one can declare generic pointers by leaving out the address space annotation. The current specification disallows having generic pointers or arrays declared as kernel arguments.

the OpenCL C specification states (6.5 in 2.0, 1.5 in 2.2):
"kernel function arguments declared to be a pointer or an array of a type must point to one of the named address spaces __global, __local or __constant."

But having a struct with generic pointers are perfectly valid for kernel parameters:

struct NumberList {
        struct NumberList *next;
        unsigned int val;
};

__kernel void test(__global struct NumberList *list)
{
        struct NumberList temp;
        temp.next = 0;
        temp.val = 50;
        list->next = &temp;
}

This can come up for example if a kernel uses the fine grained system SVM features of OpenCL and wishes to share linked list between the host and the kernel.

In practice the pointer can only have a value stored to the global address space, but maybe it should be forbidden in the first place. Anyway, I think the specification should clear up this situation and have it well defined.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing OpenCL C specification section 6.5 in version 2.0 and section 1.5 in version 2.2, then compare the quoted kernel-argument rule with the provided struct example. Done means the specification explicitly defines whether generic pointers inside structs used as kernel arguments are permitted or forbidden.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.