-
Notifications
You must be signed in to change notification settings - Fork 372
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
Make thread id available inside connection's constructor and set_status #2921
Conversation
@heplesser Could you review this or alternatively choose another reviewer? |
@heplesser the functions For example, if the NESTML model contains:
The equivalent NEST code would be: template < typename targetidentifierT >
stdp_stp__with_lif_sorn< targetidentifierT >::stdp_stp__with_lif_sorn() : ConnectionBase()
{
P_.U = ((0.5) + (0.25) * nest::normal_distribution( nest::get_vp_specific_rng( get_thread() ) )); // as real
...
} The above code results in a compilation error for Adding @jougs as a reviewer since we had discussions regarding this. |
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.
As discussed in the NEST Kernel Team meeting on Thursday, passing the thread around should not be necessary since in almost all cases the synaptic parameters will be drawn by the thread responsible for the target neuron, so just getting the current thread will give the necessary information.
The next step will be to check this. If this holds, code could be much simplified.
Pull request automatically marked stale! |
@JanVogelsang @pnbabu As I pointed out earlier, I think we can just use Do you think this is a viable idea? @pnbabu Could you test this with code generated from NESTML? |
Yes, that sounds like a good idea. |
I will close this PR now in favour of a different solution as discussed above. |
This PR solves #2902. Some model parameters could potentially depend on the RNG (see NESTML), while each generator is bound to a specific thread. Currently, connections (i.e., synapses) are not aware of the thread that they correspond to. One solution would be to add the thread id to the connection class. However, while this wouldn't increase the total object size in the case of index-based node targeting (HPC case,
TargetIdentifierIndex
) due to a 16-bit padding that is currently unused, it would possibly increase the size when using the pointer-based node targeting (non-HPC case,TargetIdentifierPtrRport
). In theory, it could be possible to restructure the connection class members in order to include the thread id in both cases without increasing the total object size, however this would not be guaranteed for all systems/architectures.Another solution would be to simply pass the thread id as parameter to all relevant functions of the connection class. When calling a function on a connection, it will always happen inside a threaded environment, therefore the thread id will always be available at that time. The only exception are default connections, which are not bound to a specific thread. In these cases however, the RNG of the main thread (thread id 0) can be used, if required at all.