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

oc_ansi.h: add some definitions used in mods (ModedlDB & BBP) #1811

Merged
merged 7 commits into from
May 12, 2022

Conversation

alexsavulescu
Copy link
Member

In the context of C/C++ MOD compatibility across different versions, the aim is to have as much as possible all NRN "API" in headers so to as not having to declare them in the VERBATIM blocks.

Also #1805 changed nrn_mallinfo signature to return std::size_t

@alexsavulescu alexsavulescu changed the title Mechapi oc_ansi.h: add some definitions used in mods (ModedlDB & BBP) May 9, 2022
@alexsavulescu alexsavulescu requested a review from olupton May 11, 2022 13:48
Copy link
Collaborator

@olupton olupton left a comment

Choose a reason for hiding this comment

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

LGTM, some of this will get reshuffled again in #1597 but I don't see anything really problematic.

src/nrniv/bgpdmasetup.cpp Outdated Show resolved Hide resolved
Comment on lines +289 to +295
extern void* bbss_buffer_counts(int*, int**, int**, int*);
extern void bbss_save_global(void*, char*, int);
extern void bbss_restore_global(void*, char*, int);
extern void bbss_save(void*, int, char*, int);
extern void bbss_restore(void*, int, int, char*, int);
extern void bbss_save_done(void*);
extern void bbss_restore_done(void*);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to say that these are included in a different header in #1597:

/** BBSaveState API
* See save_test_bin and restore_test_bin for an example of the use of this
* following interface. Note in particular the use in restore_test_bin of a
* prior clear_event_queue() in order to allow bbss_buffer_counts to pass an
* assert during the restore process.
*/
/** First call to return the information needed to make the other calls. Returns
* a pointer used by the other methods. Caller is reponsible for freeing (using
* free() and not delete []) the returned gids and sizes arrays when finished.
* The sizes array and global_size are needed for the caller to construct
* proper buffer sizes to pass to bbss_save_global and bbss_save for filling
* in. The size of these arrays is returned in *len. They are not needed for
* restoring (since the caller is passing already filled in buffers that are
* read by bbss_restore_global and bbss_restore. The gids returned are base
* gids. It is the callers responsibility to somehow concatenate buffers with
* the same gid (from different hosts) either after save or before restore and
* preserve the piece count of the number of concatenated buffers for each base
* gid. Global_size will only be non_zero for host 0.
*/
void* bbss_buffer_counts(int* len, int** gids, int** sizes, int* global_size);
/** Call only on host 0 with a buffer of size equal to the global_size returned
* from the bbss_buffer_counts call on host 0 sz is the size of the buffer
* (for error checking only, buffer+sz is out of bounds)
*/
void bbss_save_global(void* bbss, char* buffer, int sz);
/** Call on all hosts with the buffer contents returned from the call to
* bbss_save_global. This must be called prior to any calls to bbss_restore sz
* is the size of the buffer (error checking only). This also does some other
* important restore initializations.
*/
void bbss_restore_global(void* bbss, char* buffer, int sz);
/** Call this for each item of the gids from bbss_buffer_counts along with a
* buffer of size from the corresponding sizes array. The buffer will be filled
* in with savestate information. The gid may be the same on different hosts,
* in which case it is the callers responsibility to concatentate buffers at
* some point to allow calling of bbss_restore. sz is the size of the buffer
* (error checking only).
*/
void bbss_save(void* bbss, int gid, char* buffer, int sz);
/** Call this for each item of the gids from bbss_buffer_counts, the number of
* buffers that were concatenated for the gid, and the concatenated buffer (the
* concatenated buffer does NOT contain npiece as the first value in the char*
* buffer pointer). sz is the size of the buffer (error checking only).
*/
void bbss_restore(void* bbss, int gid, int npiece, char* buffer, int sz);
/** At the end of the save process, call this to cleanup. When this call
* returns, bbss will be invalid.
*/
void bbss_save_done(void* bbss);
/** At the end of the restore process, call this to do some extra setting up and
* cleanup. When this call returns, bbss will be invalid.
*/
void bbss_restore_done(void* bbss);
and that is included in
#include "bbsavestate.h"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will keep an eye out when updating #1597 after merging this one.

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.45%. Comparing base (7bb6808) to head (abcbdf0).
Report is 1783 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1811   +/-   ##
=======================================
  Coverage   45.45%   45.45%           
=======================================
  Files         550      550           
  Lines      113130   113130           
=======================================
  Hits        51423    51423           
  Misses      61707    61707           

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

@alexsavulescu alexsavulescu merged commit a8e9dcc into master May 12, 2022
@alexsavulescu alexsavulescu deleted the mechapi branch May 12, 2022 20:56
@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.

3 participants