From f70fd5d4dbac4f4878f2cdabcd0dc8b127284576 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 e88f8ae38a..111060a836 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -354,7 +354,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 e27698bb71..e8a0b97917 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit e27698bb710ac6b0ae0f8d5e9480c89821574ca7 +Subproject commit e8a0b97917c8ef146cd074e67aa69df43f344bb6