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

Lower PROTECT related code. #1556

Merged
merged 2 commits into from
Nov 13, 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
10 changes: 10 additions & 0 deletions src/codegen/codegen_coreneuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3038,5 +3038,15 @@ void CodegenCoreneuronCppVisitor::visit_watch_statement(const ast::WatchStatemen
current_watch_statement++));
}


void CodegenCoreneuronCppVisitor::visit_protect_statement(const ast::ProtectStatement& node) {
print_atomic_reduction_pragma();
printer->add_indent();
node.get_expression()->accept(*this);
printer->add_text(";");
}



} // namespace codegen
} // namespace nmodl
3 changes: 2 additions & 1 deletion src/codegen/codegen_coreneuron_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class CodegenCoreneuronCppVisitor: public CodegenCppVisitor {
/**
* Print atomic update pragma for reduction statements
*/
void print_atomic_reduction_pragma() override;
virtual void print_atomic_reduction_pragma();


/**
Expand Down Expand Up @@ -942,6 +942,7 @@ class CodegenCoreneuronCppVisitor: public CodegenCppVisitor {
void visit_for_netcon(const ast::ForNetcon& node) override;
void visit_verbatim(const ast::Verbatim& node) override;
void visit_watch_statement(const ast::WatchStatement& node) override;
void visit_protect_statement(const ast::ProtectStatement& node) override;

ParamVector functor_params() override;

Expand Down
8 changes: 0 additions & 8 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,14 +1106,6 @@ void CodegenCppVisitor::visit_update_dt(const ast::UpdateDt& node) {
}


void CodegenCppVisitor::visit_protect_statement(const ast::ProtectStatement& node) {
print_atomic_reduction_pragma();
printer->add_indent();
node.get_expression()->accept(*this);
printer->add_text(";");
}


void CodegenCppVisitor::visit_mutex_lock(const ast::MutexLock& node) {
printer->fmt_line("#pragma omp critical ({})", info.mod_suffix);
printer->add_indent();
Expand Down
7 changes: 0 additions & 7 deletions src/codegen/codegen_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,6 @@ class CodegenCppVisitor: public visitor::ConstAstVisitor {
/****************************************************************************************/


/**
* Print atomic update pragma for reduction statements
*/
virtual void print_atomic_reduction_pragma() = 0;


/**
* Instantiate global var instance
*
Expand Down Expand Up @@ -1485,7 +1479,6 @@ class CodegenCppVisitor: public visitor::ConstAstVisitor {
void visit_var_name(const ast::VarName& node) override;
void visit_while_statement(const ast::WhileStatement& node) override;
void visit_update_dt(const ast::UpdateDt& node) override;
void visit_protect_statement(const ast::ProtectStatement& node) override;
void visit_mutex_lock(const ast::MutexLock& node) override;
void visit_mutex_unlock(const ast::MutexUnlock& node) override;
void visit_solution_expression(const ast::SolutionExpression& node) override;
Expand Down
6 changes: 0 additions & 6 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@
/* Backend specific routines */
/****************************************************************************************/


/// TODO: Edit for NEURON
void CodegenNeuronCppVisitor::print_atomic_reduction_pragma() {
return;
}

bool CodegenNeuronCppVisitor::optimize_ion_variable_copies() const {
if (optimize_ionvar_copies) {
throw std::runtime_error("Not implemented.");
Expand Down Expand Up @@ -754,7 +748,7 @@
print_macro("_nt", "nt");
print_macro("_tqitem", "tqitem");

auto print_args_macro = [this, print_macro](const std::string& macro_basename,

Check warning on line 751 in src/codegen/codegen_neuron_cpp_visitor.cpp

View workflow job for this annotation

GitHub Actions / { "flag_warnings": "ON", "os": "ubuntu-22.04", "sanitizer": "undefined" }

lambda capture 'this' is not used [-Wunused-lambda-capture]
const ParamVector& params) {
print_macro("_" + macro_basename + "_", get_arg_str(params));
print_macro("_" + macro_basename + "comma_", get_arg_str(params) + ",");
Expand Down
7 changes: 0 additions & 7 deletions src/codegen/codegen_neuron_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ class CodegenNeuronCppVisitor: public CodegenCppVisitor {
/* Backend specific routines */
/****************************************************************************************/


/**
* Print atomic update pragma for reduction statements
*/
void print_atomic_reduction_pragma() override;


/**
* Check if ion variable copies should be avoided
*/
Expand Down
Loading