-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vendor some interesting less known frameworks + cilk/staccato benches
- Loading branch information
Showing
9 changed files
with
166 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
[submodule "benchmarks/vendor/bots"] | ||
path = benchmarks/vendor/bots | ||
url = https://github.com/bsc-pm/bots | ||
[submodule "benchmarks/vendor/staccato"] | ||
path = benchmarks/vendor/staccato | ||
url = https://github.com/rkuchumov/staccato | ||
[submodule "benchmarks/vendor/uts-benchmark-code"] | ||
path = benchmarks/vendor/uts-benchmark-code | ||
url = https://git.code.sf.net/p/uts-benchmark/code | ||
[submodule "benchmarks/vendor/fibril"] | ||
path = benchmarks/vendor/fibril | ||
url = https://github.com/chaoran/fibril | ||
[submodule "benchmarks/vendor/tasking-2.0"] | ||
path = benchmarks/vendor/tasking-2.0 | ||
url = https://github.com/aprell/tasking-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <iostream> | ||
#include <chrono> | ||
#include <thread> | ||
|
||
#include <cilk/cilk.h> | ||
#include <cilk/cilk_api.h> | ||
|
||
using namespace std; | ||
using namespace std::chrono; | ||
|
||
void fib(int n, unsigned long *sum) | ||
{ | ||
if (n < 2) { | ||
*sum = 1; | ||
return; | ||
} | ||
|
||
unsigned long x; | ||
cilk_spawn fib(n - 1, &x); | ||
|
||
unsigned long y; | ||
fib(n - 2, &y); | ||
|
||
cilk_sync; | ||
|
||
*sum = x + y; | ||
} | ||
|
||
void test(int n, unsigned long *sum) | ||
{ | ||
cilk_spawn fib(n, sum); | ||
cilk_sync; | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
size_t n = 40; | ||
unsigned long answer; | ||
const char *nthreads = nullptr; | ||
|
||
if (argc >= 2) | ||
nthreads = argv[1]; | ||
if (argc >= 3) | ||
n = atoi(argv[2]); | ||
if (nthreads == nullptr) | ||
nthreads = to_string(thread::hardware_concurrency()).c_str(); | ||
|
||
__cilkrts_end_cilk(); | ||
|
||
auto start = system_clock::now(); | ||
|
||
if (__cilkrts_set_param("nworkers", nthreads) != 0) { | ||
cerr << "Failed to set worker count\n"; | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
__cilkrts_init(); | ||
|
||
test(n, &answer); | ||
|
||
__cilkrts_end_cilk(); | ||
|
||
auto stop = system_clock::now(); | ||
|
||
cout << "Scheduler: cilk\n"; | ||
cout << "Benchmark: fib\n"; | ||
cout << "Threads: " << nthreads << "\n"; | ||
cout << "Time(us): " << duration_cast<microseconds>(stop - start).count() << "\n"; | ||
cout << "Input: " << n << "\n"; | ||
cout << "Output: " << answer << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <iostream> | ||
#include <chrono> | ||
#include <thread> | ||
|
||
#include <staccato/include/task.hpp> | ||
#include <staccato/include/scheduler.hpp> | ||
|
||
using namespace std; | ||
using namespace chrono; | ||
using namespace staccato; | ||
|
||
class FibTask: public task<FibTask> | ||
{ | ||
public: | ||
FibTask (int n_, unsigned long *sum_): n(n_), sum(sum_) | ||
{ } | ||
|
||
void execute() { | ||
if (n < 2) { | ||
*sum = 1; | ||
return; | ||
} | ||
|
||
unsigned long x; | ||
spawn(new(child()) FibTask(n - 1, &x)); | ||
|
||
unsigned long y; | ||
spawn(new(child()) FibTask(n - 2, &y)); | ||
|
||
wait(); | ||
|
||
*sum = x + y; | ||
|
||
return; | ||
} | ||
|
||
private: | ||
int n; | ||
unsigned long *sum; | ||
}; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
size_t n = 40; | ||
unsigned long answer; | ||
size_t nthreads = 0; | ||
|
||
if (argc >= 2) | ||
nthreads = atoi(argv[1]); | ||
if (argc >= 3) | ||
n = atoi(argv[2]); | ||
if (nthreads == 0) | ||
nthreads = thread::hardware_concurrency(); | ||
|
||
auto start = system_clock::now(); | ||
|
||
{ | ||
scheduler<FibTask> sh(2, nthreads); | ||
sh.spawn(new(sh.root()) FibTask(n, &answer)); | ||
sh.wait(); | ||
} | ||
|
||
auto stop = system_clock::now(); | ||
|
||
cout << "Scheduler: staccato\n"; | ||
cout << "Benchmark: fib\n"; | ||
cout << "Threads: " << nthreads << "\n"; | ||
cout << "Time(us): " << duration_cast<microseconds>(stop - start).count() << "\n"; | ||
cout << "Input: " << n << "\n"; | ||
cout << "Output: " << answer << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule tasking-2.0
added at
303ce3
Submodule uts-benchmark-code
added at
722e89
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters