This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OpenCL compiler complains about an address space qualifier in kernel function array arguments

The new OpenCL compiler for the EVMK2H platform complains about the "global" address space qualifier in a kernel function array parameter (see program below).  Even though the OpenCL 1.1 standard is less specific about this (but does not disallow it), the OpenCL 1.2 standard explicitely allows the "global" address space qualifier in kernel function array arguments (Sec. 6.5).  Could you please fix this (even though one could argue if this is a bug in OpenCL 1.1)?

Thanks,  John Romein

#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
#include <iostream>
#include <string>
#include <vector>


const char *kernelSource = "kernel void foo(global int arg[1]) { }"; // compiler complains about the "global" address space qualifier


int main()
{
  try
  {
    cl::Context             context(CL_DEVICE_TYPE_ACCELERATOR);
    std::vector<cl::Device> devices(context.getInfo<CL_CONTEXT_DEVICES>());
    cl::Program::Sources    source(1, std::make_pair(kernelSource, strlen(kernelSource)));
    cl::Program             program(context, source);
    program.build(devices);
  } catch (cl::Error &err) {
    std::cerr <<"cl::Error(): " << err.what() << '(' << err.err() << ')' << std::endl;
  }

  return 0;
}

  • Moved this thread to High Performace Computing forum.

    Thanks.

  • Hi John,

        We rely on clang for OpenCL C parsing and currently we are using clang 3.3.  The error you see is reported from clang even though we have set OpenCL C language specification to 1.2.  We will see if global address space qualifier is supported on array parameter when we upgrade to use newer clang.

        In the meantime, you can use a workaround by changing your array parameter to a pointer:

    const char *kernelSource = "kernel void foo(global int *arg) { }";


    - Yuan