From 13018cf894338040742661520fa2b91181b900d0 Mon Sep 17 00:00:00 2001 From: Samuel Berkun Date: Thu, 1 Feb 2024 01:21:52 -0800 Subject: [PATCH 1/4] initial draft for multithreaded rp2040 --- .../lflang/generator/c/CCmakeGenerator.java | 9 ++-- .../target/property/PlatformProperty.java | 52 +++++++++++++++++++ .../target/property/type/PlatformType.java | 2 +- core/src/main/resources/lib/c/reactor-c | 2 +- 4 files changed, 59 insertions(+), 6 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 4349b91dec..55bfc0e176 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -394,7 +394,8 @@ CodeBuilder generateCMakeCode( if (!targetConfig.get(SingleThreadedProperty.INSTANCE) && platformOptions.platform() != Platform.ZEPHYR - && platformOptions.platform() != Platform.FLEXPRET) { + && platformOptions.platform() != Platform.FLEXPRET + && 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)"); @@ -558,9 +559,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 ec9d97e0d7..3e979090b1 100644 --- a/core/src/main/java/org/lflang/target/property/PlatformProperty.java +++ b/core/src/main/java/org/lflang/target/property/PlatformProperty.java @@ -190,6 +190,58 @@ private void validateZephyr(TargetConfig config, MessageReporter reporter) { } } + private void validateFlexPRET(TargetConfig config, MessageReporter reporter) { + var platform = config.get(PlatformProperty.INSTANCE); + var board = platform.board(); + if (board.setByUser()) { + if (!board.value().equals("emulator") && !board.value().equals("fpga")) { + reporter + .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) + .error( + "Only \"emulator\" and \"fpga\" are valid options for board property. Got " + + board + + "."); + } + + // Do validation specific to emulator + if (board.value().equals("emulator")) { + if (platform.port().setByUser()) { + reporter + .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) + .warning("Port property ignored for emulator"); + } + if (platform.baudRate().setByUser()) { + reporter + .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) + .warning("Baudrate property ignored for emulator"); + } + } else { + if (platform.baudRate().setByUser()) { + reporter + .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) + .error( + "Baudrate property is entirely controlled by FlexPRET's SDK and cannot be set by" + + " the user"); + } + } + } + } + + private void validateZephyr(TargetConfig config, MessageReporter reporter) { + var platform = config.get(PlatformProperty.INSTANCE); + var singleThreaded = config.get(SingleThreadedProperty.INSTANCE); + + if (singleThreaded) { + if (platform.userThreads().value() > 0) { + reporter + .nowhere() + .warning( + "Specifying user threads is only for threaded Lingua Franca on the Zephyr platform." + + " This option will be ignored."); + } + } + } + @Override public Element toAstElement(PlatformOptions value) { Element e = LfFactory.eINSTANCE.createElement(); 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 56715c2a9c..8ab00037e0 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 c7583dcd64..5d1f1a3db4 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit c7583dcd64f0726fea898b118cb00e853251de42 +Subproject commit 5d1f1a3db4205aefc3334df09c8e059239090143 From d87e426f91bf72787d763af822fc163349790d41 Mon Sep 17 00:00:00 2001 From: Samuel Berkun Date: Sat, 25 May 2024 05:08:05 -0700 Subject: [PATCH 2/4] rebase mistake --- .../target/property/PlatformProperty.java | 52 ------------------- 1 file changed, 52 deletions(-) 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 3e979090b1..ec9d97e0d7 100644 --- a/core/src/main/java/org/lflang/target/property/PlatformProperty.java +++ b/core/src/main/java/org/lflang/target/property/PlatformProperty.java @@ -190,58 +190,6 @@ private void validateZephyr(TargetConfig config, MessageReporter reporter) { } } - private void validateFlexPRET(TargetConfig config, MessageReporter reporter) { - var platform = config.get(PlatformProperty.INSTANCE); - var board = platform.board(); - if (board.setByUser()) { - if (!board.value().equals("emulator") && !board.value().equals("fpga")) { - reporter - .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) - .error( - "Only \"emulator\" and \"fpga\" are valid options for board property. Got " - + board - + "."); - } - - // Do validation specific to emulator - if (board.value().equals("emulator")) { - if (platform.port().setByUser()) { - reporter - .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) - .warning("Port property ignored for emulator"); - } - if (platform.baudRate().setByUser()) { - reporter - .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) - .warning("Baudrate property ignored for emulator"); - } - } else { - if (platform.baudRate().setByUser()) { - reporter - .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) - .error( - "Baudrate property is entirely controlled by FlexPRET's SDK and cannot be set by" - + " the user"); - } - } - } - } - - private void validateZephyr(TargetConfig config, MessageReporter reporter) { - var platform = config.get(PlatformProperty.INSTANCE); - var singleThreaded = config.get(SingleThreadedProperty.INSTANCE); - - if (singleThreaded) { - if (platform.userThreads().value() > 0) { - reporter - .nowhere() - .warning( - "Specifying user threads is only for threaded Lingua Franca on the Zephyr platform." - + " This option will be ignored."); - } - } - } - @Override public Element toAstElement(PlatformOptions value) { Element e = LfFactory.eINSTANCE.createElement(); From 2de8269498b9d1f5575cb75bb01fc60d084a9514 Mon Sep 17 00:00:00 2001 From: Samuel Berkun Date: Sat, 25 May 2024 05:17:02 -0700 Subject: [PATCH 3/4] remove single-thread check (again) --- .../org/lflang/target/property/PlatformProperty.java | 12 ------------ 1 file changed, 12 deletions(-) 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 ec9d97e0d7..12399319f7 100644 --- a/core/src/main/java/org/lflang/target/property/PlatformProperty.java +++ b/core/src/main/java/org/lflang/target/property/PlatformProperty.java @@ -115,9 +115,6 @@ protected PlatformOptions fromString(String string, MessageReporter reporter) { public void validate(TargetConfig config, MessageReporter reporter) { var platform = config.get(PlatformProperty.INSTANCE).platform; switch (platform) { - case RP2040: - validateRP2040(config, reporter); - break; case FLEXPRET: validateFlexPRET(config, reporter); break; @@ -129,15 +126,6 @@ public void validate(TargetConfig config, MessageReporter reporter) { } } - private void validateRP2040(TargetConfig config, MessageReporter reporter) { - var singleThreaded = config.get(SingleThreadedProperty.INSTANCE); - if (!singleThreaded) { - reporter - .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) - .error("Platform " + Platform.RP2040 + " does not support threading."); - } - } - private void validateFlexPRET(TargetConfig config, MessageReporter reporter) { var platform = config.get(PlatformProperty.INSTANCE); var board = platform.board(); From 8eb0a1524605f27455bef71a6e61062d9bd8bc53 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 5 Jun 2024 00:24:14 -0700 Subject: [PATCH 4/4] Update reactor-cpp submodule --- core/src/main/resources/lib/cpp/reactor-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/cpp/reactor-cpp b/core/src/main/resources/lib/cpp/reactor-cpp index f0f62ad339..f47e5174e4 160000 --- a/core/src/main/resources/lib/cpp/reactor-cpp +++ b/core/src/main/resources/lib/cpp/reactor-cpp @@ -1 +1 @@ -Subproject commit f0f62ad339c82dc137955f7dcae617326b644622 +Subproject commit f47e5174e4cbb891a886b06395da65cc8af79640