Using TBB with C99 ?

Using TBB with C99 ?

 Hi everyone, I just wonder is it possible to use TBB with standard C (C99) ? I have checked the header files and it seem like they are all for C++.

Thank you
Ryan

publicaciones de 16 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Hi Ryan,

>>... I just wonder is it possible to use TBB with standard C (C99) ?

I understood that you want to compile TBB sources with some pure C compiler? Is that what you want?

or

You want the TBB team to re-design TBB library to support only C language ( no Any C++ key words, features, etc )? If Yes, I don't think it is possible.

Best regards,
Sergey

Also, TBB is a highly portable library and it can be build with many C/C++ compilers. What I see on the web is that Microsoft has no plans to support C99 standard.

Hi Sergey, Thank you for your reply. I would like to use TBB with a pure C compiler (for example gcc). But as far as I know, the header files bundled with TBB are for C++. Or I miss something ?

Ryan

>>...I would like to use TBB with a pure C compiler (for example gcc). But as far as I know, the header files bundled with
>>TBB are for C++. Or I miss something ?

Please take a look at a couple of files in [TBBDIR]\Build\... folder. For example:

- linux.*.inc
- linux.inc

This is what I see in linux.inc:
...
native_compiler := gcc
export compiler ?= gcc
...

I don't quite see the point here. comp=gcc means using g++, i.e., the C++ compiler from GCC. Is this really about an environment with a C-only installation? Then you'll have a hard time writing a program in TBB, because it is all about using C++ constructs to facilitate writing parallel programs in an established standard language. You'll be able to link in C-only code, of course, but that may not be very comfortable at the level of granularity that TBB addresses, I suppose. Perhaps somebody could try to express the same ideas purely in C, but I don't know how successful that could be, and it's not something that Intel would be interested in, I think.

>>...Then you'll have a hard time writing a program in TBB, because it is all about using C++ constructs to facilitate writing parallel
>>programs...

Exactly and my first question was what about C++ operators '()' because they are used extensively in TBB.

Ryan, I don't understand what is a main purpose of a 'Pure-C' port of TBB? Could you explain it?

No doubt that C++ is an established language, and a cross platform library can tap a large market but C is also quite popular, especially for HPC community, and it's actually becoming quite hot lately. Hope that Intel will note about this.

@Sergey: currently we are working on a project that use a pure C implementation.
@Raf Schietekat: yeah sorry, my post was about pure C implementation.

Hi Ryan,

>>No doubt that C++ is an established language, and a cross platform library can tap a large market but C is also quite popular,
>>especially for HPC community, and it's actually becoming quite hot lately. Hope that Intel will note about this.
>>...

Thank you for your explanations.

This is my personal opinion and I think some "domains" in TBB are over-complicated. For example, a subsystem that provides a "Parallel-For" functionality could be implemented with a couple of hundreds C or C++ code lines instead of a couple of thousands.

>>@Sergey: currently we are working on a project that use a pure C implementation...

In overall, I see that there are four concepts in the programming world now:

1. A simple software subsystem implemented in as simple as possible way
2. A simple software subsystem implemented in as complex as possible way
3. A complex software subsystem implemented in as simple as possible way
4. A complex software subsystem implemented in as complex as possible way

What concept is applicable in your case?

I meant an established standard language as opposed to a bespoke one like Cilk, or even the need for OpenMP, which is based on adding #pragma's, and is also available for C and Fortran, perhaps even in your environment? To me it would seem more sensible to further tweak OpenMP than to attempt to port TBB "down" to C (or at least reimplement its ideas as well as possible), hoping to woo users without the benefit of C++'s powerful additional constructs to hide most of the complexity where OpenMP's pitch is to "just" add a #pragma here and there and still get most of the benefits that way. And it's not even as if HPC eschews C++ as a matter of course: you'll find it at least on some of the top-ranking systems, so I'm even a bit curious why it's not available to you?

>>...OpenMP's pitch is to "just" add a #pragma here and there and still get most of the benefits that way...

It is the best way to increase performance of legacy applications with millions of C/C++ code lines. For a new application someone could select Intel TBB, or Nvidia CUDA, or some multi-threading libraries from Microsoft, or OpenMP.

Cita:

It is the best way to increase performance of legacy applications with millions of C/C++ code lines. For a new application someone could select Intel TBB, or Nvidia CUDA, or some multi-threading libraries from Microsoft, or OpenMP.

Quite so.

Hi everyone,
I would like to use TBB with standard c.but is it possible to use c with TBB as i dont see any example code in c for TBB.

reagrds,

Hi,

You can do a very simple verification. Here is a test-case:

#include *tbb/tbb.h*
#include *tbb/task_scheduler_init.h*

void main( void )
{
tbb::task_scheduler_init tsi( 8 );
}

Try to compile it with a C compiler and let us know results. Thanks in advance.

Without the sarcasm: you cannot use TBB without a C++ compiler, but you can link in or use C code as with any C++ program, so you can call C routines compiled with a C or C++ compiler from a TBB program compiled with a C++ compiler, and you can add/substitute TBB (C++) code to/in existing C code because C++ is downward compatible with C. See also my comments above.

>>... i dont see any example code in c for TBB...

As Raf already explained it is impossible to use TBB with a C compiler because in TBB sources there are lots of C++ keywords, like 'class', 'template', 'T', etc. That is why a C++ compiler is needed.

In my previous post I provided a test-case and I'm interested to see a list of compilation errors when you try to compile the test-case with a C compiler. I expect that first compilation error will be in 'aligned_space.h' header file:

[ aligned_space.h ]
...
template*typename T,size_t N*
class aligned_space {
private:
...

Note: left-arrow and right-arrow characters ( they are not displayed ) are replaced with '*'. This is known problem with the Editor.

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya