Khronos Public Bugzilla
Bug 397 - const/__constant for samplers at program scope
const/__constant for samplers at program scope
Status: NEW
Product: OpenCL
Classification: Unclassified
Component: Specification
1.1
All All
: P3 normal
: ---
Assigned To: Aaftab Munshi
OpenCL Working Group
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-12-27 09:43 PST by David Garcia
Modified: 2011-03-31 08:12 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Garcia 2010-12-27 09:43:22 PST
(David Garcia from Qualcomm here)

User ljbade in the public forum has pointed out an inconsistency in the spec. See http://www.khronos.org/message_boards/viewtopic.php?f=28&t=3371

Page 184 of the OpenCL 1.1. spec says that:

<<There is no generic address space name for program scope variables. All program scope variables must be declared in the __constant address space.
>>

However, page 236 contradicts it with an example:

<<Samplers can also be declared as global constants in the program source using the following  syntax.
const sampler_t <sampler name> = <value>
>>

Should the example declare the sampler in __constant space instead?

According to the experiments done by user ljbade, NVidia's implementation accepts both "const" and "__constant" sampler declarations, whereas AMD's implementation only accepts "__constant".

This problem also exists in the OpenCL 1.0 spec.
Comment 1 Anton Lokhmotov 2010-12-29 06:20:31 PST
A very similar bug exists in the internal system.
Comment 2 Anton Lokhmotov 2010-12-31 05:13:24 PST
Actually, multiple bugs.
Comment 3 Aaftab Munshi 2011-01-07 16:26:05 PST
The reason samplers declared as program scope variables do not use the __constant qualifier but use the const qualifier is because in section 6.5.3 we have "The __constant or constant address space name is used to describe variables allocated in global memory and which are accessed inside a kernel(s) as read-only variables...."

Samplers are not variables allocated in global memory.  This is why the program scope example that describes sampler uses const instead of __constant.  

IMO the const usage is the correct way to describe sampler as a program scope variable.  We should add a clarification to make this explicitly clear.
Comment 4 David Garcia 2011-03-31 08:12:05 PDT
Affie, do you think it's appropriate to update this external bug now that we reached a resolution on #6747 in the internal bugzilla?