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

Callback from CoreNEURON to help transfer data to NEURON. #717

Merged
merged 13 commits into from
Aug 26, 2020
Merged

Conversation

nrnhines
Copy link
Member

@nrnhines nrnhines commented Aug 18, 2020

Help for the transfer of voltage, i_membrane_, and mechanism data.
Strategy is to pass a pointer which is used by CoreNEURON to copy
data which may have been reordered due to SoA and permutation.

Interacts with BlueBrain/CoreNeuron#382

Help for the transfer of voltage, i_membrane_, and mechanism data.
Strategy is to pass a pointer which is used by CoreNEURON to copy
data which may have been reordered due to SoA and permutation.
@nrnhines nrnhines marked this pull request as ready for review August 23, 2020 12:36
typedef std::pair<int, double**> Deferred_pair;
typedef std::map<int, Deferred_pair> Deferred_map;
typedef std::vector<Deferred_map> Deferred_Type2ArtData;
//typedef std::vector<std::map<int, std::pair<int, double**> > > Deferred_Type2ArtData;
Copy link
Member Author

Choose a reason for hiding this comment

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

What is the right way to do this. I had trouble with the combined typedef.

Copy link
Member

Choose a reason for hiding this comment

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

typedef std::vector<std::map<int, std::pair<int, double**> > > Deferred_Type2ArtData;

should compile. do you see any error?

alternatively, C++11 way is to use using.

using Deferred_Type2ArtData = std::vector<std::map<int, std::pair<int, double**>>>;

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.

I will take detailed look bit later but just quick comments here.

typedef std::pair<int, double**> Deferred_pair;
typedef std::map<int, Deferred_pair> Deferred_map;
typedef std::vector<Deferred_map> Deferred_Type2ArtData;
//typedef std::vector<std::map<int, std::pair<int, double**> > > Deferred_Type2ArtData;
Copy link
Member

Choose a reason for hiding this comment

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

typedef std::vector<std::map<int, std::pair<int, double**> > > Deferred_Type2ArtData;

should compile. do you see any error?

alternatively, C++11 way is to use using.

using Deferred_Type2ArtData = std::vector<std::map<int, std::pair<int, double**>>>;

@pramodk
Copy link
Member

pramodk commented Aug 23, 2020

travis ci test is failing :

11:  Start time (t) = 0
445211: 
445311:  Memory (MBs) :  After mk_spikevec_buffer : Max 50.4492, Min 50.4492, Avg 50.4492 
445411:  Memory (MBs) :     After nrn_finitialize : Max 50.4492, Min 50.4492, Avg 50.4492 
445511: 
4456 Additional mechanisms from files
445711:  fornetcon.mod invlfire.mod sample.mod
445811: 
445911/12 Test #11: coreneuron_datareturn_py .........***Exception: SegFault  0.45 sec

CoreNEURON allocates some pad space even if real size of nodes is 0.
So cannot decide whether to copy data or change the
return pointers based on whether the pointer is NULL.
@nrnhines
Copy link
Member Author

nrnhines commented Aug 24, 2020

445911/12 Test #11: coreneuron_datareturn_py .........***Exception: SegFault 0.45 sec

This is consistent on travis but I have so far been unable to reproduce the segfault on my desktop. It appears that travis is using the correct CoreNeuron.
Submodule path 'external/coreneuron': checked out 3545096f3
I guess the first puzzling thing is the appearance after the first

11:  Memory (MBs) :     After nrn_finitialize : Max 50.3164, Min 50.3164, Avg 50.3164 

of a repeated

11: 
4456 Additional mechanisms from files
445711:  fornetcon.mod invlfire.mod sample.mod

Copy link
Member

@alexsavulescu alexsavulescu left a comment

Choose a reason for hiding this comment

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

LGTM, good for merge when segfault is fixed.

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.

Almost good to merge. I have few remarks, could you take a look?

Comment on lines +358 to +360
if (corenrn_direct && nrn_nthread > 0) {
deferred_type2artdata.resize(nrn_nthread);
}
Copy link
Member

Choose a reason for hiding this comment

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

I didn't understand why we are resizing to nrn_nthread in part2_clean function. I expected to completely delete deferred_type2artdata in cleanup function?

Copy link
Member Author

Choose a reason for hiding this comment

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

I improved the comment to:

  // clean up the art Memb_list of CellGroup[].mlwithart
  // But if multithread and direct transfer mode, defer deletion of
  // data for artificial cells, so that the artificial cell ml->data
  // can be used when nrnthreads_type_return is called.

I think it also helps to see the comment in nrnthreads_type_return, which gives the justification for all this.

     // The single thread case is easy
...
        // mk_tml_with_art() created a cgs[id].mlwithart which appended
        // artificial cells to the end. Turns out that
        // cellgroups_[tid].type2ml[type]
        // is the Memb_list we need. Sadly, by the time we get here, cellgroups_
        // has already been deleted.  So we defer deletion of the necessary
        // cellgroups_ portion (deleting it on return from nrncore_run).

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