-
Notifications
You must be signed in to change notification settings - Fork 41
In memory model transfer between neuron and coreneuron #114
Conversation
pramodk
commented
Sep 13, 2018
- Merging first draft from Michael to transfer neuron model to coreneuron with DMA
* move coreneuron to coreneuron namespace * fix test to comply to new changes * fix c++ link with mod2c generated files
fixing VERBATIM blocks
…-skip-mpi-finalize command line option
… from inlinin (functions are not getting inlined with cpp)
The namespaces were not correctly nested.
This is the first of a series of transformations to allow CoreNeuron to be embedded in NEURON and simulate the NEURON model without using data files. This change reads the bbcore_mech.dat file as an ifstream or can callback, if embedded, to get the bbcore_mech.dat file information directly from NEURON via a stringstream. In both cases the information is handled by the same mk_mech(std::istream&) function. The binary sentinal value for determining Endian consistency has been removed from bbcore_mech.dat and into a binary file called byteswap1.dat bbcore_write_version has been bumped to 1.2
still read from files). On the NEURON side, the coreneuron library is loaded via the CORENEURONLIB environment variable and a coreneuron simulation is loaded and run via ParallelContext.nrncore_run()
ringtest is not producing good raster.
number of threads, and whether gaps and mpi are being used.
Should be a space separated list of args that would normally be used in launching coreneuron_exec. But no need to pass -mpi.
it is set to nthread.
#include "coreneuron/nrniv/nrn2core_direct.h" | ||
|
||
void* (*nrn2core_get_global_dbl_item_)(void*, const char*& name, int& size, double*& val); | ||
int (*nrn2core_get_global_int_item_)(const char* name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we transfer these to single header? (nrn2core_direct.h)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought they needed a separare declaration in the header (extern) and then a definition in
some file (memory to hold the function pointer)
coreneuron/nrniv/main1.cpp
Outdated
} | ||
} | ||
argc += use_mpi ? 2 : 1; // corenrn -mpi or just corenrn | ||
char** argv = new char*[argc]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corresponding delete missing?
coreneuron/nrniv/main1.cpp
Outdated
argc = 0; | ||
argv[argc++] = strdup("corenrn"); | ||
if (use_mpi) { | ||
argv[argc++] = strdup("-mpi"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corresponding free missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. In general, though, on return from nrncore_run it is not clear at the moment how much access NEURON needs to the coreneuron results. .eg. perhaps there should be an inverse
to nrnbbcore_write. Or, as we mentioned in the paper a series of accessor functions of various grain.
coreneuron/nrniv/main1.cpp
Outdated
int sp = isspace(c) ? 1 : ((c == '\0') ? 1 : 0); | ||
if (inarg && sp) { // start whitespace following previous arg | ||
inarg = 0; | ||
argv[argc++] = strndup(arg + first, i - first); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corresponding free missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safe to free all argv and argv itself on return from nrncore_run.
printf("arg: %s\n", arg); | ||
for (i = 0; i < argc; ++i) { | ||
printf("%d %s\n", i, argv[i]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only rank 0 should print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. unfortunately, coreneuron has not started mpi yet and nrniv did not pass its version of
nrnmpi_myid to nrncore_run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were for debugging and can be removed
|
||
extern "C" { | ||
void (*nrn2core_mkmech_info_)(std::ostream&); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be moved to nrn2core_direct.h?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it needed a unique definition
int& sz, | ||
double*& yvec, | ||
double*& tvec); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if these are declared in nrn2core_direct.h, why we need to declare here again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are all extern. the file is included in multiple places.
I think we should run valgrind to make sure all memory is getting freed in embedded mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subject to my detailed comments you can decide
whether to merge
With respect to valgrind, that is an excellent idea. Note that the ability to make multiple calls to |
2b823a2
to
184e6bd
Compare
@nrnhines : with last two commits I have fixed memory leaks with valgrind. I am not sure about removing event from queue:
Obviously this is not related to this branch though. |
184e6bd
to
9a9e6ca
Compare
- when direct transfer mode is used - memory leaks from previous version
9a9e6ca
to
885d035
Compare
This is the first of a series of transformations to allow CoreNeuron to be embedded in NEURON and simulate the NEURON model without using data files. This change reads the bbcore_mech.dat file as an ifstream or can callback, if embedded, to get the bbcore_mech.dat file information directly from NEURON via a stringstream. In both cases the information is handled by the same mk_mech(std::istream&) function. - binary sentinel value for determining Endian consistency has been removed from bbcore_mech.dat and into a binary file called byteswap1.dat - bbcore_write_version has been bumped to 1.2 - direct transfer of globals.dat info in place - update test dataset - if OMP_NUM_THREADS is not set then it is set to nthread.
…eNeuron#114) This is the first of a series of transformations to allow CoreNeuron to be embedded in NEURON and simulate the NEURON model without using data files. This change reads the bbcore_mech.dat file as an ifstream or can callback, if embedded, to get the bbcore_mech.dat file information directly from NEURON via a stringstream. In both cases the information is handled by the same mk_mech(std::istream&) function. - binary sentinel value for determining Endian consistency has been removed from bbcore_mech.dat and into a binary file called byteswap1.dat - bbcore_write_version has been bumped to 1.2 - direct transfer of globals.dat info in place - update test dataset - if OMP_NUM_THREADS is not set then it is set to nthread. CoreNEURON Repo SHA: BlueBrain/CoreNeuron@f2ccf7f