[PATCH 3/3] Try to perform OpenCL type initialization in C++

Adam Strzelecki ono at java.pl
Tue May 20 06:04:49 PDT 2014


> Just a note: SYCL doesn't require OpenCL++ - it parses plain ol' C++ code and generates IR/binaries (SPIR or otherwise) to offload the workloads where possible.

Well yes and no. There is an OpenCL standard and OpenCL language mode (extensions) in Clang itself.

To generate SPIR compatible kernel you need OpenCL metadata in IR as defined in SPIR standard, i.e.:

>> !opencl.kernels = !{!0}
>> !llvm.ident = !{!1}
>> !0 = metadata !{void (%struct.Point addrspace(1)*, float addrspace(1)*)* @_Z11test_kernelPKU3AS15PointPU3AS1f}

Fortunately Clang running in OpenCL mode (which is C99 mode too) it does generate such header. So first step enables such behavior in C++ too, using `-x cl++`. If you do SYCL same thing is needed.


2nd it isn't really plain ol' C++ but rather C++11 mixed with some OpenCL flavor:

>> 5.5 Keywords
>> 
>> The only OpenCL C keywords reserved in SYCL are: __global, __local, __constant and __private. The OpenCL C kernel keyword is not available as kernels are defined by functors or lambdas. The OpenCL C datatypes are not keywords in SYCL, but instead defined within namespaces. The access qualifiers __read_- only, __write_only and __read_write from OpenCL C are not available in SYCL, but are implemented using accessors instead.

My intention wasn't really to get SYCL up and running, but rather to be able to generate proper SPIR kernel out of C++11 code base, which we have a lot here @ our university. I still want to run this using regular OpenCL API calls out of SPIR, but take advantage of implicit vectorization done by OpenCL drivers.


> My company (Codeplay) has an implementation of the provisional SYCL specification that does use some patches on tip Clang, but these do not modify any code in Clang that parses C++.

Do you mind sharing that, if this is open implementation?

Please note that '[PATCH 2/3] Implicit address space conversion on POD assign' which is only patch modifying C++ semantics regarding address space conversion during initialization. This is generic problem that is somehow related with my work, but anyway has to be sorted out regardless of OpenCL++ or SYCL.


Regards,
-- 
Adam



More information about the cfe-commits mailing list