Skip to content

Commit

Permalink
Improve update_table name.
Browse files Browse the repository at this point in the history
Change the name to `update_table_*`. To avoid inconsistencies in the
name (and it's suffix) we introduce a function
`table_update_function_name`.

Fixes a bug related to incorrect use of `rsuffix`, which caused the
function name to be inconsistent for POINT_PROCESSES.
  • Loading branch information
1uc committed Jul 12, 2024
1 parent 862eb2f commit 54d01a2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/codegen/codegen_coreneuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void CodegenCoreneuronCppVisitor::print_check_table_thread_function() {
printer->add_line("double v = 0;");

for (const auto& function: info.functions_with_table) {
auto method_name_str = method_name(table_function_prefix() + function->get_node_name());
auto method_name_str = table_update_function_name(function->get_node_name());
auto arguments = internal_method_arguments();
printer->fmt_line("{}({});", method_name_str, arguments);
}
Expand Down
9 changes: 4 additions & 5 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ bool CodegenCppVisitor::has_parameter_of_name(const T& node, const std::string&
}


std::string CodegenCppVisitor::table_function_prefix() const {
return "lazy_update_";
std::string CodegenCppVisitor::table_update_function_name(const std::string& block_name) const {
return "update_table_" + method_name(block_name);
}


Expand Down Expand Up @@ -1524,9 +1524,8 @@ void CodegenCppVisitor::print_table_check_function(const Block& node) {
auto float_type = default_float_data_type();

printer->add_newline(2);
printer->fmt_push_block("void {}{}({})",
table_function_prefix(),
method_name(name),
printer->fmt_push_block("void {}({})",
table_update_function_name(name),
get_parameter_str(internal_params));
{
printer->fmt_push_block("if ({} == 0)", use_table_var);
Expand Down
8 changes: 5 additions & 3 deletions src/codegen/codegen_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,12 @@ class CodegenCppVisitor: public visitor::ConstAstVisitor {
bool use_instance = true) const = 0;

/**
* Prefix used for the function that performs the lazy update
* The name of the function that updates the table value if the parameters
* changed.
*
* \param block_name The name of the block that contains the TABLE.
*/
std::string table_function_prefix() const;

std::string table_update_function_name(const std::string& block_name) const;

/**
* Return ion variable name and corresponding ion read variable name.
Expand Down
17 changes: 7 additions & 10 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ void CodegenNeuronCppVisitor::print_check_table_function_prototypes() {
for (const auto& function: info.functions_with_table) {
auto name = function->get_node_name();
auto internal_params = internal_method_parameters();
printer->fmt_line("void {}{}({});",
table_function_prefix(),
method_name(name),
printer->fmt_line("void {}({});",
table_update_function_name(name),

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

View check run for this annotation

Codecov / codecov/patch

src/codegen/codegen_neuron_cpp_visitor.cpp#L167-L168

Added lines #L167 - L168 were not covered by tests
get_parameter_str(internal_params));
}

Expand All @@ -192,10 +191,9 @@ void CodegenNeuronCppVisitor::print_check_table_function_prototypes() {
}

for (const auto& function: info.functions_with_table) {
auto method_name_str = function->get_node_name();
auto method_args_str = get_arg_str(internal_method_parameters());
printer->fmt_line(
"{}{}{}({});", table_function_prefix(), method_name_str, info.rsuffix, method_args_str);
auto method_name = function->get_node_name();
auto method_args = get_arg_str(internal_method_parameters());
printer->fmt_line("{}({});", table_update_function_name(method_name), method_args);

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

View check run for this annotation

Codecov / codecov/patch

src/codegen/codegen_neuron_cpp_visitor.cpp#L194-L196

Added lines #L194 - L196 were not covered by tests
}
printer->pop_block();
}
Expand Down Expand Up @@ -403,9 +401,8 @@ void CodegenNeuronCppVisitor::print_hoc_py_wrapper_function_body(
info.thread_var_thread_id);
}
if (info.function_uses_table(block_name)) {
printer->fmt_line("{}{}({});",
table_function_prefix(),
method_name(block_name),
printer->fmt_line("{}({});",
table_update_function_name(block_name),

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

View check run for this annotation

Codecov / codecov/patch

src/codegen/codegen_neuron_cpp_visitor.cpp#L404-L405

Added lines #L404 - L405 were not covered by tests
internal_method_arguments());
}
const auto get_func_call_str = [&]() {
Expand Down

0 comments on commit 54d01a2

Please sign in to comment.