[cfe-dev] intptr_t type in OpenCL programs

Dorrington, Albert albert.dorrington at lmco.com
Wed Mar 5 05:16:07 PST 2014


Hi Sameer,

I was not aware of the Khronos SPIR Tools, thanks for the reference I will have to read up on it.

After my post to the mailing list I did find the typedef for Clang within the file:  ./tools/clang/lib/Headers/stdint.h
Which, on my system, appears to be installed here: /usr/local/lib/clang/3.4/include/stdint.h

I have been building openCL kernels to IR using clang with the following command line:

clang -O0 -emit-llvm -include /usr/local/include/clc/clc.h -I /usr/local/include -Dcl_clang_storage_class_specifiers -target r600 -mcpu=turks -c mykernel.cl -o mykernel.bc

I was expecting that the typedefs would have been part of /usr/local/include/clc/clc.h, but it does not appear to be.
If I try to add a -include for /usr/local/include/CL/cl.h, but that winds up trying to include system include files for the x86_64 platform, rather than the r600 target, and I end up with a bunch more errors.

My current assumption is that that libclc's clctypes.h should either define these types, or include a header file such as the opencl_spir.h file.

-Al


From: Sahasrabuddhe, Sameer [mailto:Sameer.Sahasrabuddhe at amd.com]
Sent: Wednesday, March 05, 2014 1:47 AM
To: Dorrington, Albert; cfe-dev at cs.uiuc.edu
Subject: EXTERNAL: RE: intptr_t type in OpenCL programs

Hi Albert,

The "intptr_t" type does not need special handling in Clang, since it can be created using other types. For example, the Khronos version of Clang uses the following definition in an implicit header:


                   typedef ptrdiff_t intptr_t;

where ptrdiff_t itself is typedef'd to something else:

https://github.com/KhronosGroup/SPIR-Tools/blob/master/headers/opencl_spir.h#L83

The general idea is to put such declarations in a separate header, and use the "-include" argument for Clang to include this header at the beginning of the OpenCL file being compiled.

Also, have you checked out the Khronos SPIR generator, which is based on Clang? It is maintained in a separate github repository, but most of the changes there are being merged into upstream Clang. This frontend can be combined with the SPIR-Tools header mentioned above to get almost complete support for OpenCL 1.2

https://github.com/KhronosGroup/SPIR/tree/spir_12

Sameer.

From: cfe-dev-bounces at cs.uiuc.edu<mailto:cfe-dev-bounces at cs.uiuc.edu> [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Dorrington, Albert
Sent: Friday, February 28, 2014 1:05 AM
To: cfe-dev at cs.uiuc.edu<mailto:cfe-dev at cs.uiuc.edu>
Subject: [cfe-dev] intptr_t type in OpenCL programs

When trying to compile a kernel that uses the 'intptr_t' type, I am getting an error for 'use of undeclared identifier'

Is the intptr_t implemented in Clang for OpenCL?
Where would I look in the code to find out?

Thanks!

Al Dorrington
Software Engineer Sr
Lockheed Martin, Mission Systems and Training

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140305/11edd9a5/attachment.html>


More information about the cfe-dev mailing list