Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Initial attempt at implementing VERBATIM.#1364

Merged
1uc merged 23 commits into
masterfrom
1uc/verbatim
Nov 4, 2024
Merged

Initial attempt at implementing VERBATIM.#1364
1uc merged 23 commits into
masterfrom
1uc/verbatim

Conversation

@1uc

@1uc 1uc commented Jul 22, 2024

Copy link
Copy Markdown
Collaborator

Edit the idea is to temporarily print the NOCMODL macros, e.g. the MOD file:

VERBATIM
_lget_gbl = gbl;
ENDVERBATIM

generates:

        // Setup for VERBATIM
        #define gbl inst.global->gbl
        #define get_gbl get_gbl_globals
        #define _lget_gbl ret_get_gbl
        #define t nt->_t
        // Begin VERBATIM

        _lget_gbl = gbl;
        // End VERBATIM
        #undef gbl
        #undef get_gbl
        #undef _lget_gbl
        #undef t
        // End of cleanup for VERBATIM

One can see the following happening:

       // Translate `gbl` to the correct C++ code:
       #define gbl inst.global->gbl

       // Because the substring `get_gbl` is present we print the
       // full name of the function `get_gbl` (even though it's not
       // needed).
       #define get_gbl get_gbl_globals

       // Same translation logic for the return type.
       #define _lget_gbl ret_get_gbl

There's one more twist relates to threadargs in both NOCMODL and NMODL there's two variations of prototypes: one internalthreadargsproto and threadargsproto. In NOCMODL the number and order of the arguments are the same (their types differ slightly). Therefore, in NOCMODL a single macro is sufficient to call both types, i.e. threadargs works for both types of functions. There is no internalthreadargs. In NMODL the two signatures differ significantly and for this reason we need to massage VERBATIM code to determine which string to substitute for threadargs.

bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Jul 22, 2024
@codecov

codecov Bot commented Jul 22, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 25.00000% with 84 lines in your changes missing coverage. Please review.

Project coverage is 86.23%. Comparing base (c5052b9) to head (63ff7e0).
Report is 2 commits behind head on master.

Files Patch % Lines
src/codegen/codegen_neuron_cpp_visitor.cpp 1.23% 80 Missing ⚠️
src/codegen/codegen_coreneuron_cpp_visitor.cpp 87.50% 2 Missing ⚠️
src/codegen/codegen_cpp_visitor.hpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1364      +/-   ##
==========================================
- Coverage   86.75%   86.23%   -0.52%     
==========================================
  Files         180      180              
  Lines       13669    13760      +91     
==========================================
+ Hits        11858    11866       +8     
- Misses       1811     1894      +83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bbpbuildbot

Copy link
Copy Markdown
Collaborator

Logfiles from GitLab pipeline #223048 (:white_check_mark:) have been uploaded here!

Status and direct links:

bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Aug 12, 2024
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 11, 2024
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 12, 2024
@1uc 1uc force-pushed the 1uc/verbatim branch 2 times, most recently from b986231 to d30cd25 Compare September 24, 2024 07:08
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 24, 2024
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 25, 2024
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Oct 8, 2024
@1uc 1uc force-pushed the 1uc/verbatim branch 2 times, most recently from b68af04 to 80892d4 Compare October 15, 2024 06:58
@1uc 1uc marked this pull request as ready for review October 30, 2024 14:15

@JCGoran JCGoran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, though I haven't checked how this is used in NEURON tests or modelDB. Is there a reference somewhere how users can access the variables in VERBATIM (like _lget_gbl)? If not, some docs on how NMODL does it would be great as the main NEURON docs don't really list any rules for the replacement mechanism.

Comment thread src/codegen/codegen_neuron_cpp_visitor.cpp
Comment thread src/codegen/codegen_neuron_cpp_visitor.cpp
Comment thread src/codegen/codegen_neuron_cpp_visitor.cpp
Comment thread src/symtab/symbol_table.cpp
Comment thread src/codegen/codegen_neuron_cpp_visitor.hpp Outdated
Comment thread src/codegen/codegen_neuron_cpp_visitor.cpp
Comment thread src/codegen/codegen_cpp_visitor.hpp
Comment thread src/codegen/codegen_neuron_cpp_visitor.cpp Outdated
Comment thread src/codegen/codegen_neuron_cpp_visitor.cpp Outdated
@1uc

1uc commented Oct 31, 2024

Copy link
Copy Markdown
Collaborator Author

Is there a reference somewhere how users can ...

I don't know but I'm not writing one. Users should not use and ideally not know about VERBATIM. It constantly causes severe issues that limit our ability to generate code freely.

@nrnhines

Copy link
Copy Markdown
Collaborator

Is there a reference somewhere how users can ...

I don't know but I'm not writing one. Users should not use and ideally not know about VERBATIM. It constantly causes severe issues that limit our ability to generate code freely.

There has never been a promise that use of NEURON internals within mod file VERBATIM blocks would be stable. The assumption is that occasionally VERBATIM can be useful even if intimately tied to a specific version NEURON. An example
is the VERBATIM block in ri.mod of the Traub model which makes use of the details of the internal segment data structure.
https://github.com/ModelDBRepository/82894/blob/master/mod/ri.mod . As in this case, we developers have had some success in supporting published modeldb models. Since NEURON is used in part in the domain of Computational Neuroscience research, it is sometimes necessary for users to extend the program. In practice this sometimes means that the researcher should ask a developer for advice on how to implement the extension needed. Forking and modifying NEURON source is a last resort and in most cases dealing with the issue with a mod file with a VERBATIM block that has knowledge of NEURON internals sufficed.

@JCGoran

JCGoran commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

There has never been a promise that use of NEURON internals within mod file VERBATIM blocks would be stable.

In that case, I think we need to put a huge warning label in the NEURON docs, currently there is some mention of compatibility issues, but it's not nearly prominent enough.

Regarding the mod file linked: it doesn't work with this NMODL PR as the #defines from the VERBATIM block do not appear anywhere in the cpp file.

@1uc

1uc commented Oct 31, 2024

Copy link
Copy Markdown
Collaborator Author

it doesn't work

Fixed & testing that now. It's related to SUFFIX nothing.

@1uc

1uc commented Oct 31, 2024

Copy link
Copy Markdown
Collaborator Author

Regarding how well it's tested, not very well. It's enough to compile everything we need for the nrn repository. Without it's slowly a bit tedious to make progress towards getting nmodl working for all nrn unit-test.

@JCGoran JCGoran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work (w/ some non-verbatim-related tweaks) with the built-in NEURON files, great job!

@1uc 1uc merged commit af7c882 into master Nov 4, 2024
@1uc 1uc deleted the 1uc/verbatim branch November 4, 2024 13:25
JCGoran pushed a commit to neuronsimulator/nrn that referenced this pull request Mar 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants