Discussion:
GCC refusing to inline a trivial function inside a cilk spawned function
Florent Hivert
2014-05-13 16:09:29 UTC
Permalink
Dear all,

I extremely happy to have the new GCC 4.9 support the CilkPlus extension. It
is both very powerful and extremely simple to use. However, I've hit what I
suspect is a bug, but before filing a bug report, I'd like to check that this
is not due to some internal I don't know about. Consider the following code

__attribute__ ((always_inline)) inline int get() { return 1; }

void Bar() {
if (get() == 0) _Cilk_spawn Bar();
}

int main(int argc, char **argv) {
Bar();
}

It compile without any problem with the following fake Cilk command
/opt/gcc-4.9.0/bin/g++ -D_Cilk_spawn='' inl.cpp
But when compiled with a genuine Cilk
/opt/gcc-4.9.0/bin/g++ -fcilkplus inl.cpp
I got the following error message:

nl.cpp: In function ‘void Bar()’:
inl.cpp:4:44: error: inlining failed in call to always_inline ‘int get()’: function not inlinable
__attribute__ ((always_inline)) inline int get() { return 1; }
^
inl.cpp:7:11: error: called from here
if (get() == 0) _Cilk_spawn Bar();

So my question is: Is it a genuine bug and I should file a report, or is there
an internal of the Cilk spawned function which prevent inlining.

For the info, I found that problem noticing that indexed access to C++11
std::array (ie std::array::operator[](size_type)) wasn't inlined
causing a large performance degradation to my code.

Cheers,

Florent Hivert
Florent Hivert
2014-05-27 07:12:58 UTC
Permalink
Dear all,

Is gcc-help the right place to ask such a question ? If not, can you please
tell me where to post it ?

Cheers,

Florent
Post by Florent Hivert
Dear all,
I extremely happy to have the new GCC 4.9 support the CilkPlus extension. It
is both very powerful and extremely simple to use. However, I've hit what I
suspect is a bug, but before filing a bug report, I'd like to check that this
is not due to some internal I don't know about. Consider the following code
__attribute__ ((always_inline)) inline int get() { return 1; }
void Bar() {
if (get() == 0) _Cilk_spawn Bar();
}
int main(int argc, char **argv) {
Bar();
}
It compile without any problem with the following fake Cilk command
/opt/gcc-4.9.0/bin/g++ -D_Cilk_spawn='' inl.cpp
But when compiled with a genuine Cilk
/opt/gcc-4.9.0/bin/g++ -fcilkplus inl.cpp
inl.cpp:4:44: error: inlining failed in call to always_inline ‘int get()’: function not inlinable
__attribute__ ((always_inline)) inline int get() { return 1; }
^
inl.cpp:7:11: error: called from here
if (get() == 0) _Cilk_spawn Bar();
So my question is: Is it a genuine bug and I should file a report, or is there
an internal of the Cilk spawned function which prevent inlining.
For the info, I found that problem noticing that indexed access to C++11
std::array (ie std::array::operator[](size_type)) wasn't inlined
causing a large performance degradation to my code.
Cheers,
Florent Hivert
--
Florent Hivert
---
Il y a trois sortes de gens dans le monde : ceux qui savent compter et
ceux qui ne savent pas.
There are three kinds of people in the world: those who can count,
and those who cannot.
---
Professeur, LRI, Univ. Paris Sud 11, CNRS.
Responsable Master 2 CCI
Bureau 33, Laboratoire de Recherche en Informatique (UMR CNRS 8623)
Bâtiment 650, Université Paris Sud 11, 91405 ORSAY CEDEX
Tél: 01-69-15-65-99
http://www.lri.fr/~hivert
Andrew Haley
2014-05-27 09:07:33 UTC
Permalink
Post by Florent Hivert
Is gcc-help the right place to ask such a question ? If not, can you please
tell me where to post it ?
This is the right place, but I don't think anyone here knows. You will
have to ask one of the cilk maintainers.

Andrew.

Loading...