Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark updates #3

Merged
merged 6 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion C/Savina/src/concurrency/Banking.lf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
files: ["../include/PseudoRandom.h",
"/lib/c/reactor-c/util/deque.h",
"/lib/c/reactor-c/util/deque.c"],
logging: warn
logging: warn,
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/concurrency/BoundedBuffer.lf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ target C {
"/lib/c/reactor-c/util/deque.c",
"../include/PseudoRandom.h"],
flags: "-lm",
logging: "warn"
logging: "warn",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/concurrency/CigaretteSmoker.lf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
files: "../include/PseudoRandom.h"
files: "../include/PseudoRandom.h",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/concurrency/Dictionary.lf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ target CCpp {
threading: false,
/// [[[end]]]
build-type : RelWithDebInfo,
logging: "warn"
logging: "warn",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/concurrency/LogisticMap.lf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 2020 TU Dresden
*
* For more details on this benchmark, see the Cpp version from which it was derived:
* https://github.com/lf-lang/lingua-franca/blob/master/benchmark/Cpp/Savina/src/concurrency/LogisticMap.lf.
* https://github.com/lf-lang/benchmarks-lingua-franca/blob/main/Cpp/Savina/src/concurrency/LogisticMap.lf.
*
* @author Christian Menard
* @author Hannes Klein
Expand All @@ -19,6 +19,7 @@ target C {
]]] */
threading: false,
/// [[[end]]]
fast: true
}

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
5 changes: 3 additions & 2 deletions C/Savina/src/concurrency/Philosophers.lf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 2020 TU Dresden and UC Berkeley
*
* For more details on this benchmark, see the Cpp version from which it was derived:
* https://github.com/lf-lang/lingua-franca/blob/master/benchmark/Cpp/Savina/src/concurrency/Philosophers.lf.
* https://github.com/lf-lang/benchmarks-lingua-franca/blob/main/Cpp/Savina/src/concurrency/Philosophers.lf.
*
* @author Christian Menard
* @author Edward A. Lee
Expand All @@ -18,7 +18,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
logging: warn
logging: warn,
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/concurrency/SortedList.lf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ target CCpp {
]]] */
threading: false,
/// [[[end]]]
files: "../include/PseudoRandom.h"
files: "../include/PseudoRandom.h",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/micro/Big.lf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ target C{
]]] */
threading: false,
/// [[[end]]]
files: "../include/PseudoRandom.h"
files: "../include/PseudoRandom.h",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/micro/Chameneos.lf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
logging: warn
logging: warn,
fast: true
}

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
1 change: 1 addition & 0 deletions C/Savina/src/micro/Counting.lf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ target C {
]]] */
threading: false,
/// [[[end]]]
fast: true
}

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
11 changes: 6 additions & 5 deletions C/Savina/src/micro/PingPong.lf
Original file line number Diff line number Diff line change
Expand Up @@ -61,41 +61,42 @@ reactor Ping(count:int(1000000)) {
reactor Pong(expected:int(1000000)) {
input receive:int;
output send:int;
input finish: bool;
state count:int(0);
reaction(receive) -> send {=
self->count++;
// info_print("Received %d", receive->value);
SET(send, receive->value);
=}
reaction(shutdown) {=
reaction(finish) {=
if (self->count != self->expected) {
fprintf(stderr, "Pong expected to receive %d inputs, but it received %d.\n",
error_print_and_exit("Pong expected to receive %d inputs, but it received %d.\n",
self->expected, self->count
);
exit(1);
}
printf("Success.\n");
self->count = 0;
=}
}

/*[[[cog
cog.outl(f'main reactor PingPong(numIterations:int({numIterations}), count:int({count}))')
]]] */
main reactor PingPong(numIterations:int(12), count:int(1000000))

/// [[[end]]]

{
runner = new BenchmarkRunner(num_iterations=numIterations);
ping = new Ping(count=count);
pong = new Pong(expected=count);

reaction(startup) {=
printBenchmarkInfo("PingPongLFCBenchmark");
printSystemInfo();
=}
runner.start -> ping.start;
ping.finished -> runner.finish;
ping.finished -> pong.finish;
ping.send -> pong.receive;
pong.send -> ping.receive;
}
1 change: 1 addition & 0 deletions C/Savina/src/micro/ThreadRing.lf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ target C {
]]] */
threading: false,
/// [[[end]]]
fast: true,
logging: warn,
};

Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/micro/Throughput.lf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
flags: "-lm"
flags: "-lm",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/parallelism/Apsp.lf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ target C {
/// [[[end]]]
build-type : RelWithDebInfo,
cmake-include: ["../lib/matrix.cmake"],
files: ["../include/matrix.h", "../lib/matrix.c", "../include/PseudoRandom.h"]
files: ["../include/matrix.h", "../lib/matrix.c", "../include/PseudoRandom.h"],
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
2 changes: 1 addition & 1 deletion C/Savina/src/parallelism/FilterBank.lf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* but those don't matter because the data is all 0.0.
*
* For more details on this benchmark, see the Cpp version from which it was derived:
* https://github.com/lf-lang/lingua-franca/blob/master/benchmark/Cpp/Savina/src/parallelism/FilterBank.lf.
* https://github.com/lf-lang/benchmarks-lingua-franca/blob/main/Cpp/Savina/src/parallelism/FilterBank.lf.
*
* @author Christian Menard
* @author Hannes Klein
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/parallelism/GuidedSearch.lf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ target CCpp {
"GuidedSearch/GuidedSearchCommon.hh",
"GuidedSearch/GridNode.cc",
"GuidedSearch/GridNode.hh"],
logging: "warn"
logging: "warn",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
5 changes: 3 additions & 2 deletions C/Savina/src/parallelism/MatMul.lf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* algorithm that appears in the Savina suite, including the same race condition.
*
* For details on this benchmark, see the Cpp version from which it was derived:
* https://github.com/lf-lang/lingua-franca/blob/master/benchmark/C/Savina/src/parallelism/FilterBank.lf
* https://github.com/lf-lang/benchmarks-lingua-franca/blob/main/C/Savina/src/parallelism/FilterBank.lf
*/

target C {
Expand All @@ -19,7 +19,8 @@ target C {
/// [[[end]]]
cmake-include: "../lib/matrix.cmake",
files: ["../lib/matrix.c", "../include/matrix.h"],
build-type: RelWithDebInfo
build-type: RelWithDebInfo,
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
33 changes: 17 additions & 16 deletions C/Savina/src/parallelism/NQueens.lf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Arthur Deng
*/

target C{
target C {
/* [[[cog
if (threading=="True"):
cog.outl("threading: true,")
Expand All @@ -50,8 +50,8 @@ target C{
/// [[[end]]]
logging: warn,
cmake-include: "/lib/c/reactor-c/util/deque.cmake",
files: ["/lib/c/reactor-c/util/deque.h", "/lib/c/reactor-c/util/deque.c"]

files: ["/lib/c/reactor-c/util/deque.h", "/lib/c/reactor-c/util/deque.c"],
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand All @@ -65,8 +65,6 @@ preamble {=

typedef deque_t work_queue_t;

int i; // declaration for counter used in loops

/**
* Checks whether the board is a valid configuration of queens where no two queens are on the same
* straight or diagonal line.
Expand All @@ -78,7 +76,7 @@ preamble {=
p = a[x];
for (y = x + 1; y < n; y++) {
q = a[y];
if(q == p || q == p - (y - x) || q == p + (y - x)) {
if (q == p || q == p - (y - x) || q == p + (y - x)) {
return false;
}
}
Expand Down Expand Up @@ -182,7 +180,11 @@ reactor Manager(num_workers: size_t(20), solutions_limit: size_t(1500000), size:

// The validation check above is a corrected version. The original Savina implementation will
// wrongly mark results as invalid if the solutions limit is above the expected solution.
printf("Result valid = %d\n", valid);
if (!valid) {
error_print_and_exit(
"An invalid number of solutions was computed: %ld.\n", self->num_solutions
);
}
free(self->manager_work_queue);
SET(finished, true);
=}
Expand All @@ -195,7 +197,7 @@ reactor Manager(num_workers: size_t(20), solutions_limit: size_t(1500000), size:
schedule(done, 0);
} else {
// send a work item to each worker (until there is no more work)
for (i = 0; i < self->num_workers && !deque_is_empty(self->manager_work_queue); i++) {
for (int i = 0; i < self->num_workers && !deque_is_empty(self->manager_work_queue); i++) {
work_item_t *val = deque_pop_front(self->manager_work_queue);
SET(do_work[i], *val);
free(val);
Expand All @@ -209,7 +211,7 @@ reactor Manager(num_workers: size_t(20), solutions_limit: size_t(1500000), size:
// accumulate all the solutions found by looping through solutions_found and increment num_solutions
size_t s = 0;

for (i = 0; i < self->num_workers; i++) {
for (int i = 0; i < self->num_workers; i++) {
if(solutions_found[i]->is_present) {
s += solutions_found[i]->value;
}
Expand All @@ -222,8 +224,8 @@ reactor Manager(num_workers: size_t(20), solutions_limit: size_t(1500000), size:

reaction (more_work) {=
// append all work items received from the workers to the internal work queue
for (i = 0; i < self->num_workers; i++) {
if(more_work[i]->is_present) {
for (int i = 0; i < self->num_workers; i++) {
if (more_work[i]->is_present) {
work_queue_t items = more_work[i]->value;
while (!deque_is_empty(&items)) {
deque_push_back(self->manager_work_queue, deque_pop_front(&items));
Expand All @@ -243,15 +245,15 @@ reactor Worker(bank_index: size_t(0), size: size_t(12), threshold: size_t(4)) {
size_t *a = do_work->value.data;
size_t depth = do_work->value.depth;

if(self->size == depth) {
if (self->size == depth) {
// It is unclear when exactly this evaluates to true and what this means.
// However, this seems to be essential for some sizes, including size=1.
SET(solutions_found, 1);
// abort the reaction
return;
}

if(depth >= self->threshold) {
if (depth >= self->threshold) {
// If depth is greater or equal to the threshold, the worker searches for solutions.
size_t num_solutions = nqueens_kernel_seq(a, depth, self->size);
if (num_solutions > 0) {
Expand All @@ -263,7 +265,7 @@ reactor Worker(bank_index: size_t(0), size: size_t(12), threshold: size_t(4)) {
size_t newDepth = depth + 1;
// prepare a work queue to be sent later
work_queue_t *work_queue = (work_queue_t *) calloc(1, sizeof(struct deque_t)); //freed in Manager (line 225)
for (i = 0; i < self->size; i++) {
for (int i = 0; i < self->size; i++) {
// prepare a mutable work item
size_t *vec = (size_t *) calloc(newDepth, sizeof(size_t)); // freed when the work_item_t is handled in another Worker (line 292)
work_item_t* item = (work_item_t *) calloc(1, sizeof(struct work_item_t)); // freed when popped from manager_work_queue (line 191)
Expand All @@ -279,7 +281,7 @@ reactor Worker(bank_index: size_t(0), size: size_t(12), threshold: size_t(4)) {
b[depth] = i;

// add the item to the list if is valid
if(board_valid(newDepth, b)) {
if (board_valid(newDepth, b)) {
deque_push_back(work_queue, item);
}
}
Expand Down Expand Up @@ -327,5 +329,4 @@ main reactor (
workers.solutions_found -> manager.solutions_found;
workers.more_work -> manager.more_work;
manager.finished -> runner.finish;

}
3 changes: 2 additions & 1 deletion C/Savina/src/parallelism/PiPrecision.lf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
cmake-include: "PiPrecision.cmake"
cmake-include: "PiPrecision.cmake",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
5 changes: 3 additions & 2 deletions C/Savina/src/parallelism/RadixSort.lf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 2021 UC Berkeley and TU Dresden
*
* For more details on this benchmark, see the Cpp version from which it was derived:
* https://github.com/lf-lang/lingua-franca/blob/master/benchmark/Cpp/Savina/src/parallelism/RadixSort.lf.
* https://github.com/lf-lang/benchmarks-lingua-franca/blob/main/Cpp/Savina/src/parallelism/RadixSort.lf.
*
* @author Hannes Klein
* @author Abanob Bostouros
Expand All @@ -22,7 +22,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
files: "../include/PseudoRandom.h"
files: "../include/PseudoRandom.h",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
3 changes: 2 additions & 1 deletion C/Savina/src/parallelism/Trapezoidal.lf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ target C {
]]] */
threading: false,
/// [[[end]]]
flags: "-lm"
flags: "-lm",
fast: true
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down