Skip to content

feat: parallel execution available in meta codegen #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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

http_archive(
Expand Down
21 changes: 21 additions & 0 deletions cpp_meta_header_codegen/cpp_meta_header_codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,23 @@ static inline auto write_lazy_system_iteration_rate( //
);
}

static inline auto write_system_parallel_execution( //
ecsact::codegen_plugin_context& ctx,
ecsact_system_like_id id
) -> void {
using ecsact::cc_lang_support::cpp_identifier;

auto parallel = ecsact_meta_get_system_parallel_execution(id);

ctx.write(
"template<> struct ecsact::system_parallel_execution<",
cpp_identifier(get_sys_full_name(ctx.package_id, id)),
"> : std::integral_constant<bool, ",
(parallel ? "true" : "false"),
"> {};\n\n"
);
}

template<typename DeclId>
static inline auto write_decl_full_name_specialization( //
ecsact::codegen_plugin_context& ctx,
Expand Down Expand Up @@ -646,6 +663,10 @@ void ecsact_codegen_plugin(
write_lazy_system_iteration_rate(ctx, sys_id);
}

for(auto& sys_id : ecsact::meta::get_all_system_like_ids(ctx.package_id)) {
write_system_parallel_execution(ctx, sys_id);
}

for(auto& sys_id : ecsact::meta::get_system_ids(ctx.package_id)) {
write_decl_full_name_specialization(ctx, sys_id);
}
Expand Down
7 changes: 7 additions & 0 deletions ecsact/cpp/type_info.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ template<typename SystemT>
constexpr auto system_lazy_execution_iteration_rate_v =
system_lazy_execution_iteration_rate<SystemT>::value;

template<typename SystemT>
struct system_parallel_execution;

template<typename SystemLikeT>
constexpr auto system_parallel_execution_v =
system_parallel_execution<SystemLikeT>::value;

template<typename SystemLikeT>
struct system_capabilities_info {
using readonly_components = mp_list<>;
Expand Down
1 change: 1 addition & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ copts = select({
ecsact_toolchain(
name = "ecsact_cli_windows",
target_tool = "@ecsact_cli_windows//file",
# target_tool_path = "C:/Users/zekew/projects/ecsact-dev/ecsact_cli/bazel-bin/ecsact.exe",
)

ecsact_toolchain(
Expand Down
6 changes: 3 additions & 3 deletions test/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ local_repository(

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

http_file(
Expand Down
4 changes: 4 additions & 0 deletions test/example.ecsact
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ system ExplicitlyNoLazyZero(lazy: 0) {
readwrite pkg.b.ExampleB;
}

system ParallelExample(parallel) {
readwrite pkg.a.ExampleA;
}

3 changes: 3 additions & 0 deletions test/meta_check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ static_assert(
ecsact::system_lazy_execution_iteration_rate_v<
example::ExplicitlyNoLazyZero> == 0
);

static_assert(!ecsact::system_parallel_execution_v<example::ExampleLazy>);
static_assert(ecsact::system_parallel_execution_v<example::ParallelExample>);
3 changes: 3 additions & 0 deletions test/system_impls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ void example::ExplicitlyNoLazy::impl(context&) {

void example::ExplicitlyNoLazyZero::impl(context&) {
}

void example::ParallelExample::impl(context&) {
}