genn icon indicating copy to clipboard operation
genn copied to clipboard

general index into GeNN variables

Open tnowotny opened this issue 5 years ago • 3 comments

When we created GeNN, there was a conscious decision to have variables with meaningful names, e.g. V, m, h, n, etc instead of v[0], v[1], v[2], ... However, at times it would be really nice to just iterate over all variables, e.g. write them all to disk, or initialise them in a loop etc. Should we just automatically generate a C array of pointers into the variables to help with this? E.g. SET_VARS({{"V", "scalar"},{"m", "scalar"},{"h","scalar"},{"NA","scalar"},{"NB","scalar"}}) model.addNeuronPopulation<model>("POP1", ...); would currently create scalar *VPOP1, *mPOP1, ... The suggestion would be to also create void *_vPOP1[]; where _vPOP1[0]= VPOP1, _vPOP1[1]= mPOP1 etc. @neworderofjamie , does this make any sense at all?

tnowotny avatar Sep 10 '19 19:09 tnowotny

Hmmm, it does make sense, but I'm not really sure if I think it's a good idea. Firstly, void pointers are a somewhat frowned upon/easy to shoot yourself in the foot with thing to present to the users. Secondly, I can't really think of a lot of use cases where models have enough state variables that you would want to access externally to make it worthwhile (and in those cases you can make void arrays of their state variables yourself unless you also have a profusion of different model types).

Personally I think the solution to this, like the issue with having large numbers of populations you want to do the same thing to (remember this horrorshow), is to use the 'shared library model' approach where you can get variable pointers by name - as this seems a generally useful thing and copy-and-pasted in several places now, I was thinking of making this 'official' and including a user-friendly version with the next GeNN

neworderofjamie avatar Sep 13 '19 08:09 neworderofjamie

we can continue discussion offline - I am not entirely sure I understand how the 'shared library model approach' relates to this ... but I don't think I am aware of the details of this approach at all ;-)

tnowotny avatar Sep 13 '19 10:09 tnowotny

Sure! :+1:

neworderofjamie avatar Sep 13 '19 10:09 neworderofjamie