SpineML / SpineML_2_BRAHMS

Code generation scripts to run a SpineML neural model using BRAHMS on standard CPUs
http://spineml.github.io/simulators/BRAHMS/
4 stars 3 forks source link

dataType is not correctly initialized in externalInput component.cpp #7

Closed sebjameswml closed 9 years ago

sebjameswml commented 10 years ago

See the component event method. The dataType member attribute is used uninitialized in a couple of locations.

It's not clear how we decide what dataType should be (whether analog, event or impulse). Is there anything in the XML that tells us this (ping @ajc158 )?

Here's an example ExternalInput node from an experiment.xml file:

<ExternalInput target="CTX - Cortex to D1 to D1 - MSN Synapse 0 postsynapse"
  port="v" name="realtime" tcp_port="50099" size="1" command=""
  host="127.0.0.1" timestep="0"/>

Does anything in there get translated into the SystemML node?

ajc158 commented 10 years ago

Hi Seb, the dataType should be passed in and then checked against the dataType received from the input. Seems that the uninitialised dataType always ends up as 0 (though this isn't something that can or should be relied on!). I'll get on and fix this. There is nothing in the component to receive the dataType certainly.

sebjameswml commented 10 years ago

Ok, no problem. I just initialized the value to analog and it works now On Jun 12, 2014 1:41 PM, "ajc158" notifications@github.com wrote:

Hi Seb, the dataType should be passed in and then checked against the dataType received from the input. Seems that the uninitialised dataType always ends up as 0 (though this isn't something that can or should be relied on!). I'll get on and fix this.

— Reply to this email directly or view it on GitHub https://github.com/SpineML/SpineML_2_BRAHMS/issues/7#issuecomment-45885990 .

sebjameswml commented 10 years ago

Oh, another thing Alex, what is the "size" for an external input? It seems to initialise to 1.

Oh, now I found it - it's 1 sizeof(double).

sebjameswml commented 10 years ago

This is confusing - the size in the SpineCreator code (this is the number that ends up in experiment.xml) seems to be referring to "number of doubles"

However, in the client code in SpineML_2_BRAHMS, size seems to be "number of bytes":

bool spineMLNetworkClient::sendData(char * ptr, int size)
{
    // send data
    int sent_bytes = 0;
    while (sent_bytes < size)
        sent_bytes += send(sockfd,ptr+sent_bytes,size, MSG_DONTWAIT);

Any comments @ajc158 ?

ajc158 commented 10 years ago

Yep, the conversion is done in the externalInput and externalOutput component.cpp - I think this was so that the .cpp file was not simulator specific - different simulators may use different precision - all you know is the number of values you are sending... Maybe this should be standardised and the simulator should use the client interface to tell the external program what data type it requires, or convert to that data type from a standard communication data type...

ajc158 commented 10 years ago

Reading that again I don't think it makes sense! This needs standardising

sebjameswml commented 10 years ago

I think there's a bit of a mixture of "size means bytes" in some cases (such as spineMLNetworkClient::recvData) but also "size means number of doubles" in other cases, such as when spineMLNetworkClient::createClient(string hostname, int port, int size, dataTypes datatype, int targetOrSource) is called from the component.cpp code with size=1, which came in from the experiment.xml file and the definition of the externalInput therein.

ajc158 commented 10 years ago

The size of the externalInput is written by SpineCreator based on the size of the population etc.. you are inputing to. I cannot be set by the user because there is no reason that the user would need to set it...

sebjameswml commented 10 years ago

how do you mean "based on the size of the population". Is it not just the size of the number which you are transmitting into the externalInput for each timestep?

ajc158 commented 10 years ago

Each timestep you will transmit 'size' values - in the example of a neural population size N this would be one current input for each of the N neurons in that population at each timestep...

ajc158 commented 10 years ago

Spikes would have to be handled differently

sebjameswml commented 10 years ago

Ok. That sounds ok. And the values are ALWAYS doubles, right?

ajc158 commented 10 years ago

Yep, I have no intention of supporting anything else for the forseeable (other precisions/types wouldn't be very useful in most cases anyway).

sebjameswml commented 10 years ago

Commit 44e42b886 initialises the dataType to ANALOG.

sebjameswml commented 9 years ago

Closing as I think the commit above addresses this ok.