Skip to content

Commit ef57a23

Browse files
self-hosted (#335)
* self-hosted * skip patmos instalation for self-hosted * both self-hosted and github-hosted in parallel * bugfix * skip already cloned folder * zero init platform struct. * exit if make fails * rm previously built file * diagnosis prints * typo * throw added exit added cycle time added github_path * remove exit, so PATH is always set * force self-hosted to use fpga * check jtag * add quartus path to self-hosted path * update path for jtagconfig * run all tests * skip long tests for gh-hosted runner with emulator * edit s4noc_fed example to add new arg to LF_FEDERATE_BOOKKEEPING_INSTANCES * increase REACTION_QUEUE_SIZE * format and a cast * format * format * if statement instead of tenary * remove extra paranthesis * readability-implicit-bool-conversion,-warnings-as-errors fix
1 parent bfa1ccd commit ef57a23

17 files changed

Lines changed: 184 additions & 52 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Install Patmos (self-hosted)
2+
description: Install Patmos and dependencies for self-hosted runners (no sudo)
3+
inputs:
4+
clone-template:
5+
description: "Clone lf-patmos-template next to reactor-uc"
6+
required: false
7+
default: "true"
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Clone and build Patmos
12+
shell: bash
13+
run: |
14+
if [ ! -d "$HOME/t-crest" ]; then
15+
echo "Building Patmos..."
16+
mkdir -p ~/t-crest
17+
cd ~/t-crest
18+
git clone https://github.com/t-crest/patmos-misc.git misc
19+
./misc/build.sh -q
20+
else
21+
echo "t-crest already exists; skipping Patmos build"
22+
fi
23+
24+
echo "$HOME/t-crest/local/bin" >> $GITHUB_PATH
25+
26+
- name: Verify Patmos installation
27+
shell: bash
28+
run: |
29+
patmos-clang --version
30+
if [ $? -ne 0 ]; then
31+
echo "Patmos installation failed"
32+
exit 1
33+
fi
34+
35+
- name: Verify jtagconfig installation
36+
shell: bash
37+
run: |
38+
export PATH="$PATH:$HOME/intelFPGA_lite/22.1std/quartus/bin"
39+
echo "$HOME/intelFPGA_lite/22.1std/quartus/bin" >> $GITHUB_PATH
40+
echo PATH is $PATH
41+
echo GITHUB_PATH is $GITHUB_PATH
42+
lsusb
43+
jtagd --version
44+
jtagconfig -d
45+
jtagconfig --version
46+
if [ $? -ne 0 ]; then
47+
echo "jtagconfig installation failed"
48+
exit 1
49+
fi
50+
51+
- name: Clone template
52+
shell: bash
53+
run: |
54+
if [ -d "$GITHUB_WORKSPACE/../lf-patmos-template" ]; then
55+
echo "lf-patmos-template already exists; skipping clone"
56+
exit 0
57+
fi
58+
if [ "${{ inputs.clone-template }}" = "true" ]; then
59+
echo "Cloning lf-patmos-template (reactor-uc branch) as sibling of reactor-uc..."
60+
# Clone one level up from GITHUB_WORKSPACE (which is reactor-uc/)
61+
cd "$GITHUB_WORKSPACE/.."
62+
git clone --depth=1 --branch reactor-uc https://github.com/lf-lang/lf-patmos-template.git lf-patmos-template
63+
if [ ! -f "$GITHUB_WORKSPACE/../lf-patmos-template/MakefileTemplate" ]; then
64+
echo "lfc: error: Patmos template not found at: $GITHUB_WORKSPACE/../lf-patmos-template/MakefileTemplate";
65+
exit 1;
66+
fi
67+
echo "Template cloned successfully at $GITHUB_WORKSPACE/../lf-patmos-template"
68+
fi

.github/actions/patmos/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ runs:
3232
shell: bash
3333
run: |
3434
export PATH=$PATH:$HOME/t-crest/local/bin
35-
echo "PATH=$PATH:$HOME/t-crest/local/bin" >> "$GITHUB_ENV"
35+
echo "$HOME/t-crest/local/bin" >> $GITHUB_PATH
3636
echo $PATH
3737
mkdir ~/t-crest
3838
cd ~/t-crest

.github/workflows/patmos.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ on:
77

88
jobs:
99
ci:
10-
name: Build examples
11-
runs-on: ubuntu-24.04
10+
name: Build examples (${{ matrix.name }})
11+
runs-on: ${{ matrix.runsOn }}
12+
strategy:
13+
matrix:
14+
include:
15+
- name: self-hosted
16+
runsOn: [self-hosted]
17+
- name: ubuntu-24.04
18+
runsOn: ubuntu-24.04
1219
env:
1320
REACTOR_UC_PATH: ${{ github.workspace }}
1421
steps:
@@ -17,10 +24,19 @@ jobs:
1724
with:
1825
submodules: recursive
1926

20-
- name: Install dependencies
27+
- name: Install dependencies (self-hosted)
28+
if: ${{ matrix.name == 'self-hosted' }}
29+
uses: ./.github/actions/patmos-self-hosted
30+
31+
- name: Install dependencies (GitHub-hosted)
32+
if: ${{ matrix.name == 'ubuntu-24.04' }}
2133
uses: ./.github/actions/patmos
2234

2335
- name: Build examples
2436
working-directory: ${{ github.workspace }}/examples/patmos
2537
run: |
26-
./buildAll.sh
38+
if [ "${{ matrix.name }}" == "self-hosted" ]; then
39+
./buildAll.sh -s
40+
else
41+
./buildAll.sh
42+
fi

examples/esp-idf/buildAll.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ set -e
55
IDF_TARGET="esp32c6"
66
# List of folders
77
FOLDERS=("hello" "blink")
8-
8+
# Check if ESP-IDF is installed
9+
if [ -z "$IDF_PATH" ]; then
10+
echo "ESP-IDF is not installed. Skipping build."
11+
exit 0
12+
fi
913
# Iterate over each folder and execute the command
1014
for dir in "${FOLDERS[@]}"; do
1115
echo "Entering $dir"

examples/freertos/buildAll.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/bin/bash
22
set -e
3+
if [ -z "$PICO_SDK_PATH" ]; then
4+
echo "Error: PICO_SDK_PATH is not defined. Please set it before running this script."
5+
exit 0
6+
else
7+
# Set the target board
8+
PICO_BOARD="pico_w"
9+
PICO_FOLDER="pico"
10+
echo "Entering $PICO_FOLDER"
11+
pushd $PICO_FOLDER
312

4-
# Set the target board
5-
PICO_BOARD="pico_w"
6-
PICO_FOLDER="pico"
7-
echo "Entering $PICO_FOLDER"
8-
pushd $PICO_FOLDER
9-
10-
rm -rf build && mkdir build && cd build
11-
cmake -DPICO_BOARD=pico_w -DPLATFORM=FREERTOS ..
12-
cmake --build . -j
13-
popd
13+
rm -rf build && mkdir build && cd build
14+
cmake -DPICO_BOARD=pico_w -DPLATFORM=FREERTOS ..
15+
cmake --build . -j
16+
popd
17+
fi

examples/patmos/buildAll.sh

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
#!/bin/bash
22

33
set -e
4+
if [ -z "$REACTOR_UC_PATH" ]; then
5+
echo "Error: REACTOR_UC_PATH is not set." >&2
6+
exit 1
7+
fi
8+
while getopts ":s" opt; do
9+
case $opt in
10+
s) SELF_HOSTED=true;;
11+
:) echo "Option -$OPTARG requires an argument." >&2; exit 1;;
12+
\?) echo "Invalid option -$OPTARG" >&2; exit 1;;
13+
esac
14+
done
415

516
if ! command -v pasim &> /dev/null; then
617
echo "Error: pasim command not found. Please ensure it is installed and available in your PATH."
718
else
819
# Iterate over each folder and execute the command
920
for dir in ./*; do
10-
if [ -d "$dir" ]; then
11-
# Skip directories that should not be built via this runner
12-
case "$dir" in
13-
"./s4noc_fed")
14-
echo "Skipping $dir (disabled for buildAll.sh)"
15-
continue
16-
;;
17-
esac
18-
19-
echo "Entering $dir"
20-
pushd "$dir"
21-
chmod +x build.sh
22-
./build.sh
23-
popd
21+
if [ -d "$dir" ]; then
22+
echo "Entering $dir"
23+
pushd "$dir"
24+
chmod +x build.sh
25+
if [ "$SELF_HOSTED" = true ]; then
26+
echo "Running build.sh for self-hosted runner"
27+
./build.sh -f
28+
else
29+
echo "Running build.sh for non-self-hosted runner"
30+
if [ "$dir" = "./s4noc_fed" ]; then
31+
echo "Skipping $dir for non-self-hosted runner"
32+
popd
33+
continue
2434
fi
35+
./build.sh -e
36+
fi
37+
popd
38+
fi
2539
done
2640
fi

examples/patmos/s4noc_fed/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ make clean
3636
make all -C ./sender
3737
make all -C ./receiver
3838
echo "Linking sender and receiver to create executable"
39-
make all
39+
make all || exit 1
4040

4141
read -n 1 -t 5 -p "Choose action: [e]mulate or [f]pga? (default: $DEF_TOOL) " action
4242
action=${action:-$DEF_TOOL}

examples/patmos/s4noc_fed/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "sender/sender.h"
66
#include "receiver/receiver.h"
7+
#include <machine/rtc.h>
78

89
static void* receiver_thread(void* arg) {
910
(void)arg;
@@ -20,7 +21,7 @@ static void* sender_thread(void* arg) {
2021
int main(void) {
2122
pthread_t receiver_tid;
2223
pthread_t sender_tid;
23-
24+
long long cycles_before = get_cpu_cycles();
2425
printf("Starting S4NOC Federated Example\n");
2526

2627
pthread_create(&receiver_tid, NULL, receiver_thread, NULL);
@@ -31,6 +32,7 @@ int main(void) {
3132
pthread_join(receiver_tid, NULL);
3233
pthread_join(sender_tid, NULL);
3334

34-
printf("All federates finished.\n");
35+
long long cycles_after = get_cpu_cycles();
36+
printf("Total CPU cycles: %lld\n", cycles_after - cycles_before);
3537
return 0;
3638
}

examples/patmos/s4noc_fed/receiver/receiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ typedef struct {
186186
Reactor super;
187187
LF_CHILD_REACTOR_INSTANCE(Receiver, receiver, NUM_CHILD_REACTORS); // Child receiver reactor
188188
LF_FEDERATED_CONNECTION_BUNDLE_INSTANCE(Receiver, Sender); // Federated connection to sender
189-
LF_FEDERATE_BOOKKEEPING_INSTANCES(NUM_BUNDLES);
189+
LF_FEDERATE_BOOKKEEPING_INSTANCES(NUM_BUNDLES, 0);
190190
LF_CHILD_INPUT_SOURCES(receiver, in, NUM_CHILD_REACTORS, NUM_CHILD_REACTORS, NUM_INPUT_SOURCES);
191191
LF_DEFINE_STARTUP_COORDINATOR(Receiver); // Startup coordination
192192
LF_DEFINE_CLOCK_SYNC(Receiver); // Clock synchronization

examples/patmos/s4noc_fed/sender/sender.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ static pthread_mutex_t uart_lock = PTHREAD_MUTEX_INITIALIZER;
3535
#define EVENT_QUEUE_SIZE 1
3636
// Size of system event queue (startup, timers, etc.)
3737
#define SYSTEM_EVENT_QUEUE_SIZE 11
38-
// Size of reaction queue for scheduling
39-
#define REACTION_QUEUE_SIZE 1
38+
// Size of reaction queue for scheduling.
39+
// We need two levels: sender reaction and federated flush reaction.
40+
#define REACTION_QUEUE_SIZE 2
4041
// Scheduler timeout duration
4142
#define TIMEOUT SEC(SHUTDOWN_TIMEOUT_SEC)
4243
// Keep scheduler alive
@@ -177,7 +178,7 @@ typedef struct {
177178
Reactor super;
178179
LF_CHILD_REACTOR_INSTANCE(Sender, sender, NUM_CHILD_REACTORS); // Child sender reactor
179180
LF_FEDERATED_CONNECTION_BUNDLE_INSTANCE(Sender, Receiver); // Federated connection to receiver
180-
LF_FEDERATE_BOOKKEEPING_INSTANCES(NUM_BUNDLES);
181+
LF_FEDERATE_BOOKKEEPING_INSTANCES(NUM_BUNDLES, NUM_OUTPUT_CONNECTIONS);
181182
LF_CHILD_OUTPUT_CONNECTIONS(sender, out, NUM_CHILD_REACTORS, NUM_CHILD_REACTORS, NUM_OUTPUT_CONNECTIONS);
182183
LF_CHILD_OUTPUT_EFFECTS(sender, out, NUM_CHILD_REACTORS, NUM_CHILD_REACTORS, 0);
183184
LF_CHILD_OUTPUT_OBSERVERS(sender, out, NUM_CHILD_REACTORS, NUM_CHILD_REACTORS, 0);

0 commit comments

Comments
 (0)