Skip to content

Commit 4ac52fc

Browse files
authored
feat: parallel execution available in meta codegen (#142)
1 parent b0497e1 commit 4ac52fc

File tree

8 files changed

+45
-6
lines changed

8 files changed

+45
-6
lines changed

WORKSPACE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44

55
http_archive(
66
name = "ecsact_runtime",
7-
sha256 = "dfc71e519d24b943c855d288d19f539fc9b9c65636c0376c7febb865233161b6",
8-
strip_prefix = "ecsact_runtime-0.2.0",
9-
urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.2.0.tar.gz"],
7+
sha256 = "35b03aaef0925fda5b5aefb2d6a6e2c9593f31d6414ab157091f9ca26a992da3",
8+
strip_prefix = "ecsact_runtime-0.3.0",
9+
urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.3.0.tar.gz"],
1010
)
1111

1212
http_archive(

cpp_meta_header_codegen/cpp_meta_header_codegen.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,23 @@ static inline auto write_lazy_system_iteration_rate( //
454454
);
455455
}
456456

457+
static inline auto write_system_parallel_execution( //
458+
ecsact::codegen_plugin_context& ctx,
459+
ecsact_system_like_id id
460+
) -> void {
461+
using ecsact::cc_lang_support::cpp_identifier;
462+
463+
auto parallel = ecsact_meta_get_system_parallel_execution(id);
464+
465+
ctx.write(
466+
"template<> struct ecsact::system_parallel_execution<",
467+
cpp_identifier(get_sys_full_name(ctx.package_id, id)),
468+
"> : std::integral_constant<bool, ",
469+
(parallel ? "true" : "false"),
470+
"> {};\n\n"
471+
);
472+
}
473+
457474
template<typename DeclId>
458475
static inline auto write_decl_full_name_specialization( //
459476
ecsact::codegen_plugin_context& ctx,
@@ -646,6 +663,10 @@ void ecsact_codegen_plugin(
646663
write_lazy_system_iteration_rate(ctx, sys_id);
647664
}
648665

666+
for(auto& sys_id : ecsact::meta::get_all_system_like_ids(ctx.package_id)) {
667+
write_system_parallel_execution(ctx, sys_id);
668+
}
669+
649670
for(auto& sys_id : ecsact::meta::get_system_ids(ctx.package_id)) {
650671
write_decl_full_name_specialization(ctx, sys_id);
651672
}

ecsact/cpp/type_info.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ template<typename SystemT>
4040
constexpr auto system_lazy_execution_iteration_rate_v =
4141
system_lazy_execution_iteration_rate<SystemT>::value;
4242

43+
template<typename SystemT>
44+
struct system_parallel_execution;
45+
46+
template<typename SystemLikeT>
47+
constexpr auto system_parallel_execution_v =
48+
system_parallel_execution<SystemLikeT>::value;
49+
4350
template<typename SystemLikeT>
4451
struct system_capabilities_info {
4552
using readonly_components = mp_list<>;

test/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ copts = select({
1818
ecsact_toolchain(
1919
name = "ecsact_cli_windows",
2020
target_tool = "@ecsact_cli_windows//file",
21+
# target_tool_path = "C:/Users/zekew/projects/ecsact-dev/ecsact_cli/bazel-bin/ecsact.exe",
2122
)
2223

2324
ecsact_toolchain(

test/WORKSPACE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ local_repository(
99

1010
http_archive(
1111
name = "ecsact_runtime",
12-
sha256 = "dfc71e519d24b943c855d288d19f539fc9b9c65636c0376c7febb865233161b6",
13-
strip_prefix = "ecsact_runtime-0.2.0",
14-
urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.2.0.tar.gz"],
12+
sha256 = "35b03aaef0925fda5b5aefb2d6a6e2c9593f31d6414ab157091f9ca26a992da3",
13+
strip_prefix = "ecsact_runtime-0.3.0",
14+
urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.3.0.tar.gz"],
1515
)
1616

1717
http_file(

test/example.ecsact

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ system ExplicitlyNoLazyZero(lazy: 0) {
2424
readwrite pkg.b.ExampleB;
2525
}
2626

27+
system ParallelExample(parallel) {
28+
readwrite pkg.a.ExampleA;
29+
}
30+

test/meta_check.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ static_assert(
2121
ecsact::system_lazy_execution_iteration_rate_v<
2222
example::ExplicitlyNoLazyZero> == 0
2323
);
24+
25+
static_assert(!ecsact::system_parallel_execution_v<example::ExampleLazy>);
26+
static_assert(ecsact::system_parallel_execution_v<example::ParallelExample>);

test/system_impls.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ void example::ExplicitlyNoLazy::impl(context&) {
2222

2323
void example::ExplicitlyNoLazyZero::impl(context&) {
2424
}
25+
26+
void example::ParallelExample::impl(context&) {
27+
}

0 commit comments

Comments
 (0)