CILK_NWORKERS parameter in multicore processor

CILK_NWORKERS parameter in multicore processor

Very strange, but if I set CILK_NWORKERS to 1 in my Core 2 Duo processor, I get same time, as CILK_NWORKERS=2. And I see in task manager that 2 cores are works.I want to execute Cilk++ program with 1 thread(worker) and compare result with 2 threads(workers). I print this parameter in my program with __cilkrts_get_nworkers() function and it's sets correctly.Anybody knows what really happens if I set CILK_NWORKERS? It's seems that Cilk++ dont use this parameter as follows.

10 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

I tried this parameter on Xeon L5520 (4 cores and 8 threads). In this case this parameter influenced on program execution time.I think that Cilk++ use at least 2 workers: master and second, regardless CILK_NWORKERS sets to 1 or 2, and CILK_NWORKERS sets number of second workers. Is this correct? Or maybe worker use multiple cores? Is this any way to execute program with really one worker?

We've recently identified an error in this area. Which release are you working on? Which OS?

- Barry

icpc -vVersion 12.0.4Ubuntu 10.10

Version 12.0.4 does indeed have the bug that causes it to temporarily use one extra worker. A fix is scheduled for the next release.The only way to get accurate timing results with 12.0.4is to start your timer after the extra worker has shut itself down. The following code should work:

_Cilk_spawn []{}(); // Forces Cilk runtime to start up
sleep(1);
// Start timer here
// Execute parallel code
// Stop timer here

If you put the first two lines into main(), then you will not need to repeat them anywhere else.

BTW, you are clearly using thenewest Intel Parallel Composer, not the (unsupported) Intel Cilk++ compiler. I recommend that you post future questions to the Cilk Plus forum: http://software.intel.com/en-us/forums/intel-cilk-plus/. There, you will find answers appropriate to the compiler you are using and tap into a larger Intel compiler community.

I dont understand what is this "_Cilk_spawn []{}();" and I got compilation error on this.
I tried "cilk_spawn foo()" before timer starts, where foo is:void foo() { sleep(1);}and this is got me slower result, but I'm not shure is this correct or not.

Pablo's fix uses a lambda function, which is one of the new features of C++0x. You can enable them using the -Qstd=c++0x option.

You did the same thing with your foo() function, which was correct.

- Barry

How does one set this option in Linux? I am using icpc version 12.1.0.
My compiled program is othello.
I tried "othello -CILK_NWORKERS=2", but it __cilkrts_get_nworkers() still reports 4 (I am running on a QuadCore).

Hi ScottK,
You can type the following on the command-prompt:

CILK_NWORKERS=2 ./othello

Thanks,

Balaji V. Iyer.

Of course, if you want to set it "for a while," you can alsouse:

export CILK_NWORKERS=2
./othello

- Barry

发表评论

登录添加评论。还不是成员?立即加入