File tree Expand file tree Collapse file tree 5 files changed +22
-17
lines changed Expand file tree Collapse file tree 5 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 6161 threading: false,
6262 /// [[[end]]]
6363 files: ["../include/PseudoRandom.h",
64+ "../include/benchmark_runner.h",
6465 "/lib/c/reactor-c/util/deque.h",
6566 "/lib/c/reactor-c/util/deque.c"],
67+ cmake-include: ["../include/deque.cmake"],
6668 logging: warn,
6769 fast: true
6870};
6971
7072import BenchmarkRunner from "../BenchmarkRunner.lf";
7173
7274preamble {=
75+ #include "benchmark_runner.h"
7376 #include "PseudoRandom.h"
74- #include "deque.c "
77+ #include "deque.h "
7578 #include <float.h>
76- long seed = 123456 ;
79+ extern long seed;
7780 typedef deque_t message_queue_t;
7881 typedef struct CreditMessage {
7982 size_t recipient;
@@ -84,6 +87,10 @@ preamble {=
8487
8588reactor Teller(numAccounts:int(1000), numBankings:int(50000)) {
8689
90+ preamble {=
91+ long seed = 123456;
92+ =}
93+
8794 state message_queues : {=message_queue_t*=};
8895 state random_gen : {=PseudoRandom *=};
8996 input start: bool;
Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ target C {
3333 /// [[[end]]]
3434 files: ["/lib/c/reactor-c/util/deque.h",
3535 "/lib/c/reactor-c/util/deque.c",
36+ "../include/benchmark_runner.h",
3637 "../include/PseudoRandom.h"],
38+ cmake-include: ["../include/deque.cmake"],
3739 flags: "-lm",
3840 logging: "warn",
3941 fast: true
@@ -70,7 +72,7 @@ preamble {=
7072reactor ManagerReactor(bufferSize: size_t(50), numProducers: size_t(40), numConsumers: size_t(40)) {
7173
7274 preamble {=
73- #include "deque.c "
75+ #include "deque.h "
7476 =}
7577
7678 input start: bool;
Original file line number Diff line number Diff line change @@ -70,19 +70,18 @@ target C {
7070 ]]] */
7171 threading: false,
7272 /// [[[end]]]
73- files: "../include/PseudoRandom.h",
73+ files: [ "../include/PseudoRandom.h", "../include/benchmark_runner.h"] ,
7474 fast: true
7575};
7676
7777import BenchmarkRunner from "../BenchmarkRunner.lf";
7878
79+ preamble {=
80+ #include "PseudoRandom.h"
81+ =}
7982
8083reactor ArbiterReactor(numRounds:size_t(1000), numSmokers:size_t(200)) {
8184
82- preamble {=
83- #include "PseudoRandom.h"
84- =}
85-
8685 state roundsSoFar: size_t(0);
8786 state random: PseudoRandom*;
8887
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ preamble {=
4747 #include <map>
4848 #include <vector>
4949 #include <memory>
50+ #include <random>
5051 enum class AccessType {
5152 Read,
5253 Write
@@ -151,10 +152,6 @@ reactor DictionaryImpl(numWorkers: size_t(20)) {
151152
152153reactor Worker(bank_index: size_t(0), numMessagesPerWorker: size_t(10000), writePercentage: int(10)) {
153154
154- preamble {=
155- #include <random>
156- =}
157-
158155 state messageCount: size_t(0);
159156 state random: std::minstd_rand;
160157
Original file line number Diff line number Diff line change @@ -15,37 +15,37 @@ typedef struct PseudoRandom {
1515/**
1616 * Initialize the random number generator to the specified seed.
1717 */
18- void initPseudoRandom (struct PseudoRandom * random , long seed ) {
18+ static void initPseudoRandom (struct PseudoRandom * random , long seed ) {
1919 random -> mValue = seed ;
2020}
2121
2222/**
2323 * Return a random number between 0 and 65535
2424 */
25- long nextLong (struct PseudoRandom * random ) {
25+ static long nextLong (struct PseudoRandom * random ) {
2626 random -> mValue = ((random -> mValue * 1309 ) + 13849 ) & 65535 ;
2727 return random -> mValue ;
2828}
2929
3030/**
3131 * Return a random number between 0 and 65535
3232 */
33- int nextInt (struct PseudoRandom * random ) {
33+ static int nextInt (struct PseudoRandom * random ) {
3434 return (int )nextLong (random );
3535}
3636
3737/**
3838 * Return a random number between 1.0/65536
3939 * and 1.0.
4040 */
41- double nextDouble (struct PseudoRandom * random ) {
41+ static double nextDouble (struct PseudoRandom * random ) {
4242 return 1.0 / (nextLong (random ) + 1 );
4343}
4444
4545/**
4646 * Return a random number between 0 and exclusive_max - 1.
4747 */
48- int nextIntEMax (struct PseudoRandom * random , int exclusive_max ) {
48+ static int nextIntEMax (struct PseudoRandom * random , int exclusive_max ) {
4949 return nextInt (random ) % exclusive_max ;
5050}
5151
You can’t perform that action at this time.
0 commit comments