Skip to content

Commit

Permalink
Adjust thread-variable promotion condition. (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc authored Oct 28, 2024
1 parent 750ec88 commit ef0db54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/codegen/codegen_helper_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void CodegenHelperVisitor::find_non_range_variables() {

auto vars = psymtab->get_variables_with_properties(NmodlType::global_var);
for (auto& var: vars) {
if (info.vectorize && info.thread_safe && var->get_write_count() > 0) {
if (info.vectorize && info.declared_thread_safe && var->get_write_count() > 0) {
var->mark_thread_safe();
info.thread_variables.push_back(var);
info.thread_var_data_size += var->get_length();
Expand Down Expand Up @@ -767,6 +767,10 @@ void CodegenHelperVisitor::visit_bbcore_pointer(const BbcorePointer& /* node */)
info.bbcore_pointer_used = true;
}

void CodegenHelperVisitor::visit_thread_safe(const ast::ThreadSafe&) {
info.declared_thread_safe = true;
}


void CodegenHelperVisitor::visit_watch(const ast::Watch& /* node */) {
info.watch_count++;
Expand Down
1 change: 1 addition & 0 deletions src/codegen/codegen_helper_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class CodegenHelperVisitor: public visitor::ConstAstVisitor {
void visit_derivimplicit_callback(const ast::DerivimplicitCallback& node) override;
void visit_net_receive_block(const ast::NetReceiveBlock& node) override;
void visit_bbcore_pointer(const ast::BbcorePointer& node) override;
void visit_thread_safe(const ast::ThreadSafe&) override;
void visit_watch(const ast::Watch& node) override;
void visit_watch_statement(const ast::WatchStatement& node) override;
void visit_for_netcon(const ast::ForNetcon& node) override;
Expand Down
6 changes: 6 additions & 0 deletions src/codegen/codegen_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ struct CodegenInfo {
/// if mod file is thread safe (always true for coreneuron)
bool thread_safe = true;

/// A mod file can be declared to be thread safe using the keyword THREADSAFE.
/// This boolean is true if and only if the mod file was declared thread safe
/// by the user. For example thread variables require the mod file to be declared
/// thread safe.
bool declared_thread_safe = false;

/// if mod file is point process
bool point_process = false;

Expand Down

0 comments on commit ef0db54

Please sign in to comment.