Skip to content
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

Adjust thread-variable promotion condition. #1534

Merged
merged 1 commit into from
Oct 28, 2024
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: 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
Loading