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

mech_api.h: expose more declarations to translated MOD files #1825

Merged
merged 4 commits into from
May 24, 2022

Conversation

alexsavulescu
Copy link
Member

@alexsavulescu alexsavulescu commented May 17, 2022

Include more headers in mech_api.h. This means that when updating MOD files to be compatible with C++ / #1597 then we can assume that NEURON-internal methods do not need to be declared for versions >=8.2.

As a brief reminder of the plan:

In this PR:

(description by @olupton, don't blame @alexsavulescu for it)

@alexsavulescu
Copy link
Member Author

also need

extern void mcell_ran4_init(uint32_t idum);
extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range);

@nrnhines
Copy link
Member

mcell_ran4(unsigned int* idum, ...
This does not look right to me. I would expect it to be uint32_t idum

@olupton
Copy link
Collaborator

olupton commented May 18, 2022

Also need

extern uint32_t nrnRan4int(uint32_t* idx1, uint32_t idx2);

@iomaganaris
Copy link
Member

Also

extern Symbol *hoc_get_symbol(char *);

is needed

@olupton
Copy link
Collaborator

olupton commented May 18, 2022

I think we want

nrn/src/oc/hocdec.h

Lines 234 to 238 in 571ab16

#if defined(__cplusplus)
cTemplate* ctemplate;
#else
cTemplate* template;
#endif
to change in this PR too, so that this member is called ctemplate in 8.2.0. Then we can use #ifndef NRN_VERSION_GTEQ_8_2_0 instead of #ifdef __cplusplus.

@olupton
Copy link
Collaborator

olupton commented May 18, 2022

With the current state of this PR there is a problem with ivoc_list_item: if oc_ansi.h is included in a C mechanism then it is expected to have C linkage, but the definition in src/ivoc/oclist.cpp includes oc_ansi.h as C++ and therefore exports a C++ linkage version of the function.

To fix this, we should move ivoc_list_item into the extern "C" block in the header so that for NEURON 8.2 this function always has C linkage.

@olupton
Copy link
Collaborator

olupton commented May 18, 2022

mcell_ran4(unsigned int* idum, ... This does not look right to me. I would expect it to be uint32_t idum

I think the problem is not the type but the (unhelpful) parameter name. In the definition it's called high:
https://github.com/neuronsimulator/nrn/blob/d0fb3b38f7c717c1283c94fb02770ff6fee3a4c0/src/oc/mcran4.cpp#L57

@codecov-commenter
Copy link

codecov-commenter commented May 18, 2022

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 47.05%. Comparing base (7b2a888) to head (695c99e).
Report is 1770 commits behind head on master.

Files with missing lines Patch % Lines
src/ivoc/oclist.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1825   +/-   ##
=======================================
  Coverage   47.05%   47.05%           
=======================================
  Files         543      543           
  Lines      112949   112949           
=======================================
  Hits        53143    53143           
  Misses      59806    59806           

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

@olupton
Copy link
Collaborator

olupton commented May 18, 2022

Other possible additions:

  • cvode_fadvance
  • clear_event_queue

@olupton olupton changed the title more mech api convergence after ModelDB workshop mech_api.h: expose more declarations to translated MOD files May 23, 2022
alexsavulescu and others added 4 commits May 23, 2022 16:10
- mcran4.h in mech_api.h
- hoc_get_symbol declared
- Object member always called ctemplate in 8.2+
- ivoc_list_item has C linkage in C
- Make nrncvode.h dual C/C++ and include it in mech_api.h.
- clear_event_queue and cvode_fadvance are used in ModelDB models.
@olupton olupton requested a review from pramodk May 24, 2022 06:57
@olupton olupton added this to the Release v8.2 milestone May 24, 2022
@olupton olupton requested a review from nrnhines May 24, 2022 08:34
Copy link
Member

@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!

@nrnhines: we are ready to merge this and get 8.2a tagged today. Before we do this, do you have anything that you would like to have in 8.2a?

@nrnhines
Copy link
Member

nrnhines commented May 24, 2022

anything that you would like to have in 8.2a?

As formatting is a nice feature, it would be nice to merge #1820

@nrnhines nrnhines merged commit 121d968 into master May 24, 2022
@nrnhines nrnhines deleted the more_mechapi branch May 24, 2022 09:56
ramcdougal pushed a commit to ModelDBRepository/140881 that referenced this pull request May 30, 2022
* Fixed intf_6.mod and misc.h for NEURON 9.0.0, 8.2.0, 8.1.0

* Fixed misc.h, misc.mod, stats.mod and vecst.mod for NEURON 9.0.0, 8.2.0 and 8.1.0

- Small issue with hoc_get_symbol with NEURON 8.2.0 that should be fixed
by neuronsimulator/nrn#1825

* Updated readme

* Fix inclusion of float.h

* fixups for new 8.2 wheels

* Cleanup for merge.

* Object member is called template in C in 8.2

* include with "..." not <...>

* mcell_ran4_init: pass a value

* mcell_ran4_init: update readme

* hashseed2: probable bugfix

* s-0x0 -> s=0x0: probably typo (and compiler warning) fix

Co-authored-by: Olli Lupton <[email protected]>
Co-authored-by: Pramod S Kumbhar <[email protected]>
@alexsavulescu alexsavulescu mentioned this pull request Jun 28, 2022
19 tasks
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.

6 participants