nmodl
nmodl copied to clipboard
Some codegen routines rename variables in the AST
Current implementation of net_receive printing routine :
void CodegenCVisitor::print_net_receive_common_code(Block* node, bool need_mech_inst) {
....
/// rename variables if they are actually used
auto parameters = info.net_receive_node->get_parameters();
if (!parameters.empty()) {
int i = 0;
printer->add_newline();
for (auto& parameter: parameters) {
auto name = parameter->get_node_name();
VarUsageVisitor vu;
auto var_used = vu.variable_used(node, "(*" + name + ")");
if (var_used) {
auto statement = "double* {} = weights + weight_index + {};"_format(name, i++);
printer->add_line(statement);
RenameVisitor vr(name, "*" + name);
node->visit_children(&vr);
}
}
}
}
If we are running second code generation pass (e.g. we were running OpenACC followed by C codegen), the weight is already renamed to weight*. And hence subsequent lookups will fail.
This was causing undefined weights in #101.
For now, temporary workaround is to activate one backend at a time (which is sufficient).