cilk::context_run is very slow

cilk::context_run is very slow

I'm on linux running 8503.

It seems thatcilk_context::run is taking 1ms to 5ms, even when I reuse the same context.That is crazy slow. (This on a 1.6GHz laptop).

In contrast a pthread_create()/pthread_join() pair takes about 30us. Even that seems way slow.

I would have hoped that if I reuse the same context that all the pthreads would be sitting around on a pthread_cond_wait() and that the cost of restarting the same context again would be on the order of 10 to 100ns.

Lookiing at strace, it appears that cilk_context::run creates new worker threads, and reparses all the memory maps.

I care about this because I have parallel jobs that are sometimes only 20ms. I can use pthreads to speed those up, but was hoping to use Cilk.


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

In Cilk++ 1.1, Cilk workerthreads are only cached and reused on Windows, not on Linux. It's technically feasible to reuse threads on Linux too; the code to do so was never writtenbecause there wasn't any visible need.

Leave a Comment

Please sign in to add a comment. Not a member? Join today