next Cilk functions

next Cilk functions

In a previous thread here (which I am now unable to now locate) I asked if it was okay to nest cilk_spawn functions. The reply was yes.

The next questions then is it okay to nest a cilk_spawn function call; with a cilk_for call. In other words cilk_spawn calls a function and in that function there is cilk_for?

I know that it is not a good idea to put cilk_spawn calls inside of a for or cilk_for function.


4 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Yes, thisshould fine.

cilk_for is implemented in the compiler by lifting the cilk_for body into a lambda function, and passing that function into the Cilk runtime along with the grainsize and number of entries in your loop. The Cilk runtime then does a recursive divide-and-conquer; splitting the entries in (roughly) half, and spawning half and calling half, until the number of entries is less than the grainsize, at which point the lambda function is called to actually do the work.

You can nest cilk_for and cilk_spawn as much as you want and everything will work correctly. The limitation is imposed by the fact that a cilk_spawn has more overhead than a simple call. Not much; a cilk_spawn is about 4x the cost of a call. But still more. If you nest too deeply, you'll have excessive cilk_spawn overhead which will hurt performance.

As always, it's a matter of balance. The Cilkview Scalability Analyzer should be able to help you with this.

- Barry

Barry Tannenbaum wrote:
| The Cilkview Scalability Analyzer should be able to help you with this.

Has this been released somewhere? I don't see mention of it in the docs.


Oops. My bad. Wrong forum.

The Cilkscreen Race Detector and Cilkscreen Scalability Analyzer are shipped as part of the Cilk++ compiler available as a WhatIf package. The Cilk tools arenot yet available for Intel Cilk Plus.

- Barry

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo