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

Support for FlexPRET platform #2262

Merged
merged 52 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1db738c
Add support for FlexPRET
magnmaeh Apr 21, 2024
8b50948
Remove printing of board properties
magnmaeh Apr 21, 2024
f688bd0
Add check on requested threads vs. number of HW threads on FlexPRET, …
magnmaeh Apr 22, 2024
38c83ed
Add support for port property.
magnmaeh Apr 23, 2024
cb9e163
Add custom install for FlexPRET; add validation for FlexPRET.
magnmaeh Apr 24, 2024
d492a00
Add check on default value for and PlatformOptions. Also add FlexPR…
magnmaeh Apr 25, 2024
1a9510a
Use Option<T> for PlatformOptions and change code to be compatible wi…
magnmaeh May 1, 2024
dde2b88
Add execution of generated bash script at end of lfc. Currently does …
magnmaeh May 1, 2024
eb831ef
Remove warnings on unused variables in generated code; fix flash opti…
magnmaeh May 2, 2024
ace6553
Add tests for FlexPRET - concurrent is failing for some reason...
magnmaeh May 2, 2024
01fce38
Update reactor-c
magnmaeh May 2, 2024
6c30ff0
Bump reactor-c so tests pass
magnmaeh May 3, 2024
cd8e023
Add info message when FP_SDK_FPGA_INTERFACE_PROGRAM is set because LF…
magnmaeh May 3, 2024
f856e38
Add CI tests.
magnmaeh May 3, 2024
6eced85
Bump reactor-c
magnmaeh May 4, 2024
546248e
Merge branch 'master' into add-flexpret-support
magnmaeh May 4, 2024
05672bc
Merge branch 'master' into add-flexpret-support
magnmaeh May 4, 2024
cdc0702
Fix issue reported by CI
magnmaeh May 4, 2024
30b7fa8
Merge branch 'add-flexpret-support' of github.com:magnmaeh/lingua-fra…
magnmaeh May 4, 2024
7f96f28
Apply spotless
magnmaeh May 4, 2024
5291921
Another formatting.
magnmaeh May 4, 2024
0823188
Bump reactor-c to solve Arduino CI issue
magnmaeh May 4, 2024
b0fb028
Bump reactor-c and fix bug in FlexPRET flash command
magnmaeh May 5, 2024
6f3c71f
Fix format violations
magnmaeh May 5, 2024
3f4b96d
Add FlexPRET tests to CI
magnmaeh May 5, 2024
0c2c1ec
Fix minor bug with setting env variable
magnmaeh May 10, 2024
e718747
Attempt to resolve CI issues
magnmaeh May 10, 2024
9db1410
Merge branch 'master' into add-flexpret-support
magnmaeh May 10, 2024
439a4d7
Apply formatter
magnmaeh May 10, 2024
f8965b5
Bump reactor-c
magnmaeh May 14, 2024
273bf4a
Update branch with master
magnmaeh May 14, 2024
4409f60
Merge branch 'master' into add-flexpret-support
magnmaeh May 15, 2024
f4346f2
Bump reactor-c
magnmaeh May 18, 2024
d6a5aa6
Merge remote-tracking branch 'origin/master' into add-flexpret-support
magnmaeh May 18, 2024
908383c
Add all-embedded.yml top-level workflow
magnmaeh May 18, 2024
b4bf936
Update setup-flexpret/action.yml
magnmaeh May 18, 2024
31019be
Update setup-flexpret/action.yml
magnmaeh May 18, 2024
1b80019
Update setup-flexpret/action.yml
magnmaeh May 18, 2024
5a72997
Update c-flexpret-tests.yml
magnmaeh May 18, 2024
5140709
Update CI
magnmaeh May 18, 2024
ba1f764
Update CI
magnmaeh May 18, 2024
980f30e
Formatting
magnmaeh May 18, 2024
4a8c7e0
Apply suggestions from code review
lhstrh May 19, 2024
2c5a495
Change install of riscv compiler for CI
magnmaeh May 19, 2024
e896e16
Merge branch 'add-flexpret-support' of github.com:magnmaeh/lingua-fra…
magnmaeh May 19, 2024
c956598
Remove redundant code
magnmaeh May 19, 2024
1c8c1dc
Apply suggestions from code review
lhstrh May 21, 2024
59545e4
Remove unecessary exceptions in FlexPRETUtil.java
magnmaeh May 21, 2024
c5922c9
Merge branch 'add-flexpret-support' of github.com:magnmaeh/lingua-fra…
magnmaeh May 21, 2024
5597205
Remove use of FP_SDK_FPGA_INTERFACE_PROGRAM
magnmaeh May 21, 2024
602404e
Merge branch 'master' into add-flexpret-support
magnmaeh May 21, 2024
228d5b1
Bump reactor-c
erlingrj May 22, 2024
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
48 changes: 48 additions & 0 deletions .github/actions/setup-flexpret/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Install FlexPRET and dependencies (Linux only)
description: Install FlexPRET and dependencies (Linux only)
runs:
using: "composite"
steps:
- name: Setup
run: |
# Clone the FlexPRET repository
git clone --recurse-submodules https://github.com/pretis/flexpret

# This rest is copied directly from FlexPRET's `azure-pipelines.yml`

# Ubuntu 20.04 only has Verilator 4.028 but we neeed a more modern version
# so we do not use 'sudo apt-get install -y -qq verilator' here.
wget -q https://github.com/sifive/verilator/releases/download/4.036-0sifive2/verilator_4.036-0sifive2_amd64.deb -O verilator.deb
sudo dpkg -i verilator.deb

# Install riscv compiler
wget -q https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.3.0-2.3/xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz -O riscv.tgz
magnmaeh marked this conversation as resolved.
Show resolved Hide resolved
tar zxf riscv.tgz
mv xpack-riscv-none-embed-gcc-8.3.0-2.3 ~/riscv-embed-gcc
ln -s ~/riscv-embed-gcc/bin/riscv-none-embed-as ~/riscv-embed-gcc/bin/riscv32-unknown-elf-as
ln -s ~/riscv-embed-gcc/bin/riscv-none-embed-ar ~/riscv-embed-gcc/bin/riscv32-unknown-elf-ar
ln -s ~/riscv-embed-gcc/bin/riscv-none-embed-gcc ~/riscv-embed-gcc/bin/riscv32-unknown-elf-gcc
ln -s ~/riscv-embed-gcc/bin/riscv-none-embed-ld ~/riscv-embed-gcc/bin/riscv32-unknown-elf-ld
ln -s ~/riscv-embed-gcc/bin/riscv-none-embed-objdump ~/riscv-embed-gcc/bin/riscv32-unknown-elf-objdump
ln -s ~/riscv-embed-gcc/bin/riscv-none-embed-objcopy ~/riscv-embed-gcc/bin/riscv32-unknown-elf-objcopy

# Update submodules
git submodule update --init --recursive

# Save location of RISC-V compiler to reuse later
echo "FP_RISCV_COMPILER=~/riscv-embed-gcc" >> "$GITHUB_ENV"
shell: bash
- name: Build FlexPRET and install to SDK
run: |
# Step into cloned directory
cd flexpret

# Save pwd to environment variable so we can find `env.bash` in later steps
echo "FP_DIR=$(pwd)" >> "$GITHUB_ENV"

# Source environment
source env.bash

# Build FlexPRET's high memory configuration and install it to SDK
cd $FP_PATH && cmake -DFP_CONFIG=highmem -B build && cd build && make all install
shell: bash
33 changes: 33 additions & 0 deletions .github/workflows/all-embedded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Tests for embedded platforms
name: CI (embedded platforms)

on:
schedule:
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
# * is a special character in YAML so you have to quote this string
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
- cron: '0 8 * * 6'
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:
push:
branches:
- master
pull_request:
types: [synchronize, opened, reopened, ready_for_review, converted_to_draft]
merge_group:

env:
# 2020.11
vcpkgGitRef: 0bf3923f9fab4001c00f0f429682a0853b5749e0

concurrency:
group: all-embedded-${{ github.ref }}-${{ github.event_path }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
check-diff:
uses: ./.github/workflows/check-diff.yml

c-embedded:
uses: ./.github/workflows/c-embedded.yml
needs: check-diff
if: ${{ needs.check-diff.outputs.run_c == 'true' }}

# Add more languages if supported
28 changes: 28 additions & 0 deletions .github/workflows/c-embedded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: C embedded

on:
workflow_dispatch:
workflow_call:

env:
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
# 2020.11
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
vcpkgGitRef: 0bf3923f9fab4001c00f0f429682a0853b5749e0
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
lhstrh marked this conversation as resolved.
Show resolved Hide resolved

concurrency:
group: c-embedded-${{ github.ref }}-${{ github.event_path }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
# Run the C Arduino integration tests.
arduino:
uses: ./.github/workflows/c-arduino-tests.yml
with:
all-platforms: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}

# Run the C Zephyr integration tests.
zephyr:
uses: ./.github/workflows/c-zephyr-tests.yml

# Run the C FlexPRET integration tests.
flexpret:
uses: ./.github/workflows/c-flexpret-tests.yml
58 changes: 58 additions & 0 deletions .github/workflows/c-flexpret-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: C FlexPRET tests

on:
workflow_call:
inputs:
compiler-ref:
required: false
type: string
runtime-ref:
required: false
type: string
use-cpp:
required: false
type: boolean
default: false
scheduler:
required: false
type: string
all-platforms:
required: false
default: true
type: boolean

jobs:
flexpret-tests:
runs-on: ubuntu-latest
steps:
- name: Check out lingua-franca repository
uses: actions/checkout@v3
with:
repository: lf-lang/lingua-franca
submodules: true
ref: ${{ inputs.compiler-ref }}
fetch-depth: 0
- name: Prepare build environment
uses: ./.github/actions/prepare-build-env
- name: Setup and build FlexPRET
uses: ./.github/actions/setup-flexpret
- name: Check out specific ref of reactor-c
uses: actions/checkout@v3
with:
repository: lf-lang/reactor-c
path: core/src/main/resources/lib/c/reactor-c
ref: ${{ inputs.runtime-ref }}
if: ${{ inputs.runtime-ref }}
- name: Run FlexPRET smoke tests
run: |
cd "$FP_DIR" && source env.bash && cd -
export RISCV_TOOL_PATH_PREFIX=$FP_RISCV_COMPILER
./gradlew core:integrationTest \
--tests org.lflang.tests.runtime.CFlexPRETTest.* \
core:integrationTestCodeCoverageReport
rm -rf test/C/src-gen
- name: Report to CodeCov
uses: ./.github/actions/report-code-coverage
with:
files: core/build/reports/jacoco/integrationTestCodeCoverageReport/integrationTestCodeCoverageReport.xml
if: ${{ github.repository == 'lf-lang/lingua-franca' }}
10 changes: 0 additions & 10 deletions .github/workflows/only-c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ jobs:
with:
target: "C"

# Run the C Arduino integration tests.
arduino:
uses: ./.github/workflows/c-arduino-tests.yml
with:
all-platforms: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}

# Run the C Zephyr integration tests.
zephyr:
uses: ./.github/workflows/c-zephyr-tests.yml

# Run the CCpp integration tests.
ccpp:
uses: ./.github/workflows/c-tests.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static boolean compatibleWithThreadingOff(TestCategory category) {

// CONCURRENT, FEDERATED, DOCKER_FEDERATED, DOCKER
// are not compatible with single-threaded execution.
// ARDUINO and ZEPHYR have their own test suites, so we don't need to rerun.
// ARDUINO, ZEPHYR and FLEXPRET have their own test suites, so we don't need to rerun.
boolean excluded =
category == TestCategory.CONCURRENT
|| category == TestCategory.SERIALIZATION
Expand All @@ -244,7 +244,8 @@ public static boolean compatibleWithThreadingOff(TestCategory category) {
|| category == TestCategory.VERIFIER
|| category == TestCategory.ZEPHYR_UNTHREADED
|| category == TestCategory.ZEPHYR_BOARDS
|| category == TestCategory.ZEPHYR_THREADED;
|| category == TestCategory.ZEPHYR_THREADED
|| category == TestCategory.FLEXPRET;

// SERIALIZATION and TARGET tests are excluded on Windows.
excluded |= isWindows() && category == TestCategory.TARGET;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*************
* Copyright (c) 2023, The University of California at Berkeley.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************/
package org.lflang.tests.runtime;

import java.util.List;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.lflang.target.Target;
import org.lflang.tests.Configurators;
import org.lflang.tests.TestBase;
import org.lflang.tests.TestRegistry.TestCategory;
import org.lflang.tests.Transformers;

public class CFlexPRETTest extends TestBase {

public CFlexPRETTest() {
super(Target.C);
}

@Test
public void buildFlexPRETConcurrent() {
Assumptions.assumeTrue(isLinux(), "FlexPRET tests only supported on Linux");
super.runTestsFor(
List.of(Target.C),
"Build concurrent tests for FlexPRET.",
TestCategory.CONCURRENT::equals,
Transformers::noChanges,
Configurators::makeFlexPRETCompatible,
TestLevel.BUILD,
false);
}

@Test
public void buildFlexPRETBasicTestsUnthreaded() {
Assumptions.assumeTrue(isLinux(), "FlexPRET tests only supported on Linux");
super.runTestsFor(
List.of(Target.C),
"Build basic tests for FlexPRET in single threaded mode.",
TestCategory.BASIC::equals,
Transformers::noChanges,
Configurators::makeFlexPRETCompatibleUnthreaded,
TestLevel.BUILD,
false);
}

@Test
public void buildFlexPRETBasicTests() {
Assumptions.assumeTrue(isLinux(), "FlexPRET tests only supported on Linux");
super.runTestsFor(
List.of(Target.C),
"Build basic tests for FlexPRET.",
TestCategory.BASIC::equals,
Transformers::noChanges,
Configurators::makeFlexPRETCompatible,
TestLevel.BUILD,
false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,21 @@ public static String generateFederateNeighborStructure(FederateInstance federate
return code.toString();
}

public static String surroundWithIfElseFederated(String insideIf, String insideElse) {
if (insideElse == null) {
return surroundWithIfFederated(insideIf);
} else {
return """
#ifdef FEDERATED
%s
#else
%s
#endif // FEDERATED
"""
.formatted(insideIf, insideElse);
}
}

/**
* Surround {@code code} with blocks to ensure that code only executes if the program is
* federated.
Expand All @@ -465,6 +480,21 @@ public static String surroundWithIfFederated(String code) {
.formatted(code);
}

public static String surroundWithIfElseFederatedCentralized(String insideIf, String insideElse) {
if (insideElse == null) {
return surroundWithIfFederatedCentralized(insideIf);
} else {
return """
#ifdef FEDERATED_CENTRALIZED
%s
#else
%s
#endif // FEDERATED_CENTRALIZED
"""
.formatted(insideIf, insideElse);
}
}

/**
* Surround {@code code} with blocks to ensure that code only executes if the program is federated
* and has a centralized coordination.
Expand Down
Loading
Loading