An Intel® Cilk™ Plus construct was found to contain an OpenMP construct or vice versa
OpenMP and Intel® Cilk™ Plus are two frameworks that allow a programmer to express parallelism. Both of these technologies rely on similar ideas. There are source coding patterns that indicate where parallelism can be applied. There is a pool of worker threads that can be dynamically applied to work units. Generally speaking, the number of worker threads in the pool is determined by the number of physical processing units available.
Ideally Intel® Cilk™ Plus and OpenMP should share the same pool of threads. If they don't, then this creates the possibility of over subscription, that is, contention for processing units. This can lead to loss of efficiency. Generally speaking, both Intel® Cilk™ Plus and OpenMP take care to avoid over subscription, but this only works if the two threading subsystems are aware of each other or at least are not simultaneously active.
If the Intel® Cilk™ Plus and OpenMP runtime systems are known to be integrated in the implementations that will be used for this application then this diagnostic can be safely ignored.
ID |
Observation |
Description |
---|---|---|
1 |
Intel® Cilk™ Plus declaration or OpenMP* declaration |
The inner construct |
1 |
Intel® Cilk™ Plus declaration or OpenMP* declaration |
The outer construct |
#include <cilk.h> #include <omp.h> int a[100][100] = {1, 3, 5, 7, 9}; int do_a_chunk(int row, int start, int end) { int chunksum = 0; for (int j = start; j < end; j++) { chunksum += a[row][j]; } return chunksum; } int main(int argc, char **argv) { int i,j,sum; sum = 0; #pragma omp parallel for reduction(+:sum) for (i = 0; i < 100; i++) { int sum1,sum2,sum3,sum4; // use Intel(R) Cilk(TM) Plus to execute the inner loop on // (up to) four threads; not a good idea sum1 = cilk_spawn do_a_chunk(i, 0, 25); sum2 = cilk_spawn do_a_chunk(i, 25, 50); sum3 = cilk_spawn do_a_chunk(i, 50, 75); sum4 = do_a_chunk(i, 75, 100); cilk_sync; sum += sum1 + sum2 + sum3 + sum4; } return sum; }
Copyright © 2010, Intel Corporation. All rights reserved.