Elemental functions: Writing data parallel code in C/C++ using Intel® Cilk™ Plus

Intel® Cilk™ Plus is a simple C/C++ language extension construct for data parallel operations.


Intel® Cilk™ Plus provides simple to use language extensions to express data and task-parallelism to the C and C++ language implemented by the Intel® C++ Compiler, which is part of Intel® Parallel Composer and Intel® Parallel Studio. This article describes one of these programming constructs: “elemental functions”.

There are cases in which the algorithm performs operations on large collection of data, with no dependence among the operations being performed on the various data item. For example, the programmer may write, at a certain point of the algorithm: add arrays a1 and a2 and store the result in array r. When thinking at that level, the programmer is thinking in terms of a single operation that needs to be performed on many elements, independently of each other. Unfortunately, the C/C++ programming languages do not provide constructs that allow expressing the operation as such. Instead, they force the programmer to elaborate the operation in terms of a loop that operates on each array element. The end result, in terms of the values being stored in the result array, would be the same. However, the introduction of the loop introduces an unintended order of operations: The implementation has to add the first two array elements, store the results in the first location of the result array, move on to perform the same operation on the second set of elements, and so on. An example later will show what is expected to be a typical use of elemental function: use a single line to mark a standard C/C++ function as elemental, change the invocation loop from serial to parallel (in this example, it is a change of one keyword) and that is it.

To continue reading the article, click on the link below.

Refer to http://software.intel.com/en-us/articles/optimization-notice for more information regarding performance and optimization choices in Intel software products.

For more complete information about compiler optimizations, see our Optimization Notice.


I have to agree with MLK. I have been looking for a simple example for 10 minutes and keep coming up dry. You keep telling me there are only three keywords without saying what they are. PDFs, white papers, and marketing BS are just ways to pay consultants more. Just give me a bulleted list of this "simple" language extension with a brief, CONCRETE description.

http://software.intel.com/en-us/articles/intel-cilk-plus/ is poorly written. I don't need Intel to tell me multicore has become prevalent and Cilk is "quick" and "easy." Just show me a program!

I think Intel, as well as all others, should strive to give basic info about its products, such as Cilk, on the product's web page, without asking people to further click this or cick that, watch a video, download something, etc. In Cilk's case, Intel fails to just list a very simple Cilk program on the Cilk page. A concrete simple example is worth a hundred words. KISS! I hate to read things like "As multicore systems become prevalent on desktops, servers and even laptop systems, new performance leaps will come as the industry adopts parallel programming techniques. ...." These are simply bulls. Get right to the point! You don't know how to sell things! You think people would be motivated to learn more by reading nonsense like "The Intel Cilk Plus language, built on the Cilk technology developed at M.I.T. over the past two decades, is designed to provide a simple, well-structured model that makes development, verification and analysis easy"? I don't care whether it is from MIT or Stanford; everybody says their languages are simple and easy. So, save all these; and just show a simple good example!