Skip to content

Commit

Permalink
Merge branch 'master' into xtend-to-java-generator-base
Browse files Browse the repository at this point in the history
  • Loading branch information
housengw committed Feb 28, 2022
2 parents a71034e + 8133847 commit a61b2c4
Show file tree
Hide file tree
Showing 61 changed files with 915 additions and 305 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/test-lfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bin/lfc --output-path . test/C/src/Minimal.lf
# --runtime-version <arg> Specify the version of the runtime
# library used for compiling LF
# programs.
bin/lfc --runtime-version 26e6e641916924eae2e83bbf40cbc9b933414310 test/Cpp/src/Minimal.lf
bin/lfc --runtime-version ca216ccc3da5ecff0e8013f75e275d7acac099de test/Cpp/src/Minimal.lf

# -t,--threads Specify the default number of threads.
bin/lfc -t 2 test/C/src/Minimal.lf
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/benchmark-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ jobs:
run: |
python3 benchmark/runner/run_benchmark.py -m test_mode=True iterations=1 benchmark="glob(*)" target=lf-c,lf-c-unthreaded
if: ${{ inputs.target == 'C' }}
- name: Setup C++ build environment
- name: Compile reactor-cpp once and reuse for all benchmarks
run: |
./bin/lfc test/Cpp/src/Minimal.lf
echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/test/Cpp/lib" >> $GITHUB_ENV
mkdir -p reactor-cpp/build
cd reactor-cpp/build
cmake -DCMAKE_INSTALL_PREFIX=../install ../../org.lflang/src/lib/cpp/reactor-cpp
make install
echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/reactor-cpp/install/lib" >> $GITHUB_ENV
if: ${{ inputs.target == 'Cpp' }}
- name: Test C++ benchmarks
run: |
python3 benchmark/runner/run_benchmark.py -m test_mode=True iterations=1 benchmark="glob(*)" target=lf-cpp iterations=1 target.params.extra_args="[--external-runtime-path, ${GITHUB_WORKSPACE}/test/Cpp]"
python3 benchmark/runner/run_benchmark.py -m test_mode=True iterations=1 benchmark="glob(*)" target=lf-cpp iterations=1 target.params.extra_args="[--external-runtime-path, ${GITHUB_WORKSPACE}/reactor-cpp/install]"
if: ${{ inputs.target == 'Cpp' }}
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/c-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
required: false
type: boolean
default: false
scheduler:
required: false
type: string

jobs:
run:
Expand Down Expand Up @@ -53,14 +56,19 @@ jobs:
- name: Build RTI docker image
uses: ./.github/actions/build-rti-docker
if: ${{ runner.os == 'Linux' }}
- name: Perform tests for C target
- name: Perform tests for C target with default scheduler
run: |
./gradlew test --tests org.lflang.tests.runtime.CTest.* --tests org.lflang.tests.lsp.LspTests.lspWithDependenciesTestC
if: ${{ !inputs.use-cpp }}
- name: Perform tests for CCpp target
if: ${{ !inputs.use-cpp && !inputs.scheduler }}
- name: Perform tests for C target with specified scheduler (no LSP tests)
run: |
echo "Specified scheduler: ${{ inputs.scheduler }}"
./gradlew test --tests org.lflang.tests.runtime.CSchedulerTest.* -Dscheduler=${{ inputs.scheduler }}
if: ${{ !inputs.use-cpp && inputs.scheduler }}
- name: Perform tests for CCpp target with default scheduler
run: |
./gradlew test --tests org.lflang.tests.runtime.CCppTest.*
if: ${{ inputs.use-cpp }}
if: ${{ inputs.use-cpp && !inputs.scheduler }}
- name: Report to CodeCov
uses: codecov/codecov-action@v2.1.0
with:
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/cpp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ jobs:
repository: lf-lang/lingua-franca
submodules: true
ref: ${{ inputs.compiler-ref }}
- name: Set cpp runtime version
run: |
echo ${{ inputs.runtime-ref }} > org.lflang/src/org/lflang/generator/cpp/cpp-runtime-version.txt
if: ${{ inputs.runtime-ref }}
- name: Check out specific ref of reactor-cpp
uses: actions/checkout@v2
with:
repository: lf-lang/reactor-cpp
path: org.lflang/src/lib/cpp/reactor-cpp
ref: ${{ inputs.runtime-ref }}
if: ${{ inputs.runtime-ref }}
- name: Run C++ tests;
run: |
./gradlew test --tests org.lflang.tests.runtime.CppTest.* --tests org.lflang.tests.lsp.LspTests.lspWithDependenciesTestCpp
Expand All @@ -42,4 +45,4 @@ jobs:
file: org.lflang.tests/build/reports/xml/jacoco
fail_ci_if_error: false
verbose: true
if: ${{ !inputs.compiler-ref }} # i.e., if this is part of the main repo's CI
if: ${{ !inputs.runtime-ref }} # i.e., if this is part of the main repo's CI
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "org.lflang/src/lib/py/reactor-c-py"]
path = org.lflang/src/lib/py/reactor-c-py
url = https://github.com/lf-lang/reactor-c-py.git
[submodule "org.lflang/src/lib/cpp/reactor-cpp"]
path = org.lflang/src/lib/cpp/reactor-cpp
url = https://github.com/lf-lang/reactor-cpp
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/BoundedBuffer.lf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/CigaretteSmoker.lf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/Dictionary.lf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ target CCpp {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/LogisticMap.lf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
3 changes: 2 additions & 1 deletion benchmark/C/Savina/src/concurrency/Philosophers.lf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down Expand Up @@ -183,7 +184,7 @@ reactor Arbitrator(num_philosophers:int(20)) {
if (finished[i]->is_present) {
self->finished_philosophers++;
if (self->num_philosophers == self->finished_philosophers) {
printf("Arbitrator: All philosophers are seated. Number of denials to philosophers: %d\n", self->retries);
printf("Arbitrator: All philosophers are sated. Number of denials to philosophers: %d\n", self->retries);
SET(allFinished, true);
}
}
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/SleepingBarber.lf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/SortedList.lf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target CCpp {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/Big.lf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target C{
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/Chameneos.lf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/Counting.lf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/PingPong.lf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/ThreadRing.lf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
3 changes: 2 additions & 1 deletion benchmark/C/Savina/src/micro/Throughput.lf
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
threads: 2,
/// [[[end]]]
flags: "-lm",
flags: "-lm"
};

import BenchmarkRunner from "../BenchmarkRunner.lf";
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/Apsp.lf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/FilterBank.lf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/GuidedSearch.lf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ target CCpp {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/MatMul.lf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/NQueens.lf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target C{
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/PiPrecision.lf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/RadixSort.lf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/Trapezoidal.lf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
19 changes: 10 additions & 9 deletions benchmark/Rust/Savina/src/parallelism/MatMul.lf
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ reactor Manager(numWorkers: usize(20), dataLength: usize(1024)) {
input[numWorkers] moreWork: {=[WorkItem; 8]=};

reaction(startup) {=
// Fill both input arrays with data
// Fill both input arrays with data
let (a, b) = {
let mut a = Matrix::<f64>::new(self.data_length, self.data_length);
let mut b = TransposedMatrix::<f64>::new(self.data_length, self.data_length);

for i in 0..self.data_length {
for j in 0..self.data_length {
a.set(i, j, i as f64);
b.set(i, j, j as f64);
}
}

(Arc::new(a), Arc::new(b))
};

self.A = a;
self.B = b;
=}
Expand Down Expand Up @@ -143,7 +143,7 @@ reactor Manager(numWorkers: usize(20), dataLength: usize(1024)) {
pub numBlocks: usize, // total number of elements per block in both dimensions
pub dim: usize, // number of elements in one dimension in one block
}

pub fn is_valid(matrix: &Matrix<f64>, data_length: usize) -> bool {
for i in 0..data_length {
for j in 0..data_length {
Expand All @@ -170,7 +170,7 @@ reactor Worker(threshold: usize(16384)) {
input data: {=(Arc<Matrix<f64>>, Arc<TransposedMatrix<f64>>, Arc<Mutex<Matrix<f64>>>)=};
input doWork: WorkItem;
output moreWork: {=[WorkItem; 8]=};

preamble {=
use crate::reactors::manager::WorkItem;
use crate::matrix::{Matrix, TransposedMatrix};
Expand All @@ -181,7 +181,7 @@ reactor Worker(threshold: usize(16384)) {
ctx.use_ref_opt(data, |(a, b, c)| {
self.A = a.clone();
self.B = b.clone();
self.C = c.clone();
self.C = c.clone();
});
=}

Expand Down Expand Up @@ -210,13 +210,14 @@ reactor Worker(threshold: usize(16384)) {
// otherwise we compute the result directly
let end_r = wi.srC + wi.dim;
let end_c = wi.scC + wi.dim;

let mut c = self.C.lock().unwrap();

for i in wi.srC..end_r {
for j in wi.scC..end_c {
for k in 0..wi.dim {
let v = self.A.get(i, wi.scA + k) * self.B.get(wi.srB + k, j);
let mut v = self.A.get(i, wi.scA + k) * self.B.get(wi.srB + k, j);
v += c.get(i, j);
c.set(i, j, v);
}
}
Expand Down
1 change: 1 addition & 0 deletions benchmark/runner/conf/default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
iterations: 12
threads: null
timeout: 1200
savina_path: "${oc.env:SAVINA_PATH}"
lf_path: "${oc.env:LF_PATH}"
continue_on_error: False
Expand Down
3 changes: 3 additions & 0 deletions benchmark/runner/conf/target/lf-c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ prepare: ["mkdir", "src"]
copy: ["cp", "-r", "${benchmark.targets.lf-c.copy_sources}", "src"]
gen: ["cog", "-r", "${args:benchmark.targets.lf-c.gen_args}",
"-D", "threads=${threads}",
"-D", "scheduler=${target.params.scheduler}",
"-D", "numIterations=${iterations}",
"-D", "threaded_runtime=True",
"src/${benchmark.targets.lf-c.lf_file}"]
compile: ["${lf_path}/bin/lfc", "src/${benchmark.targets.lf-c.lf_file}"]
run: ["bin/${benchmark.targets.lf-c.binary}"]
parser:
_target_: "parser.parse_lfc_output"
params:
scheduler: "GEDF_NP"
3 changes: 2 additions & 1 deletion org.lflang.lfc/src/org/lflang/lfc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public class Main {
* @author Marten Lohstroh <marten@berkeley.edu>
*/
enum CLIOption {
COMPILER(null, "target-compiler", true, false, "Target compiler to invoke.", true),
CLEAN("c", "clean", false, false, "Clean before building.", true),
COMPILER(null, "target-compiler", true, false, "Target compiler to invoke.", true),
EXTERNAL_RUNTIME_PATH(null, "external-runtime-path", true, false, "Specify an external runtime library to be used by the compiled binary.", true),
FEDERATED("f", "federated", false, false, "Treat main reactor as federated.", false),
HELP("h", "help", false, false, "Display this information.", true),
Expand All @@ -117,6 +117,7 @@ enum CLIOption {
QUIET("q", "quiet", false, false, "Suppress output of the target compiler and other commands", true),
RTI("r", "rti", true, false, "Specify the location of the RTI.", true),
RUNTIME_VERSION(null, "runtime-version", true, false, "Specify the version of the runtime library used for compiling LF programs.", true),
SCHEDULER("s", "scheduler", true, false, "Specify the runtime scheduler (if supported).", true),
THREADS("t", "threads", true, false, "Specify the default number of threads.", true),
VERSION(null, "version", false, false, "Print version inforomation.", false);

Expand Down
2 changes: 2 additions & 0 deletions org.lflang.tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ test {
events "passed", "skipped", "failed"
showStandardStreams = true
}
// Pass the scheduler property on to the Java VM
systemProperty 'scheduler', System.getProperty('scheduler')
// Suggested by Gradle documentation: https://guides.gradle.org/performance/#parallel_test_execution
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
useJUnitPlatform()
Expand Down
Loading

0 comments on commit a61b2c4

Please sign in to comment.