Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: respect parallel system parameter #127

Merged
merged 2 commits into from
Jul 2, 2024
Merged
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
28 changes: 22 additions & 6 deletions rt_entt_codegen/shared/parallel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <vector>
#include <type_traits>
#include <format>

#include "ecsact/lang-support/lang-cc.hh"
#include "rt_entt_codegen/shared/system_variant.hh"
#include "system_variant.hh"
Expand Down Expand Up @@ -178,6 +177,25 @@ auto ecsact::rt_entt_codegen::parallel::can_entities_parallel(
return true;
}

/**
* Quick check to see if a system should run independently regardless of it's
* system capbilities.
*/
static auto should_run_independently(ecsact_system_like_id id) -> bool {
// User has explicitly marked a system as not parallel; respect that.
if(ecsact_meta_get_system_parallel_execution(id) == ECSACT_PAR_EXEC_DENY) {
return true;
}

// Generator systems increase storage so they may not run in parallel with
// other systems.
if(!ecsact::meta::get_system_generates_ids(id).empty()) {
return true;
}

return false;
}

static auto loop_iterator(
const std::vector<system_like_id_variant>& system_list,
const std::vector<system_like_id_variant>::iterator begin,
Expand All @@ -190,10 +208,8 @@ static auto loop_iterator(

for(auto iterator = begin; iterator != system_list.end(); iterator++) {
auto sys_like_id = *iterator;
auto capabilities = ecsact::meta::system_capabilities(sys_like_id);
auto generate_ids = ecsact::meta::get_system_generates_ids(sys_like_id);

if(!generate_ids.empty()) {
if(should_run_independently(sys_like_id)) {
if(!parallel_system_list.empty()) {
parallel_system_cluster.push_back(parallel_system_list);
}
Expand All @@ -209,8 +225,8 @@ static auto loop_iterator(
return;
}

std::set<ecsact_component_like_id> child_unsafe_comps{};

auto capabilities = ecsact::meta::system_capabilities(sys_like_id);
auto child_unsafe_comps = std::set<ecsact_component_like_id>{};
auto child_systems = ecsact::meta::get_child_system_ids(sys_like_id);

for(auto child_sys_id : child_systems) {
Expand Down