cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

dragonxi4amd
Journeyman III

OpenCL project without any OOP language

Using C-language with C99 instead of C++ and C99 for OpenCL

Hi All,

(1) Is it possible to develop C99 OpenCL apps using just C language and

C99 language instead of C++ and C99 ?

(2) If yes, which C-language and for which OS ?

(3) Has anyone tried C & C99 combination ?

For those who wander why not to use C++:

A)  C++ is not needed in this project

B)  C-language offers all the features needed with C99

C) Although OpenCL API documentation refers to objects, please not that API is about FUNCTIONS - there no classes to create objects as in OOP! 

D)  C++ introduces extra delay compared to C-language

* this is our client's requirement based on their own experiences, not to be argued and it's true that OOP has its price to be paid i.e. lost speed

E) response times already are challenge with OpenCl

F) OpenCL specs V1.2 has some new features which (if rightly implemented) will improve speed

- however one may have to wait v1.2 implementation not to be available before summer 2012 !?

Thanks in advance!

Ronnie

ps. this topic is relevant and not to be "merged" (nor deleted, please!)

 

 

 

 

thanks in advance

Ronnie

 

Tags (1)
0 Likes
20 Replies
himanshu_gautam
Grandmaster

OpenCL project without any OOP language

Ronnie,

Well I think on a basic level OpenCL Programming needs a OpenCl Kernel(which has to be in OpenCL C language, which is nothing more that c99 with some extensions) and Host Program(which is totally language independent. Wrappers for almost all popular languages are now available.And ofcourse C is definitely the fastest of the choices available).

It would be nice if you specify what particular feature you are looking for from 1.2 spec. It might be shifted to higher priority 🙂

0 Likes
nou
Exemplar

OpenCL project without any OOP language

- OpenCL API is in C and there is only thin C++ wrapper on top of this API.

- you can write in style OOP even with pure C or even in ASM. C++ is just syntactic sugar for OOP.

0 Likes
Meteorhead
Challenger

OpenCL project without any OOP language

IMHO this overhead of C++ we're talking about is minimal, somewhere on the border of being able to see at all. Efficient OpenCL applications do not call API functions on every corner, and even if they do, the speed of these functions will 99.99% depend on the API call itself (which is precompiled library that the programmer has no control over), and not on the language it was called from, or even a wrapper around it. Even if a wrapper does error checking on every corner, does some profiling, it should not hurt performance. (Taking 2-3 if()s, and the likes is not painful for a CPU, and API calls shouldn't happen more than 100-200 times per second at the very most).

0 Likes
dragonxi4amd
Journeyman III

OpenCL project without any OOP language

Hi Himanshu,

That would be VERY nice surprise !

Following are the features our clients are looking for from 1.2 spec:

1) clCreateProgramWithBuiltInKernels

2) clCompileProgram

3) clLinkProgram

4) clCreateSubDevices

Thanks in advance !
Ronnie

0 Likes
thesmileman
Journeyman III

OpenCL project without any OOP language

Originally posted by: dragonxi4amd Hi All,

(1) Is it possible to develop C99 OpenCL apps using just C language and

C99 language instead of C++ and C99 ?

(2) If yes, which C-language and for which OS ?

(3) Has anyone tried C & C99 combination ?

For those who wander why not to use C++:

A)  C++ is not needed in this project

B)  C-language offers all the features needed with C99

C) Although OpenCL API documentation refers to objects, please not that API is about FUNCTIONS - there no classes to create objects as in OOP! 

D)  C++ introduces extra delay compared to C-language

* this is our client's requirement based on their own experiences, not to be argued and it's true that OOP has its price to be paid i.e. lost speed

E) response times already are challenge with OpenCl

F) OpenCL specs V1.2 has some new features which (if rightly implemented) will improve speed

- however one may have to wait v1.2 implementation not to be available before summer 2012 !?

Thanks in advance!

Ronnie

ps. this topic is relevant and not to be "merged" (nor deleted, please!) 

Your entire post seems to indicate you haven't read the spec or you don't have a clear understand of basic code. You mentioned the C++ API doesn't have classes and seem to indicate it is just a static class wrapper which simply calls functions which isn't the case. It even has container support so I really don't understand what you are talking about.

Question 1 and 3 are demenstrated in the spec and almost any other tutorial on the web. For you to actually know statement "E" you would have to have used OpenCL which clearly if you can't answer 1 or 3 you haven't done (Or if you have you are completely missing the obvious). For statement C you obviously haven't looked at the wrapper (or ANY tutorial dealing with the wrapper).

The only reason for your post seems to have us do research to answer your questions for you went litterall 1 hr of research coudl have provided you witht the answers. Now I am wasting my time so I am going to stop.

0 Likes
LeeHowes
Staff
Staff

OpenCL project without any OOP language

I don't really understand, and I've been working on the C++ bindings recently (there is a new version downloadable from khronos if anyone's interested - minimal hello world program is now down to about 10 lines). There is little to no performance degredation from C++, and the way the bindings are designed they should almost entirely optimise away. There are many cases, largely thanks to templates and functors instead of function pointers, where C++ is just faster than C.

Having said that, obviously there are still developers who do not want to use C++ for various reasons. The OpenCL API is not a C++ API - that is a conscious design decision. You can hence use OpenCL perfectly well without a C++ compiler.

Given that, I just don't see what the problem is... are you just asking if anyone has tested this fact? I'm sure the embedded people have. I haven't used a compiler in strict C mode but there's no obvious reason why it shouldn't work. I wouldn't do it. The C++ bindings are better in every way unless there is a good reason to stick to pure C.

Lee

0 Likes
player999
Journeyman III

OpenCL project without any OOP language

I use pure C under GNU/Linux. Seems everything works fine. But there is enormous size of code. For instance, I've 800 lines of CL initialization code in my pattern recognition program. I used to program CUDA and it's C implementation much more compact.

0 Likes
dragonxi4amd
Journeyman III

OpenCL project without any OOP language

Thanks to all of those who have given constructive feedback !

Our developers agree, the OpenCL C programming language (C99) is/will suitable for certain applications and platforms -
we use it at the moment for certain projects!

However, for example rapidly deployable autonomous and unmanned systems and devices for network-centric operations
at remote and demanding theaters require special software and hardware not available at the moment!

Also, development for real-time embedded mobile systems require powerful compilers!
Sadly, current OpenCL C compiler implementations do not produce enough efficient code.

Some of our clients are applying the principle "less is more" and develop with their partners SDKs
where programmers need to master ONE language (with C99 you need another language such as C++/C)
- and SDKs which are designed right from the beginning with performance and reliability having high priority
(they do not make the mistake thinking that one can optimize badly designed and implemented SDKs once it first works).

As was replied to me, embedded developers might be the ones which might chooce C instead of C++ as another.
That's true !

With respect to all developers !
Ronnie


 

0 Likes
LeeHowes
Staff
Staff

OpenCL project without any OOP language

Originally posted by: player999 I use pure C under GNU/Linux. Seems everything works fine. But there is enormous size of code. For instance, I've 800 lines of CL initialization code in my pattern recognition program. I used to program CUDA and it's C implementation much more compact.

 

Of course. CUDA's host code isn't C. It's translated into C by the CUDA compiler, which isn't so different from using the C++ bindings for OpenCL (which are just as compact in the new version, but lack single source, which is a benefit if you like avoiding having another compiler in your tool chain).

 

dragonxi4amd:

I think I understand what you're saying in your last post, but I still don't understand what you're asking for. Obviously the tool chain has limits in its optimisation ability, though it's getting pretty good these days it's clearly not going to be comparable with ICC on x86 - but there isn't another compiler generating AMD IL so there's nothing to compare against. Your C99 comments are still going over my head... are you asking for single source? We could do single source in theory, but then you wouldn't be using C as I just pointed out to player999. The C++ bindings come close to that without going outside a language standard, but that would mean people using C++.

0 Likes