Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ public static boolean compatibleWithThreadingOff(TestCategory category) {
|| category == TestCategory.ZEPHYR_BOARDS
|| category == TestCategory.ZEPHYR_THREADED
|| category == TestCategory.FLEXPRET
|| category == TestCategory.PATMOS;
|| category == TestCategory.PATMOS_THREADED
|| category == TestCategory.PATMOS_UNTHREADED;

// 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
Expand Up @@ -49,7 +49,8 @@ private static boolean isExcludedFromCCpp(TestCategory category) {
excluded |= category == TestCategory.ZEPHYR_THREADED;
excluded |= category == TestCategory.ZEPHYR_BOARDS;
excluded |= category == TestCategory.ARDUINO;
excluded |= category == TestCategory.PATMOS;
excluded |= category == TestCategory.PATMOS_THREADED;
excluded |= category == TestCategory.PATMOS_UNTHREADED;
excluded |= category == TestCategory.NO_INLINING;
excluded |= category == TestCategory.VERIFIER;
return !excluded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ protected ProcessBuilder getExecCommand(LFTest test) throws TestError {
+ " in directory: "
+ command.directory());

// Run the full command to check if it executes correctly
try {
Process testProc =
new ProcessBuilder(fullCommand).directory(command.directory()).inheritIO().start();
int testExit = testProc.waitFor();
System.out.println("DEBUG: Test command exited with code: " + testExit);
} catch (Exception e) {
System.out.println("DEBUG: Exception while running full command: " + e.getMessage());
}

// Create the ProcessBuilder
ProcessBuilder processBuilder = new ProcessBuilder(fullCommand).directory(command.directory());

Expand All @@ -92,13 +82,26 @@ protected ProcessBuilder getExecCommand(LFTest test) throws TestError {
return processBuilder;
}

@Test
public void runPatmosThreadedTests() {
Assumptions.assumeTrue(isLinux(), "Patmos tests only run on Linux");
super.runTestsFor(
List.of(Target.C),
Message.DESC_PATMOS,
TestCategory.PATMOS_THREADED::equals,
Transformers::noChanges,
Configurators::makePatmosCompatible,
TestLevel.EXECUTION,
false);
}

@Test
public void runPatmosUnthreadedTests() {
Assumptions.assumeTrue(isLinux(), "Patmos tests only run on Linux");
super.runTestsFor(
List.of(Target.C),
Message.DESC_PATMOS,
TestCategory.PATMOS::equals,
TestCategory.PATMOS_UNTHREADED::equals,
Transformers::noChanges,
Configurators::makePatmosCompatibleUnthreaded,
TestLevel.EXECUTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public static boolean makeFlexPRETCompatibleUnthreaded(TargetConfig config) {
}

public static boolean makePatmosCompatible(TargetConfig config) {
// Patmos emulator runs are significantly slower with debug-level runtime logs.
LoggingProperty.INSTANCE.override(config, LogLevel.WARN);

/**
* Patmos has a maximum of eight hardware threads; override the chosen number of worker threads
* to be 0 (meaning run-time selects it).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ public enum TestCategory {
ZEPHYR_UNTHREADED(false, "zephyr" + File.separator + "unthreaded", TestLevel.BUILD),
ZEPHYR_BOARDS(false, "zephyr" + File.separator + "boards", TestLevel.BUILD),
FLEXPRET(false, "flexpret", TestLevel.BUILD),
PATMOS(false, "patmos", TestLevel.EXECUTION),
PATMOS_THREADED(false, "patmos" + File.separator + "threaded", TestLevel.EXECUTION),
PATMOS_UNTHREADED(false, "patmos" + File.separator + "unthreaded", TestLevel.EXECUTION),
VERIFIER(false, "verifier", TestLevel.EXECUTION),
TARGET(false, "", TestLevel.EXECUTION);

Expand Down
28 changes: 28 additions & 0 deletions test/C/src/patmos/threaded/HelloPatmosMultiCore.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Test multi-threaded execution on Patmos with multiple workers
target C {
platform: "Patmos",
workers: 2
}

reactor Worker(id: int = 0) {
reaction(startup) {=
printf("Worker %d starting on Patmos\n", self->id);
=}

reaction(shutdown) {=
printf("Worker %d shutting down\n", self->id);
=}
}

main reactor {
w1 = new Worker(id=1)
w2 = new Worker(id=2)

reaction(startup) {=
printf("MultiCore Patmos test started\n");
=}

reaction(shutdown) {=
printf("MultiCore Patmos test completed\n");
=}
}
48 changes: 48 additions & 0 deletions test/C/src/patmos/threaded/PatmosMultiCoreSync.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Test multi-threaded synchronization on Patmos with message passing
target C {
platform: "Patmos",
workers: 2,
timeout: 10 msec
}

reactor Producer {
output out: int
timer t(0, 2 msec)
state count: int = 0

reaction(t) -> out {=
if (self->count < 3) {
lf_set(out, self->count);
self->count++;
}
=}
}

reactor Consumer {
input in: int
state last_received: int = -1

reaction(in) {=
self->last_received = in->value;
printf("Consumer received: %d\n", in->value);
=}

reaction(shutdown) {=
printf("Last received value: %d\n", self->last_received);
=}
}

main reactor {
producer = new Producer()
consumer = new Consumer()

producer.out -> consumer.in

reaction(startup) {=
printf("MultiCore Patmos synchronization test started\n");
=}

reaction(shutdown) {=
printf("MultiCore Patmos synchronization test completed\n");
=}
}
File renamed without changes.
Loading