eCores not producing results correctly

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

eCores not producing results correctly

Postby sommaz » Thu Dec 11, 2014 12:50 pm

Hi,
I am using epiphany III based board(16 cores). I am trying to generate 0 to 127 natural numbers and add them.
To achieve this, I am loading a program into a workgroup ((0, 0), (0,1),(1,0), (1,1) ) to generate the numbers and other similar workgroup ((0, 2), (0,3),(1,2), (1,3) ) to add them. When I am using same code for single core to generate nos and another single core to add them, they works fine.
I must get 8128 from all ecores but I am not getting.
Snapshot of my output is given as ATTACHMENT. Different values in different runs..
Any help..
Attachments
output.png
Snapshot of the output
output.png (99.78 KiB) Viewed 4354 times
sommaz
 
Posts: 9
Joined: Thu Sep 04, 2014 8:57 am

Re: eCores not producing results correctly

Postby notzed » Sat Dec 13, 2014 8:19 am

Without seeing the code it's hard to say.

It's probably just that your programme is not handling concurrency or the memory quirks correctly.

addend: i subsequently saw your post in the sdk forum, presumably it's the same problem.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: eCores not producing results correctly

Postby sommaz » Mon Dec 15, 2014 10:20 am

notzed wrote:Without seeing the code it's hard to say.

It's probably just that your programme is not handling concurrency or the memory quirks correctly.
addend: i subsequently saw your post in the sdk forum, presumably it's the same problem.


Thanks for your reply. To handle the concurrency I am using flag.
This host program will load two eCores. One eCore will generate natural numbers and other will add them. Finally, will be displayed via host.
Please have a look into my code and give your valuable idea..
Host side code
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "include.h"
#include <e-hal.h>
int main(int argc, char *argv[])
{
   unsigned  int  i, j, data, pos = 0, loc,  done=0, count, cid, _r[_BufSize], result = 0;
   e_platform_t platform;
   e_epiphany_t dev;

   e_init(NULL);
   e_reset_system();
   e_get_platform_info(&platform);

   e_open(&dev, 0, 0, platform.rows, platform.cols); // open all teh cores
   e_reset_group(&dev);

   //Set the row, col, flags
   for(i= 0; i<2; i++){
      for(j=0; j<2; j++){
         pos = j+2;
         e_write(&dev, i, j, ROW, &i, sizeof(unsigned int ));    //Row
         e_write(&dev, i, j, COL, &pos, sizeof(unsigned int));   // Col
         e_load("e_actor2.srec", &dev, i, pos, E_TRUE);  //Loading to only specific cores
      }
   }
   //Loading the program into the cores
   e_load_group("e_actor1.srec", &dev, 0, 0, 2, 2, E_TRUE);
   do{
      count = 0;
      pos = 0;
      for(i= 0; i<2; i++){
         for(j=0; j<2; j++){
            pos = j+2;
            e_read(&dev, i, pos, 0x7000, &done, sizeof(int));
            count = count + done;
         }
      }
   }while(count!=4);   

   for(i= 0; i<2; i++){
      for(j=0; j<2; j++){
         pos = j + 2;
         e_read(&dev, i, pos, 0x4000, &data, sizeof(unsigned int));
         result = result + data;
         e_read(&dev, i, pos, 0x5000, &cid, sizeof(unsigned int));
         printf("%d -- 0x%03x \n", data, cid);
         e_read(&dev, i, pos, 0x2000, _r, _BufSize);
         for(loc = 0 ; loc < 128; loc ++ ){
            printf("%d ", _r[loc]);
         }
         printf("\n");
      }
   }

   printf("Final Result : %d \n", result);   
   e_close(&dev);
   e_finalize();
   return 0;
}


Code for Generating the natural numbers:
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "e-lib.h"
#include "include.h"
int  out_fifo[_BufSize] SECTION(".data_bank2"); // data_bank2  is for implementing the output  Fifo
int main(int argc, char *argv[]) {
        unsigned int  *row, *col, j,  *_from, *_to;
        unsigned *src, *dst;

        row = (unsigned int *) ROW;     // Getting row
        col = (unsigned int *) COL;     // Getting col
        _to = (unsigned int *) 0x5000;
        _from = (unsigned int *) 0x6000;

        for ( j = 0 ; j < SIZE; j++ )
        {
                out_fifo[j] = j;
        }
        //Copying the data to next core
        src = (unsigned int  *) (out_fifo);
        dst = (unsigned int  *) e_get_global_address(*row, *col, (unsigned *) 0x2000);
        e_memcopy(dst, src, _BufSize); // Full buffer copy to the specific core

        //Alerting the nect core
        *_to = 0x00000001;
        e_write(&e_group_config, _to, *row, *col, _from, sizeof(unsigned int));

        return 0;
}


Code for Adding them..
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "e-lib.h"
#include "include.h"

int main(int argc, char *argv[]){

        unsigned int i, result=0,  *_core, *val, *flag, *info, *_output;
        e_coreid_t coreid;
        coreid = e_get_coreid();

        // GET THE VALUES  AND ADD THEM
        val = (unsigned int *) 0x2000;
        info = (unsigned int *) 0x6000;
        _output = (unsigned int *) 0x4000;
        _core = (unsigned int *) 0x5000;
        flag = (unsigned int *) 0x7000;
        while(1){
                if(*info == 1){
                        for( i = 0; i < SIZE; i++)
                        {
                                result = result + *val;
                                val++;
                        }
                        *_output = result;
                        *_core = coreid;
                        *flag = 0x00000001;
                        return EXIT_SUCCESS;
                }
        }
}


Thanks for your help...
sommaz
 
Posts: 9
Joined: Thu Sep 04, 2014 8:57 am


Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 1 guest

cron