cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

williamthec
Journeyman III

Could OpenCL support C++? (Self-defined classes & overloading)

At the beginning of this month I bought a HD5870 to take the place of my old GTX260 because I thought OpenCL is gonna be more widely used than CUDA, as it's a open architecture, and I love AMD's cards also. But then I found that there seemed no way for me to program in C++ form, i.e. the one with classes and operator overloading which can greatly improve programming efficiency.

Now I have some codes in C++ form, and I want to optimize them with GPU parallel computing.

Have I missed something or could OpenCL support C++ language? Actually the CUDA 3.0 gives supports to C++ programming, I don't want having made a wrong decision.

0 Likes
7 Replies
nou
Exemplar

OpenCl kernels use pure C99 with some limitations. there is only binding to C++ on host code side. http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.1.pdf

maybe in future there will be support for some C++ features. i seen roadmap with C++ templates mentioned. but it was abanoned or postponed as it was planed to SDK 2.3.

0 Likes

Originally posted by: nou OpenCl kernels use pure C99 with some limitations. there is only binding to C++ on host code side. http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.1.pdf

 

maybe in future there will be support for some C++ features. i seen roadmap with C++ templates mentioned. but it was abanoned or postponed as it was planed to SDK 2.3.

 

Thanks for your reply~ I feel a little bit sorry for that... 

0 Likes
Meteorhead
Challenger

OpenCL only supports C99 and no C++ yet. This is the Khronos standard. Unfortunately until this changes, most likely no widespread C++ support will be added to kernel language.

What gives hope in this matter is that developers are really trying to force C++ into OpenCL, thus it is not impossible that future standards (1.1+) will support C++ inside kernels. People have suggested (me included) that in the meantime, vendorspecific extensions could enable c++ support inside kernels, allowing both us developers and compiler developers to worl ahead of time and start testing a robust, capable c++ compiler for AMD HW.

To answer your question shortly: c++ is not supported in any way by OpenCL, but there is hope to see it in around a year's time I guess.

0 Likes

Originally posted by: Meteorhead OpenCL only supports C99 and no C++ yet. This is the Khronos standard. Unfortunately until this changes, most likely no widespread C++ support will be added to kernel language.

 

What gives hope in this matter is that developers are really trying to force C++ into OpenCL, thus it is not impossible that future standards (1.1+) will support C++ inside kernels. People have suggested (me included) that in the meantime, vendorspecific extensions could enable c++ support inside kernels, allowing both us developers and compiler developers to worl ahead of time and start testing a robust, capable c++ compiler for AMD HW.

 

To answer your question shortly: c++ is not supported in any way by OpenCL, but there is hope to see it in around a year's time I guess.

 

Thank you, Meteorhead~

But does that mean the current hardware architecture(include my 5870) have no support for C++ inside kernels at all, 'cause I noticed that it was not until the later Fermi architecture came out that CUDA could support C++.

0 Likes

Classes and templates are compiler only issues. That's simply a software issue that can be fixed when feasible.

Virtual functions aren't currently supported. They're a pretty poor idea on a vector architecture like Cypress or Fermi anyway, but it is true that Fermi does support them in principle. There are some other aspects that aren't supported in hardware.

0 Likes

well you can write objective in C too. just create struct which contain objects variables. and then you write set of object method where first argument will be "this" pointer on struct.

0 Likes

OK, I'll try later, and wait for the next version of OpenCL~

0 Likes