Passing a float from the Core to the Host: error!

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Passing a float from the Core to the Host: error!

Postby claudio4parallella » Sun Sep 03, 2017 12:27 pm

Please I'm kindly asking anybody could help me in my aim to exchange float from Host to Core and back from Core to Host.

Here my unsuccesfull attempt to send as individual input a Float value from the Core to the Host:

Core side:
Code: Select all
e_memseg_t omem00;
char outputMsg[]="%f";
char bufOutput[256]={0};
float myFloat=11.22;
snprintf(bufOutput, sizeof(bufOutput), outputMsg, myFloat);
if (omem00.size>=strlen(bufOutput)+1)
{
  e_write((void*)&omem00, bufOutput, my_row, my_col,NULL,strlen(bufOutput)+1);
}


Host side:
Code: Select all
e_read(&bufOutput00,0,0,0,bufOutputMem,outputSize);
float fvalue=atof(bufOutputMem);
printf("Core00 Output = %s float = %3.3f\n",bufOutputMem, fvalue);


A buffer works only if from Core side I use:

Code: Select all
snprintf(bufOutput, sizeof(bufOutput), "55.66");


The same unsolved problem is when I send from Host to Core a float.

Is there any example please?

Where am I worng? Thanks a lot
claudio4parallella
 
Posts: 68
Joined: Thu Aug 10, 2017 3:48 pm

Re: Passing a float from the Core to the Host: error!

Postby claudio4parallella » Sun Sep 03, 2017 8:26 pm

Well, after lot of attempts, it seems to me impossible to work with Input Output of float from Core to Host and viceversa.

I cannot find a way to send from HOST to CORE a float or double value and receive back from CORE to HOST the result as float or double.

The /epiphany-examples/apps/dotproduct is calculating c[i]=a[i]*b[i] as integer. Nothing to do if a, b, c are float.

FIRST ATTEMPT: maibox
When using "mailnbox" to transfer via buffer the values Host->Core it's impossible to have a float number because impossible to have something like atof().
Back Core->Host using "mailbox" and buffer it's possible because host is giving atof();

SECOND ATTEMPT: core memory
Using core memory it's ok Core->Host using pointers (core) and e_read (host).
Back from Host->Core it's impossible to me to have a float or double on the core side.

I cannot believe that Parallella - Epiphany cannot manage data transfer that involve float or not integer values.

Anybody could help my ignorance about to do it please?

Thanks a lot in advance
claudio4parallella
 
Posts: 68
Joined: Thu Aug 10, 2017 3:48 pm

Re: Passing a float from the Core to the Host: error!

Postby Sarahah » Tue Sep 05, 2017 11:38 am

claudio4parallella wrote:I cannot find a way to send from HOST to CORE a float or double value and receive back from CORE to HOST the result as float or double.


I agree with this point.
Sarahah
 
Posts: 1
Joined: Tue Sep 05, 2017 10:44 am

Re: Passing a float from the Core to the Host: error!

Postby claudio4parallella » Tue Sep 05, 2017 7:59 pm

ok! it works!

Using core memory ok Float core->host and host->core

Using shared memory ok Float from core->host, not opposite because missing atof(buffer).

So it almost works.
claudio4parallella
 
Posts: 68
Joined: Thu Aug 10, 2017 3:48 pm


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 5 guests