From 7ffbc49168c0de6fa162e260102f1c21e1f6e10f Mon Sep 17 00:00:00 2001 From: Philipp Shemetov Date: Tue, 26 Aug 2025 18:42:03 +0300 Subject: [PATCH] Remove export from launch Signed-off-by: Philipp Shemetov --- .../tests/concurrency/concurrency_tests.ets | 56 +++++++++++++++++++ .../ets/tests/ets_test_suite/CMakeLists.txt | 8 ++- .../ets_test_suite/coroutines/CMakeLists.txt | 14 ++++- .../ets_test_suite/coroutines/affinity.ets | 6 +- .../coroutines/arktsconfig.json | 11 ++++ 5 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 static_core/plugins/ets/tests/concurrency/concurrency_tests.ets create mode 100644 static_core/plugins/ets/tests/ets_test_suite/coroutines/arktsconfig.json diff --git a/static_core/plugins/ets/tests/concurrency/concurrency_tests.ets b/static_core/plugins/ets/tests/concurrency/concurrency_tests.ets new file mode 100644 index 0000000000..0e8490ac6a --- /dev/null +++ b/static_core/plugins/ets/tests/concurrency/concurrency_tests.ets @@ -0,0 +1,56 @@ +type CoroFunT = ( + a0: A, + a1: A, + a2: A, + a3: A, + a4: A, + a5: A, + a6: A, + a7: A, + a8: A, + a9: A, + a10: A, + a11: A, + a12: A, + a13: A, + a14: A, + a15: A +) => R; + + +export class ConcurrencyTest { + + public static launch>(coroFun: F, launchParams: LaunchParams, ...args: FixedArray): Job { + return ConcurrencyTest.launchInternal(coroFun, args as FixedArray, launchParams); + } + + public static launch>(coroFun: F, ...args: FixedArray): Job { + return ConcurrencyTest.launchInternal(coroFun, args as FixedArray); + } + + public static launchInternal>(coroFun: F, args: FixedArray, launchParams?: LaunchParams): Job { + const paddedArgs = ConcurrencyTest.padArrayToMaxArgs(args); + if (launchParams) { + return ConcurrencyTest.launchInternalJobNative(coroFun, args as FixedArray, launchParams.abortFlag, launchParams.workerGroupId); + } + return ConcurrencyTest.launchInternalJobNative(coroFun, args as FixedArray, false, WorkerGroup.ANY_ID); + } + + public static padArrayToMaxArgs(arr: FixedArray): FixedArray<(T | undefined)> { + const MAX_ARGS = 16; + const res: FixedArray<(T | undefined)> = new (T | undefined)[MAX_ARGS]; + for (let i = 0; i < arr.length && i < MAX_ARGS; ++i) { + res[i] = arr[i]; + } + for (let i = arr.length; i < MAX_ARGS; ++i) { + res[i] = undefined; + } + return res; + } + + public static native launchInternalJobNative(coroFun: F, args: FixedArray, abortFlag: boolean, gid: WorkerGroupId): Job; + + public static print() : void { + console.log("test") + } +} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt index 6fbdffe10f..cfabeef559 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt @@ -15,7 +15,7 @@ function(add_ets_test test_suite) set(prefix ARG) set(noValues SKIP_ARM32_COMPILER) set(singleValues FILE TEST_NAME ENTRYPOINT TEST_PATH) - set(multiValues OPTIONS MODE COMPILER_EXTRA_OPTIONS) + set(multiValues OPTIONS MODE COMPILER_EXTRA_OPTIONS ARKTS_CONFIGS) cmake_parse_arguments(${prefix} "${noValues}" "${singleValues}" "${multiValues}" ${ARGN}) # Create target to run one test in different modes(e.g. ets_test_suite_coroutines_launch_n_workers) @@ -35,13 +35,19 @@ function(add_ets_test test_suite) if ("INT" IN_LIST ARG_MODE) set(target ${test_suite}_${ARG_TEST_NAME}-ets-int) + # add_dependencies(${all_modes_tests} ${ARG_TARGET_DEPEND}) + # message("DEBUG:", ${ARG_TARGET_DEPEND}) run_int_ets_code(${target} ${test_out_dir} SOURCES "${test_in}" ENTRYPOINT ${ARG_ENTRYPOINT} RUNTIME_EXTRA_OPTIONS ${ARG_OPTIONS} + ARKTS_CONFIGS ${ARKTS_CONFIGS} COMPILER_EXTRA_OPTIONS ${ARG_COMPILER_EXTRA_OPTIONS} ) add_dependencies(${all_modes_tests} ${target}) + if("${test_suite}" STREQUAL "ets_test_suite_coroutines") + add_dependencies(${target} coro_compiled) + endif() endif() # Compiler doesn't support some instruction in arm32 mode(launch) diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt index b69fc51931..e726c13813 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt @@ -11,7 +11,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_custom_target(ets_test_suite_coroutines) +set(ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../concurrency/concurrency_tests.ets) + +compile_ets_sources(${CMAKE_CURRENT_BINARY_DIR} coro_compiled RESULT "${ETS_SOURCES}") +# compile_ets_code(${CMAKE_CURRENT_SOURCE_DIR}/../../concurrency/concurrency_tests.ets ${CMAKE_CURRENT_SOURCE_DIR}/concurrency_tests.abc compiled) +add_custom_target(ets_test_suite_coroutines + DEPENDS coro_compiled) # Add ets coroutine tests targets # @@ -40,7 +45,8 @@ function(add_ets_coroutines_test) set(singleValues FILE) set(multiValues OPTIONS IMPL OPTION_SETS_THREADED OPTION_SETS_STACKFUL WORKERS MODE) cmake_parse_arguments(${prefix} "${noValues}" "${singleValues}" "${multiValues}" ${ARGN}) - + + set(BOOT_PANDA_FILES "${BOOT_PANDA_FILES}:${CMAKE_CURRENT_BINARY_DIR}/coro_compiled-concurrency_tests.abc") if (ARG_SKIP_ARM32_COMPILER) set(SKIP_ARM32_COMPILER "SKIP_ARM32_COMPILER") endif() @@ -76,13 +82,15 @@ function(add_ets_coroutines_test) set(additional_options "--coroutine-enable-features:migration,migrate-await") endif() string(TOLOWER "${option_set}" options_name) - + set(ARKTS_CONFIGS_COROUTINES ${CMAKE_CURRENT_SOURCE_DIR}/arktsconfig.json) add_ets_test(ets_test_suite_coroutines FILE ${ARG_FILE} ${SKIP_ARM32_COMPILER} TEST_NAME "${test_name}_${impl_name}_${options_name}_workers_${workers_count}" OPTIONS ${ARG_OPTIONS} ${impl_option} ${additional_options} ${workers_option} ${list_unhandled_option} MODE ${ARG_MODE} + ARKTS_CONFIGS ${ARKTS_CONFIGS_COROUTINES} + DEPEND_VAR coro_compiled ) endforeach() endforeach() diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets index 5529365fdc..3133380adb 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets @@ -15,7 +15,8 @@ import {CoroutineExtras, AtomicFlag} from "std/debug/concurrency" import {StdDebug} from "std/debug" -import { launch } from "std/concurrency" +import { ConcurrencyTest } from "../../concurrency/concurrency_tests"; +//import { launch } from "std/concurrency" import { Job } from "std/core" type L = StdDebug.Logger @@ -49,7 +50,7 @@ function check_sync_id_nonmain(number_of_coros: int): int { let promises: (Job | undefined)[] = new (Job | undefined)[number_of_coros]; for (let i = 0; i < number_of_coros; ++i) { - promises[i] = launch Int>(checker, id_current); + promises[i] = ConcurrencyTest.launch Int>(checker, id_current); } continue_execution.set(true); let result: int = 0; @@ -112,6 +113,7 @@ function testExclusiveLaunchFlag(): void { function main(): int { // Call L's enableLogging method to enable logs. + //ConcurrencyTest.print() let testSuite = new arktest.ArkTestsuite('coroutines.affinity'); testSuite.addTest('testAsyncDefaultPolicy', testAsyncDefaultPolicy); testSuite.addTest('testAsyncNonMainPolicy', testAsyncNonMainPolicy); diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/arktsconfig.json b/static_core/plugins/ets/tests/ets_test_suite/coroutines/arktsconfig.json new file mode 100644 index 0000000000..aa856daf17 --- /dev/null +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/arktsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "baseUrl": "/home/huawei/Documents/huawei_repos/ark_0812/runtime_core/static_core", + "paths": { + "std": [ + "/home/huawei/Documents/huawei_repos/ark_0812/runtime_core/static_core/plugins/ets/stdlib" + ], + "lib": ["/home/huawei/Documents/huawei_repos/ark_0812/runtime_core/static_core/plugins/ets/tests/concurrency/concurrency_tests.ets"] + } + } +} -- Gitee