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

Conversation

pramodk
Copy link
Collaborator

@pramodk pramodk commented Sep 13, 2018

  • Merging first draft from Michael to transfer neuron model to coreneuron with DMA

fouriaux and others added 30 commits March 27, 2018 14:45
* move coreneuron to coreneuron namespace
* fix test to comply to new changes
* fix c++ link with mod2c generated files
… 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.
#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);
Copy link
Collaborator Author

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)

Copy link
Collaborator

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)

}
}
argc += use_mpi ? 2 : 1; // corenrn -mpi or just corenrn
char** argv = new char*[argc];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

corresponding delete missing?

argc = 0;
argv[argc++] = strdup("corenrn");
if (use_mpi) {
argv[argc++] = strdup("-mpi");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

corresponding free missing?

Copy link
Collaborator

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.

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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

corresponding free missing?

Copy link
Collaborator

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]);
}
Copy link
Collaborator Author

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?

Copy link
Collaborator

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

Copy link
Collaborator

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&);
}
Copy link
Collaborator Author

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?

Copy link
Collaborator

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);

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

@pramodk
Copy link
Collaborator Author

pramodk commented Sep 13, 2018

I think we should run valgrind to make sure all memory is getting freed in embedded mode.

Copy link
Collaborator

@nrnhines nrnhines left a 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

@nrnhines
Copy link
Collaborator

With respect to valgrind, that is an excellent idea. Note that the ability to make multiple calls to
pc.nrncore_run(string) has not been thought through yet.

@pramodk pramodk force-pushed the nrn2coredirect_master branch from 2b823a2 to 184e6bd Compare October 1, 2018 22:08
@pramodk
Copy link
Collaborator Author

pramodk commented Oct 1, 2018

@nrnhines : with last two commits I have fixed memory leaks with valgrind. I am not sure about removing event from queue:

==53751== 96 bytes in 2 blocks are definitely lost in loss record 79 of 118
==53751==    at 0x100099616: malloc (in /usr/local/Cellar/valgrind/3.13.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==53751==    by 0x10135BE0D: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==53751==    by 0x1000F668B: coreneuron::TQueue<(coreneuron::container)1>::insert(double, void*) (tqueue.ipp:243)
==53751==    by 0x1000F5294: coreneuron::NetCvode::event(double, coreneuron::DiscreteEvent*, coreneuron::NrnThread*) (netcvode.cpp:251)
==53751==    by 0x100101331: coreneuron::NetParEvent::send(double, coreneuron::NetCvode*, coreneuron::NrnThread*) (netpar.cpp:132)
==53751==    by 0x100101BEF: coreneuron::nrn_spike_exchange_init() (netpar.cpp:306)
==53751==    by 0x10011C69E: coreneuron::checkpoint_initialize() (nrn_checkpoint.cpp:860)
==53751==    by 0x1000D3F7A: solve_core (main1.cpp:396)
==53751==    by 0x100001F81: main (coreneuron.cpp:33)

Obviously this is not related to this branch though.

@pramodk pramodk force-pushed the nrn2coredirect_master branch from 184e6bd to 9a9e6ca Compare October 1, 2018 22:14
    - when direct transfer mode is used
    - memory leaks from previous version
@pramodk pramodk force-pushed the nrn2coredirect_master branch from 9a9e6ca to 885d035 Compare October 1, 2018 22:16
@pramodk pramodk merged commit f2ccf7f into master Oct 3, 2018
iomaganaris pushed a commit that referenced this pull request Mar 6, 2019
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.
@pramodk pramodk deleted the nrn2coredirect_master branch December 4, 2020 18:14
pramodk added a commit to neuronsimulator/nrn that referenced this pull request Nov 2, 2022
…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
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.

3 participants