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

Support for NEURON {RANDOM ranvar1, ranvar2, ...} statement. #1125

Merged
merged 12 commits into from
Feb 8, 2024

Conversation

nrnhines
Copy link
Collaborator

@nrnhines nrnhines commented Dec 15, 2023

Accepts the latest netcon.mod from neuronsimulator/nrn#2627. Some changes were picked from #581

  • Misuse of RANDOM variables should result in meaningful error messages
  • Unit tests
  • Semantic analysis visitor improvements

@nrnhines nrnhines marked this pull request as draft December 15, 2023 00:55
@nrnhines
Copy link
Collaborator Author

nrnhines commented Dec 15, 2023

This comment is obsolete. nrn/netstim.cpp has been removed as the translation of RANDOM variables with nmodl is complete.

nrn/netstim.cpp is temporary and has been manually modified from the nmodl generated cpp file. The diff is below and
can be used to indicate how the nmodl translator needs to be augmented.

hines@hines-t7500:~/neuron/rannmodl/buildsani$ bin/nmodl ../src/nrnoc/netstim.mod
hines@hines-t7500:~/neuron/rannmodl/buildsani$ diff netstim.cpp ../netstim.cpp
7c7
< Created         : Sat Dec 16 19:30:54 2023
---
> Created         : Sat Dec 16 11:04:46 2023
46a47
>         "ranvar",
49a51
> #define Zranvar (nrnran123_State*)inst->ranvar[indexes[2*pnodecount + id]]
77a80
>         void** ranvar{};
96c99
<         return -1;
---
>         return 2;
111c114
<         return 3;
---
>         return 4;
164a168,175
> 
>         int pnodecount = ml->_nodecount_padded;
>         int nodecount = ml->nodecount;
>         Datum* indexes = ml->pdata;
>         for (int id = 0; id < nodecount; id++) {
>             nrnran123_deletestream(Zranvar);
>         }
> 
191a203
>         inst->ranvar = nt->_vdata;
266c278
<         random_setseq(ranvar, x);
---
>         nrnran123_setseq(Zranvar, x);
281c293
<                 nrnran123_setids(ranvar, id[0], id[1], id[2]);
---
>                 nrnran123_setids(Zranvar, id[0], id[1], id[2]);
284c296
<                 nrnran123_setseq(ranvar, id[0], which);
---
>                 nrnran123_setseq(Zranvar, id[0], which);
297c309
<                 nrnran123_setids(ranvar, static_cast<uint32_t>(*getarg(1)), static_cast<uint32_t>(*getarg(2)), static_cast<uint32_t>(*getarg(3)));
---
>                 nrnran123_setids(Zranvar, static_cast<uint32_t>(*getarg(1)), static_cast<uint32_t>(*getarg(2)), static_cast<uint32_t>(*getarg(3)));
299c311
<                 nrnran123_setids(ranvar, static_cast<uint32_t>(*getarg(1)), static_cast<uint32_t>(*getarg(2)), 0);
---
>                 nrnran123_setids(Zranvar, static_cast<uint32_t>(*getarg(1)), static_cast<uint32_t>(*getarg(2)), 0);
301c313
<             nrnran123_setseq(ranvar, 0, 0);
---
>             nrnran123_setseq(Zranvar, 0, 0);
324c336
<         ret_erand = random_negexp(ranvar);
---
>         ret_erand = nrnran123_negexp(Zranvar);
352c364
<                     artcell_net_send(&inst->tqitem[indexes[2*pnodecount + id]], weight_index, pnt, nt->_t+inst->event[id], 1.0);
---
>                     artcell_net_send(&inst->tqitem[indexes[3*pnodecount + id]], weight_index, pnt, nt->_t+inst->event[id], 1.0);
360c372
<                     artcell_net_send(&inst->tqitem[indexes[2*pnodecount + id]], weight_index, pnt, nt->_t+0.0, 1.0);
---
>                     artcell_net_send(&inst->tqitem[indexes[3*pnodecount + id]], weight_index, pnt, nt->_t+0.0, 1.0);
368c380
<                     artcell_net_send(&inst->tqitem[indexes[2*pnodecount + id]], weight_index, pnt, nt->_t+inst->event[id], 1.0);
---
>                     artcell_net_send(&inst->tqitem[indexes[3*pnodecount + id]], weight_index, pnt, nt->_t+inst->event[id], 1.0);
409c421
<                     artcell_net_send(&inst->tqitem[indexes[2*pnodecount + id]], 0, (Point_process*)inst->point_process[indexes[1*pnodecount + id]], nt->_t+inst->event[id], 3.0);
---
>                     artcell_net_send(&inst->tqitem[indexes[3*pnodecount + id]], 0, (Point_process*)inst->point_process[indexes[1*pnodecount + id]], nt->_t+inst->event[id], 3.0);
431c443,444
<         hoc_register_dparam_semantics(mech_type, 2, "netsend");
---
>         hoc_register_dparam_semantics(mech_type, 2, "random");
>         hoc_register_dparam_semantics(mech_type, 3, "netsend");
433c446
<         add_nrn_artcell(mech_type, 2);
---
>         add_nrn_artcell(mech_type, 3);
hines@hines-t7500:~/neuron/rannmodl/buildsani$ 

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

src/codegen/codegen_coreneuron_cpp_visitor.cpp Outdated Show resolved Hide resolved
src/visitors/semantic_analysis_visitor.cpp Outdated Show resolved Hide resolved
src/visitors/semantic_analysis_visitor.cpp Outdated Show resolved Hide resolved
src/visitors/semantic_analysis_visitor.cpp Outdated Show resolved Hide resolved
@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@pramodk pramodk force-pushed the hines/nmodlrandom-simplified branch from d4efc03 to c89dcf1 Compare January 27, 2024 13:56
@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

 - replace possibly_rename() with lambda as it's used in one place
 - remove extdef_rand.h
 - move is_random_function from symtab/symbol_properties.hpp to
   visitor_utils.hpp
 - add parsing test in test/unit/utils/nmodl_constructs.cpp
Copy link
Contributor

@pramodk pramodk left a comment

Choose a reason for hiding this comment

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

@nrnhines: tomorrow I am going to work a bit on src/visitors/semantic_analysis_visitor.* and address Todo about meaningful error message.

src/visitors/semantic_analysis_visitor.cpp Outdated Show resolved Hide resolved
src/codegen/codegen_coreneuron_cpp_visitor.cpp Outdated Show resolved Hide resolved
@bbpbuildbot

This comment has been minimized.

 - fix failing modtoken tests
 - add units for semantic analysis visitor of RANDOM
 - simplify the logic for semantic checks
 - remove unnecessary code
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (3e3f62a) 88.18% compared to head (2b8950d) 88.11%.
Report is 1 commits behind head on master.

Files Patch % Lines
src/codegen/codegen_cpp_visitor.cpp 44.44% 10 Missing ⚠️
src/codegen/codegen_coreneuron_cpp_visitor.cpp 50.00% 8 Missing ⚠️
src/visitors/perf_visitor.cpp 57.14% 3 Missing ⚠️
src/symtab/symbol_properties.cpp 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1125      +/-   ##
==========================================
- Coverage   88.18%   88.11%   -0.08%     
==========================================
  Files         175      175              
  Lines       12411    12520     +109     
==========================================
+ Hits        10945    11032      +87     
- Misses       1466     1488      +22     

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

@bbpbuildbot

This comment has been minimized.

@pramodk pramodk changed the title NEURON {RANDOM ranvar1, ranvar2, ...} statement. Support for NEURON {RANDOM ranvar1, ranvar2, ...} statement. Feb 8, 2024
@pramodk pramodk marked this pull request as ready for review February 8, 2024 01:01
@bbpbuildbot
Copy link
Collaborator

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

Status and direct links:

Copy link
Contributor

@pramodk pramodk left a comment

Choose a reason for hiding this comment

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

LGTM - I have made the necessary changes directly.

@pramodk pramodk merged commit 8f7eb99 into master Feb 8, 2024
20 checks passed
@pramodk pramodk deleted the hines/nmodlrandom-simplified branch February 8, 2024 07:03
ohm314 pushed a commit that referenced this pull request May 21, 2024
…tatement (#1125)

* Support for new RANDOM construct in NMODL, see neuronsimulator/nrn#2627
* Added necessary changes to the parser, visitors, symbol table and code generation
* Added unit tests

Co-authored-by: Pramod S Kumbhar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants