Hacker News new | past | comments | ask | show | jobs | submit login
Cilk Plus/LLVM: Intel Cilk Plus C/C++ Language Extensions in LLVM (cilkplus.github.io)
57 points by nkurz on April 22, 2016 | hide | past | favorite | 17 comments



Cilk Plus is an Intel language extension for expressing parallelism in C and C++: https://www.cilkplus.org

Mostly it's supported by Intel's ICC and ICPC compilers, but I was interested to see that it's been ported to LLVM.

There's a parallel project for GCC as well: https://www.cilkplus.org/build-gcc-cilkplus


You don't need to do any of that last link for GCC 5.0+, which supports the Cilk extensions out of the box.


Wow, I hadn't realized! That makes it dramatically more likely that Cilk will gain some traction.

Full support for Cilk Plus has been added to the GCC compiler. Cilk Plus is an extension to the C and C++ languages to support data and task parallelism

https://gcc.gnu.org/gcc-5/changes.html

Do you have any idea if support is likely to be built into clang as well?


Yes, the moment GCC landed those Cilk extensions, I started using them. The Cilk5 paper was seminal, and modern Cilk incorporates some support for SIMD, so I was delighted when GCC 5 arrived.

I don't know what the status for Clang is, but I'd be surprised if they weren't mainlined soon; that's a largely uneducated opinion though...


So does this attempt to better utilize the multiple compute units which make up a single compute pipeline? For example Skylake technically has 4 FPU's per physical core 1 SIMD, 3 x87 FPU-esque units, 1 branch processors, and 3-4ish IPU's (branch processors have some IPU uOPs)?

Or is it just a compiler integrated green thread library?

The FAQ is really vague just says its makes interfacing with parallelism easier.


It started as a very simple green-parallelism library (spawn/sync/for), but it looks like it has been expanded to include an array syntax for c (a[:] = sqrt(b[:])*c[:])), which will automatically vectorize if possible. It also has`#pragma simd` to hint to the compiler that you want a code block to be vectorized, even if the compiler would otherwise not.

There's something about 'hyper objects' too which sound like race-condition safe objects for doing things like reductions.


For example Skylake technically has 4 FPU's per physical core 1 SIMD, 3 x87 FPU-esque units, 1 branch processors, and 3-4ish IPU's (branch processors have some IPU uOPs)?

Maybe I'm misunderstanding, but that's a very odd description of the execution units in a Skylake core. It might be better to say: "Skylake can sustain execution of 4 instructions per cycle, up to three of which can perform 256-bit vector operations." Section 2.1 here gives an exact diagram: http://www.intel.com/content/dam/www/public/us/en/documents/...


It's a fine-grained (green) threading runtime and language extension. Here's one of the original papers on Cilk: [1]. The programming model is completely independent of, and orthogonal to, whatever microarchitecture the pipeline has (and in fact out-of-order execution gets you benefits from multiple EUs for free, ish, modulo any SIMD optimizations you might do).

[1] http://www.cs.cmu.edu/~chensm/Big_Data_reading_group/papers/...


More of the latter, from what I've skimmed at least.

Cilk was a language originally developed for parallelism by MIT, they developed a Cilk Plus revision, and it later adopted by Intel as Cilk++ (where they added more functionality and a few keywords). This is basically an OSS implementation of the language without all the "good stuff" that comes with the Intel Compiler. You get green threads (fibers in Intel's lexicon), an acceptable malloc which is swapped in thought appropriate, real threading (which marks off critical sections in the conventional fashion) as necessary, and the ability to use spawn/async (a conventional barrier-wait thinger).

They say "SIMD[check]" so in theory there are all of those AVX512 with the SIMD stuff (xmm0,16..ymm0-32? It's been a while since I've looked at the ISA) in here but I went through the code briefly and saw no reference to utilization of those registers. This page is really doing a real disservice to the language because where it really shines is in the tooling that integrates with the language. The Parallel Suite XE (priced around Visual Studio) lets you get some crazy-granular stuff for traditional number--crunching that GCC and LLVM doesn't produce (effectively leaving those registers unused). With ICC, to state the obvious, you get that functionality, as well as all the fantastic cluster analysis stuff. (n.b. VS with TPL does a not-too-bad-job at utilizing the AVX(edit: put in "AVR" originally ugh haha) subset of the ISA.)

edit: https://bitbucket.org/intelcilkruntime/intel-cilk-runtime/sr... Yeah.. not too much processor specific stuff. In that dir, a few files showed the impl details of their threads which was just a conventional mov $1, rax; mov $2,rbx, blah blah. Nothing special. There are references to the 'special sauce' (vla references) left in the code from "if __INTEL__COMPILER__" macros, so I'm guessing it's just a copy-paste. Shame, it's a great language/toolset.


"The Intel® Cilk™ Plus runtime library is distributed under a BSD 3-Clause license.

"

Enjoy having to put attribution in literally every Cilk binary you distribute :P


Is that really an issue for folks? Just about every commercial software package seems to have an "about" screen listing all the libraries they are using, mobile phones have menu entries for it etc, and it doesn't seem to be that big of a deal as long as it is one of the standard licenses.


I don't know why you are getting downvoted. Clause #2 would require the inclusion of the BSD license with any release of compiled code. This is a very serious issue with the library. Any additional licensing terms which must be propagated to the compiled software is bad juju.


What are you talking about? Every open source license I can think of requires you to distribute the license with your binary: GPL, LGPL, BSD, MIT, Apache, etc.


The vast majority of compiler runtime libraries have explicit exceptions to licenses to avoid this, to avoid creating copyright infringers out of everyone.


So? You just don't use Cilk if you don't want to include the license, just like a normal library. It is a language extension, not something that magically infects your regular C or Fortran code...


Is this true for MIT? BSD, for example, explicitly mentions binary distribution but MIT does not.


The MIT license says "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software." I would think that a binary distribution would count as a "copy or substantial portion of the Software", but I'm not a lawyer.

Full text:

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: