Cilk: Add support for Cilk (with C/C++) (#3522)
This commit is contained in:
parent
859f99a042
commit
c8462a29fb
File diff suppressed because one or more lines are too long
|
@ -306,6 +306,18 @@
|
||||||
"title": "CIL",
|
"title": "CIL",
|
||||||
"owner": "sbrl"
|
"owner": "sbrl"
|
||||||
},
|
},
|
||||||
|
"cilkc": {
|
||||||
|
"title": "Cilk/C",
|
||||||
|
"require": "c",
|
||||||
|
"alias": "cilk-c",
|
||||||
|
"owner": "OpenCilk"
|
||||||
|
},
|
||||||
|
"cilkcpp": {
|
||||||
|
"title": "Cilk/C++",
|
||||||
|
"require": "cpp",
|
||||||
|
"alias": ["cilk-cpp", "cilk"],
|
||||||
|
"owner": "OpenCilk"
|
||||||
|
},
|
||||||
"clojure": {
|
"clojure": {
|
||||||
"title": "Clojure",
|
"title": "Clojure",
|
||||||
"owner": "troglotit"
|
"owner": "troglotit"
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
Prism.languages.cilkc = Prism.languages.insertBefore('c', 'function', {
|
||||||
|
'parallel-keyword': {
|
||||||
|
pattern: /\bcilk_(?:for|reducer|s(?:cope|pawn|ync))\b/,
|
||||||
|
alias: 'keyword'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Prism.languages['cilk-c'] = Prism.languages['cilkc'];
|
|
@ -0,0 +1 @@
|
||||||
|
Prism.languages.cilkc=Prism.languages.insertBefore("c","function",{"parallel-keyword":{pattern:/\bcilk_(?:for|reducer|s(?:cope|pawn|ync))\b/,alias:"keyword"}}),Prism.languages["cilk-c"]=Prism.languages.cilkc;
|
|
@ -0,0 +1,9 @@
|
||||||
|
Prism.languages.cilkcpp = Prism.languages.insertBefore('cpp', 'function', {
|
||||||
|
'parallel-keyword': {
|
||||||
|
pattern: /\bcilk_(?:for|reducer|s(?:cope|pawn|ync))\b/,
|
||||||
|
alias: 'keyword'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Prism.languages['cilk-cpp'] = Prism.languages['cilkcpp'];
|
||||||
|
Prism.languages['cilk'] = Prism.languages['cilkcpp'];
|
|
@ -0,0 +1 @@
|
||||||
|
Prism.languages.cilkcpp=Prism.languages.insertBefore("cpp","function",{"parallel-keyword":{pattern:/\bcilk_(?:for|reducer|s(?:cope|pawn|ync))\b/,alias:"keyword"}}),Prism.languages["cilk-cpp"]=Prism.languages.cilkcpp,Prism.languages.cilk=Prism.languages.cilkcpp;
|
|
@ -0,0 +1,42 @@
|
||||||
|
<h2>Cilk keywords</h2>
|
||||||
|
<pre><code>cilk_scope {}
|
||||||
|
cilk_spawn f();
|
||||||
|
cilk_spawn {}
|
||||||
|
cilk_sync;
|
||||||
|
cilk_for () {}
|
||||||
|
int cilk_reducer() x;</code></pre>
|
||||||
|
|
||||||
|
<h2>Full example</h2>
|
||||||
|
<pre><code>#include <cilk/cilk.h>
|
||||||
|
|
||||||
|
int fib_cilk_scope(int n) {
|
||||||
|
if (n < 2)
|
||||||
|
return;
|
||||||
|
int x, y;
|
||||||
|
cilk_scope {
|
||||||
|
x = cilk_spawn fib(n-1);
|
||||||
|
y = fib(n-2);
|
||||||
|
}
|
||||||
|
return x + y;
|
||||||
|
|
||||||
|
int fib_cilk_sync(int n) {
|
||||||
|
if (n < 2)
|
||||||
|
return;
|
||||||
|
int x = cilk_spawn fib(n-1);
|
||||||
|
int y = fib(n-2);
|
||||||
|
cilk_sync;
|
||||||
|
return x + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zero(void *v) {
|
||||||
|
*(int *)v = 0;
|
||||||
|
}
|
||||||
|
void plus(void *l, void *r) {
|
||||||
|
*(int *)l += *(int *)r;
|
||||||
|
}
|
||||||
|
int array_sum_cilk_for_reducer(int *A, int n) {
|
||||||
|
int cilk_reducer(zero, plus) sum = 0;
|
||||||
|
cilk_for (int i = 0; i < n; ++i)
|
||||||
|
sum += A[i];
|
||||||
|
return sum;
|
||||||
|
}</code></pre>
|
|
@ -0,0 +1,43 @@
|
||||||
|
<h2>Cilk keywords</h2>
|
||||||
|
<pre><code>cilk_scope {}
|
||||||
|
cilk_spawn f();
|
||||||
|
cilk_spawn {}
|
||||||
|
cilk_sync;
|
||||||
|
cilk_for () {}
|
||||||
|
int cilk_reducer() x;</code></pre>
|
||||||
|
|
||||||
|
<h2>Full example</h2>
|
||||||
|
<pre><code>#include <cilk/cilk.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
int fib_cilk_scope(int n) {
|
||||||
|
if (n < 2)
|
||||||
|
return;
|
||||||
|
int x, y;
|
||||||
|
cilk_scope {
|
||||||
|
x = cilk_spawn fib(n-1);
|
||||||
|
y = fib(n-2);
|
||||||
|
}
|
||||||
|
return x + y;
|
||||||
|
|
||||||
|
int fib_cilk_sync(int n) {
|
||||||
|
if (n < 2)
|
||||||
|
return;
|
||||||
|
int x = cilk_spawn fib(n-1);
|
||||||
|
int y = fib(n-2);
|
||||||
|
cilk_sync;
|
||||||
|
return x + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zero(void *v) {
|
||||||
|
*(int *)v = 0;
|
||||||
|
}
|
||||||
|
void plus(void *l, void *r) {
|
||||||
|
*(int *)l += *(int *)r;
|
||||||
|
}
|
||||||
|
int array_sum_cilk_for_reducer(std::vector<int> A) {
|
||||||
|
int cilk_reducer(zero, plus) sum = 0;
|
||||||
|
cilk_for (auto itr = A.cbegin(); itr != A.cend(); ++itr)
|
||||||
|
sum += *itr;
|
||||||
|
return sum;
|
||||||
|
}</code></pre>
|
|
@ -33,6 +33,8 @@
|
||||||
"clike",
|
"clike",
|
||||||
"cpp"
|
"cpp"
|
||||||
],
|
],
|
||||||
|
"cilkc": "c",
|
||||||
|
"cilkcpp": "cpp",
|
||||||
"coffeescript": "javascript",
|
"coffeescript": "javascript",
|
||||||
"crystal": "ruby",
|
"crystal": "ruby",
|
||||||
"css-extras": "css",
|
"css-extras": "css",
|
||||||
|
@ -195,6 +197,9 @@
|
||||||
"cs": "csharp",
|
"cs": "csharp",
|
||||||
"dotnet": "csharp",
|
"dotnet": "csharp",
|
||||||
"cfc": "cfscript",
|
"cfc": "cfscript",
|
||||||
|
"cilk-c": "cilkc",
|
||||||
|
"cilk-cpp": "cilkcpp",
|
||||||
|
"cilk": "cilkcpp",
|
||||||
"coffee": "coffeescript",
|
"coffee": "coffeescript",
|
||||||
"conc": "concurnas",
|
"conc": "concurnas",
|
||||||
"jinja2": "django",
|
"jinja2": "django",
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -69,6 +69,11 @@
|
||||||
"cfscript": "CFScript",
|
"cfscript": "CFScript",
|
||||||
"cfc": "CFScript",
|
"cfc": "CFScript",
|
||||||
"cil": "CIL",
|
"cil": "CIL",
|
||||||
|
"cilkc": "Cilk/C",
|
||||||
|
"cilk-c": "Cilk/C",
|
||||||
|
"cilkcpp": "Cilk/C++",
|
||||||
|
"cilk-cpp": "Cilk/C++",
|
||||||
|
"cilk": "Cilk/C++",
|
||||||
"cmake": "CMake",
|
"cmake": "CMake",
|
||||||
"cobol": "COBOL",
|
"cobol": "COBOL",
|
||||||
"coffee": "CoffeeScript",
|
"coffee": "CoffeeScript",
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,63 @@
|
||||||
|
cilk_for()
|
||||||
|
cilk_for ()
|
||||||
|
|
||||||
|
cilk_spawn f();
|
||||||
|
cilk_spawn {}
|
||||||
|
cilk_spawn{}
|
||||||
|
|
||||||
|
cilk_sync;
|
||||||
|
|
||||||
|
cilk_scope {}
|
||||||
|
cilk_scope{}
|
||||||
|
|
||||||
|
int cilk_reducer() x;
|
||||||
|
int cilk_reducer () x;
|
||||||
|
|
||||||
|
----------------------------------------------------
|
||||||
|
|
||||||
|
[
|
||||||
|
["parallel-keyword", "cilk_for"], ["punctuation", "("], ["punctuation", ")"],
|
||||||
|
["parallel-keyword", "cilk_for"], ["punctuation", "("], ["punctuation", ")"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_spawn"],
|
||||||
|
["function", "f"],
|
||||||
|
["punctuation", "("],
|
||||||
|
["punctuation", ")"],
|
||||||
|
["punctuation", ";"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_spawn"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_spawn"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_sync"], ["punctuation", ";"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_scope"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_scope"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["keyword", "int"],
|
||||||
|
["parallel-keyword", "cilk_reducer"],
|
||||||
|
["punctuation", "("],
|
||||||
|
["punctuation", ")"],
|
||||||
|
" x",
|
||||||
|
["punctuation", ";"],
|
||||||
|
|
||||||
|
["keyword", "int"],
|
||||||
|
["parallel-keyword", "cilk_reducer"],
|
||||||
|
["punctuation", "("],
|
||||||
|
["punctuation", ")"],
|
||||||
|
" x",
|
||||||
|
["punctuation", ";"]
|
||||||
|
]
|
||||||
|
|
||||||
|
----------------------------------------------------
|
||||||
|
|
||||||
|
Check Cilk keywords.
|
|
@ -0,0 +1,63 @@
|
||||||
|
cilk_for()
|
||||||
|
cilk_for ()
|
||||||
|
|
||||||
|
cilk_spawn f();
|
||||||
|
cilk_spawn {}
|
||||||
|
cilk_spawn{}
|
||||||
|
|
||||||
|
cilk_sync;
|
||||||
|
|
||||||
|
cilk_scope {}
|
||||||
|
cilk_scope{}
|
||||||
|
|
||||||
|
int cilk_reducer() x;
|
||||||
|
int cilk_reducer () x;
|
||||||
|
|
||||||
|
----------------------------------------------------
|
||||||
|
|
||||||
|
[
|
||||||
|
["parallel-keyword", "cilk_for"], ["punctuation", "("], ["punctuation", ")"],
|
||||||
|
["parallel-keyword", "cilk_for"], ["punctuation", "("], ["punctuation", ")"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_spawn"],
|
||||||
|
["function", "f"],
|
||||||
|
["punctuation", "("],
|
||||||
|
["punctuation", ")"],
|
||||||
|
["punctuation", ";"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_spawn"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_spawn"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_sync"], ["punctuation", ";"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_scope"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["parallel-keyword", "cilk_scope"],
|
||||||
|
["punctuation", "{"],
|
||||||
|
["punctuation", "}"],
|
||||||
|
|
||||||
|
["keyword", "int"],
|
||||||
|
["parallel-keyword", "cilk_reducer"],
|
||||||
|
["punctuation", "("],
|
||||||
|
["punctuation", ")"],
|
||||||
|
" x",
|
||||||
|
["punctuation", ";"],
|
||||||
|
|
||||||
|
["keyword", "int"],
|
||||||
|
["parallel-keyword", "cilk_reducer"],
|
||||||
|
["punctuation", "("],
|
||||||
|
["punctuation", ")"],
|
||||||
|
" x",
|
||||||
|
["punctuation", ";"]
|
||||||
|
]
|
||||||
|
|
||||||
|
----------------------------------------------------
|
||||||
|
|
||||||
|
Check Cilk keywords.
|
Loading…
Reference in New Issue