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

Pass inst when passing id. #1184

Merged
merged 2 commits into from
Feb 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: 3 additions & 3 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@
printer->add_text(" ");
printer->push_block();

printer->fmt_line("auto inst = make_instance_{}(*_ml);", info.mod_suffix);

// function requires return variable declaration
if (node.is_function_block()) {
auto type = default_float_data_type();
Expand Down Expand Up @@ -328,6 +326,7 @@
_nt = nrn_threads;
)CODE");
}
printer->fmt_line("auto inst = make_instance_{}(_ml_real);", info.mod_suffix);
if (info.function_uses_table(block_name)) {
printer->fmt_line("_check_{}({})", block_name, internal_method_arguments());
}
Expand Down Expand Up @@ -376,13 +375,14 @@


std::string CodegenNeuronCppVisitor::internal_method_arguments() {
return "_ml, id, _ppvar, _thread, _nt";
return "_ml, inst, id, _ppvar, _thread, _nt";
}


CodegenNeuronCppVisitor::ParamVector CodegenNeuronCppVisitor::internal_method_parameters() {
ParamVector params;
params.emplace_back("", "_nrn_mechanism_cache_range*", "", "_ml");
params.emplace_back("", fmt::format("{}&", instance_struct()), "", "inst");
params.emplace_back("", "size_t", "", "id");
params.emplace_back("", "Datum*", "", "_ppvar");
params.emplace_back("", "Datum*", "", "_thread");
Expand Down Expand Up @@ -507,7 +507,7 @@
std::string CodegenNeuronCppVisitor::int_variable_name(const IndexVariableInfo& symbol,
const std::string& name,
bool use_instance) const {
auto position = position_of_int_var(name);

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

View workflow job for this annotation

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

unused variable ‘position’ [-Wunused-variable]

Check warning on line 510 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" }

unused variable 'position' [-Wunused-variable]
if (symbol.is_index) {
if (use_instance) {
throw std::runtime_error("Not implemented. [wiejo]");
Expand Down Expand Up @@ -785,7 +785,7 @@
}


for (const auto& f: info.function_tables) {

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

View workflow job for this annotation

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

unused variable ‘f’ [-Wunused-variable]

Check warning on line 788 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" }

unused variable 'f' [-Wunused-variable]
throw std::runtime_error("Not implemented, global function tables.");
}

Expand Down Expand Up @@ -1077,7 +1077,7 @@

for (int i = 0; i < codegen_int_variables_size; ++i) {
const auto& int_var = codegen_int_variables[i];
const auto& name = int_var.symbol->get_name();

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

View workflow job for this annotation

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

unused variable ‘name’ [-Wunused-variable]

Check warning on line 1080 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" }

unused variable 'name' [-Wunused-variable]
if (i != info.semantics[i].index) {
throw std::runtime_error("Broken logic.");
}
Expand Down
2 changes: 1 addition & 1 deletion test/usecases/references
Loading