0

ie. for

int A[100]
A[:] = 1;

does that try to create a 100 threads? or is it the same as doing a for loop?

I thought it was parallelized but I just tested it and it doesn't look like it.

Is there a way to make it use multiple threads or is Array notation just that, notation?

d0m1n1c
  • 157
  • 4
  • 16

1 Answers1

0

No. Cilk Plus supports two kinds of parallelism; data parallelism and task parallelism.

Data parallelism performs the same operation on multiple values simultaneously. It's sometimes referred to as SIMD - Single Instruction, Multiple Data. Array notation is a "hint" to the compiler that this is a data parallel operation and should be performed using the CPU's vector units. When there are more elements than will fit in the vector unit, the compiler will generate a loop around the operation. If the compiler can detect that multiple lines are operating on the same sets of data, it will put the loop around the whole calculation.

Task parallelism performs multiple tasks simultaneously, where each task is executing its own stream of instructions. If you want to do your calculation in parallel as well, you need to use a cilk_for loop around your calculation. You could also use TBB or OpenMP, if you prefer them.

  • Barry
user2062850
  • 251
  • 1
  • 6
  • I'll add that the semantics of array notation were designed to allow a multi-threaded implementation. But it's never been implemented that way. But would be awkward for performance, because if an array section is large enough to amortize parallel scheduling overhead, it's also likely big enough to not fit in cache, and thus introduce bandwidth problems. – Arch D. Robison Apr 24 '14 at 17:41