From ceec1e9b8144d7811d8cd3f6cd3108fa0eb34e2b Mon Sep 17 00:00:00 2001 From: Samuel Berkun Date: Thu, 1 Feb 2024 01:21:52 -0800 Subject: [PATCH] initial draft for multithreaded rp2040 --- .../java/org/lflang/generator/c/CCmakeGenerator.java | 9 +++++---- .../org/lflang/target/property/PlatformProperty.java | 4 ++-- .../org/lflang/target/property/type/PlatformType.java | 2 +- core/src/main/resources/lib/c/reactor-c | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java index 7212e448a4..0316f78dbf 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -346,7 +346,8 @@ CodeBuilder generateCMakeCode( } if (!targetConfig.get(SingleThreadedProperty.INSTANCE) - && platformOptions.platform() != Platform.ZEPHYR) { + && platformOptions.platform() != Platform.ZEPHYR + && platformOptions.platform() != Platform.RP2040) { // If threaded computation is requested, add the threads option. cMakeCode.pr("# Find threads and link to it"); cMakeCode.pr("find_package(Threads REQUIRED)"); @@ -504,9 +505,9 @@ private static String setUpMainTargetRp2040( code.pr("pico_sdk_init()"); code.newLine(); code.pr("add_subdirectory(core)"); - code.pr("target_link_libraries(core PUBLIC pico_stdlib)"); - code.pr("target_link_libraries(core PUBLIC pico_multicore)"); - code.pr("target_link_libraries(core PUBLIC pico_sync)"); + code.pr("target_link_libraries(reactor-c PUBLIC pico_stdlib)"); + code.pr("target_link_libraries(reactor-c PUBLIC pico_multicore)"); + code.pr("target_link_libraries(reactor-c PUBLIC pico_sync)"); code.newLine(); code.pr("set(LF_MAIN_TARGET " + executableName + ")"); diff --git a/core/src/main/java/org/lflang/target/property/PlatformProperty.java b/core/src/main/java/org/lflang/target/property/PlatformProperty.java index 4e5ea72503..178cc465f0 100644 --- a/core/src/main/java/org/lflang/target/property/PlatformProperty.java +++ b/core/src/main/java/org/lflang/target/property/PlatformProperty.java @@ -75,10 +75,10 @@ protected PlatformOptions fromString(String string, MessageReporter reporter) { @Override public void validate(TargetConfig config, MessageReporter reporter) { var singleThreaded = config.get(SingleThreadedProperty.INSTANCE); - if (!singleThreaded && config.get(PlatformProperty.INSTANCE).platform == Platform.RP2040) { + if (!singleThreaded && !config.get(PlatformProperty.INSTANCE).platform.isMultiThreaded()) { reporter .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) - .error("Platform " + Platform.RP2040 + " does not support threading."); + .error("Platform " + config.get(PlatformProperty.INSTANCE).platform + " does not support threading."); } } diff --git a/core/src/main/java/org/lflang/target/property/type/PlatformType.java b/core/src/main/java/org/lflang/target/property/type/PlatformType.java index 6382291c61..49743bd387 100644 --- a/core/src/main/java/org/lflang/target/property/type/PlatformType.java +++ b/core/src/main/java/org/lflang/target/property/type/PlatformType.java @@ -14,7 +14,7 @@ public enum Platform { AUTO, ARDUINO, // FIXME: not multithreaded NRF52("Nrf52", true), - RP2040("Rp2040", false), + RP2040("Rp2040", true), LINUX("Linux", true), MAC("Darwin", true), ZEPHYR("Zephyr", true), diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 188fb3c983..b9e1d9a8a4 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 188fb3c983aac9ea7bcafa4e5172daaa5f8a883d +Subproject commit b9e1d9a8a4cb64f5aac302bd202cc0b5dbfccc0e