예제 #1
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i, j, m, n, k;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t emem;
	char emsg[_BufSize];
	unsigned num;
	unsigned counter = 0;
	srand(1);

	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	//e_set_host_verbosity(H_D2);
	//e_set_loader_verbosity(L_D1);
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

	// Allocate a buffer in shared external memory
	// for message passing from eCore to host.
	e_alloc(&emem, _BufOffset, _BufSize);	
	
    	// Open a workgroup
	e_open(&dev, 0, 0, platform.rows, platform.cols);
	
	
	// Load the device program onto core (0,0)
	e_load("e_mutex_test0.srec", &dev, 0, 0, E_TRUE);

	usleep(10000);
	// Load the device program onto all the other eCores
	e_load_group("e_mutex_test.srec", &dev, 0, 1, 1, 3, E_TRUE);
	e_load_group("e_mutex_test.srec", &dev, 1, 0, 3, 4, E_TRUE);
	
	usleep(100000);
	

			
		// Wait for core program execution to finish
		// Read message from shared buffer
				
		e_read(&dev, 0, 0, 0x6200, &num, sizeof(num));
		e_read(&dev, 0, 0, 0x6300, &counter, sizeof(counter));

		// Print the message and close the workgroup.
		fprintf(stderr, "The counter now is %d!\n", counter);
		fprintf(stderr, "The clock cycle is %d!\n", num);
		
	// Close the workgroup
	e_close(&dev);
	
	// Release the allocated buffer and finalize the
	// e-platform connection.
	e_free(&emem);
	e_finalize();

	return 0;
}
예제 #2
0
int main()
{
    //counters for row and colum, cored id and loop counter
    unsigned   row_loop,col_loop;
    // this will contain the epiphany platform configura tion
    e_platform_t epiphany;
    e_epiphany_t dev;
    e_mem_t memory;
    e_mem_t memory2;
    int  message;
    int  core1;
    int  core2;
    int  message2;
    e_return_stat_t result;


    e_init(NULL); // initialise the system establish connection to the Device
    e_reset_system(); // reset the epiphnay chip
    e_get_platform_info(&epiphany);//gets the configuration info for the parallella platofrm


    for(row_loop=0; row_loop <4; row_loop ++)
    {
        for(col_loop=0; col_loop <3; col_loop = col_loop+2)
        {
            //one core within the parallella work group is 1 x 2 i.e dual core
            e_open(&dev,row_loop,col_loop,1,2);
            //reset the group
            e_reset_group(&dev);
            //load the group
            result =  e_load("hello_world.srec",&dev,0,0,E_FALSE);
            if (result != E_OK) {
                fprintf(stderr,"Error Loading the Epiphany Application 1 %i\n", result);
            }

            result =  e_load("hello_world2.srec",&dev,0,1,E_FALSE);
            if (result != E_OK) {
                fprintf(stderr,"Error Loading the Epiphany Application 2 %i\n", result);
            }
            e_start_group(&dev);
            usleep(10000);
            e_read(&dev,0,0,0x3000, &message, sizeof(int));
            e_read(&dev,0,0,0x3004, &core1,sizeof(int));
            e_read(&dev,0,1,0x3000, &message2, sizeof(int));
            e_read(&dev,0,1,0x3004, &core2,sizeof(int));
            fprintf(stderr,"message from  core %d ", core1);
            fprintf(stderr,"core id  = 0x%03x \n", message);
            fprintf(stderr,"message from  core %d ", core2);
            fprintf(stderr,"core id = 0x%03x \n", message2);
            e_close(&dev);
        }
    }

    e_free(&memory);
    e_finalize();

    return 0;

}
예제 #3
0
int main(int argc, char *argv[]){

  //Open
  e_init(NULL);
  e_reset_system();
  e_finalize();  
  return 0;
}
int main(int argc, char *argv[])
{
  int result, fail;
  
  fd = stderr;
  
  pEpiphany = &Epiphany;
  pERAM     = &ERAM;
  
  e_set_host_verbosity(H_D0);

  if ( E_OK != e_init(NULL) ) {
      fprintf(stderr, "\nERROR: epiphinay initialization failed!\n\n");
      exit(1);
  }

  if (E_OK != e_reset_system() ) {
      fprintf(stderr, "\nWARNING: epiphinay system rest failed!\n\n");
  }

  // prepare ERAM
  if (E_OK != e_alloc(pERAM, 0x00000000, e_platform.emem[0].size))
  {
      fprintf(stderr, "\nERROR: Can't allocate Epiphany DRAM!\n\n");
      exit(1);
  }
  e_set_host_verbosity(H_D0);
  
  if (E_OK != e_open(pEpiphany, 0, 0, e_platform.rows, e_platform.cols))
  {
      fprintf(stderr, "\nERROR: Can't establish connection to Epiphany device!\n\n");
      exit(1);
  }
  
  
  fail = 0;
  
  
  
  //////////////////////////////
  // Test Host-Device throughput
  SRAM_speed();
  ERAM_speed();
  DRAM_speed();
  
  /////////////////////////////
  // Test eCore-ERAM throughput
  result = EPI_speed();

  //Finalize
  e_close(pEpiphany);
  e_free(pERAM);
  e_finalize();
  
  /////////////////////////////
  //For now, always pass
  return EXIT_SUCCESS;
}
예제 #5
0
int main(int argc, char *argv[]){

  e_platform_t platform;
  e_epiphany_t dev;
  char emsg[_BufSize];
  

  unsigned int row, col;
  unsigned int data, led_state;
  int i,j;
 
  //Open
  e_init(NULL);
  e_get_platform_info(&platform);
  e_open(&dev, 0, 0, platform.rows, platform.cols);

  //Put Code here
  printf("CORE\tCONFIG\t\tSTATUS\t\tPC\t\tDEBUG\t\tIRET\t\tIMASK\t\tILAT\t\tIPEND\n");
  printf("------------------------------------------------------------------");
  printf("------------------------------------------------------------------\n");
  for (i=0; i<platform.rows; i++) {
    for (j=0; j<platform.cols; j++) {     
      printf("(%02d,%02d)\t", i,j);

      e_read(&dev, i, j, 0xf0400, &data, sizeof(unsigned));//config 
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf0404, &data, sizeof(unsigned));//status 
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf0408, &data, sizeof(unsigned));//pc 
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf040C, &data, sizeof(unsigned));//debug
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf0420, &data, sizeof(unsigned));//iret 
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf0424, &data, sizeof(unsigned));//imask 
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf0428, &data, sizeof(unsigned));//ilat
      printf("0x%08x\t",data);

      e_read(&dev, i, j, 0xf0434, &data, sizeof(unsigned));//ipend 
      printf("0x%08x\t",data);
      printf("\n");
    }
  }

  //Close
  e_close(&dev);
  e_finalize();
  
  return 0;
}
예제 #6
0
static void
epiphany_fini(struct epiphany_state *state)
{
	e_close(&state->dev);
	e_finalize();

	free(state->twiddle);
	free(state->data);
}
예제 #7
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t emem;
	char emsg[_BufSize];

	srand(1);

	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

	// Allocate a buffer in shared external memory
	// for message passing from eCore to host.
	e_alloc(&emem, _BufOffset, _BufSize);

	for (i=0; i<_SeqLen; i++)
	{
		// Draw a random core
		row = rand() % platform.rows;
		col = rand() % platform.cols;
		coreid = (row + platform.row) * 64 + col + platform.col;
		fprintf(stderr, "%3d: Message from eCore 0x%03x (%2d,%2d): ", i, coreid, row, col);

		// Open the single-core workgroup and reset the core, in
		// case a previous process is running. Note that we used
		// core coordinates relative to the workgroup.
		e_open(&dev, row, col, 1, 1);
		e_reset_group(&dev);

		// Load the device program onto the selected eCore
		// and launch after loading.
		e_load("e_hello_world.srec", &dev, 0, 0, E_TRUE);

		// Wait for core program execution to finish, then
		// read message from shared buffer.
		usleep(100000000);
		e_read(&emem, 0, 0, 0x0, emsg, _BufSize);

		// Print the message and close the workgroup.
		fprintf(stderr, "\"%s\"\n", emsg);
		e_close(&dev);
	}

	// Release the allocated buffer and finalize the
	// e-platform connection.
	e_free(&emem);
	e_finalize();

	return 0;
}
static void epiphany_thread_shutdown(__maybe_unused struct thr_info *thr)
{
	e_epiphany_t *dev = &thr->cgpu->epiphany_dev;
	e_mem_t *emem = &thr->cgpu->epiphany_emem;

	e_close(dev);
	e_free(emem);
	e_finalize();

}
예제 #9
0
int main(int argc, char *argv[]){

  e_platform_t platform;
  e_epiphany_t dev;

  unsigned int read_buffer[RAM_SIZE/4];
  unsigned int read_data;
  unsigned int i,j;
  int row0,col0,rows,cols,slow;
  unsigned addr,k;

  if(argc < 2){
    usage();
    return EXIT_FAILURE;
  }
  else{
    row0  = atoi(argv[1]);
    col0  = atoi(argv[2]);
    rows  = atoi(argv[3]);
    cols  = atoi(argv[4]);
    slow  = 0;//atoi(argv[5]);
  }
  //Open
  e_init(NULL);
  e_get_platform_info(&platform);
  e_open(&dev, 0, 0, platform.rows, platform.cols);

  //Put Code here
  printf("(ROW,COL)   ADDRESS   DATA\n");
  printf("-----------------------------\n");
  for (i=row0; i<(row0+rows); i++) {
    for (j=col0; j<(col0+cols); j++) {           
      if(slow>0){
	for(k=0;k<RAM_SIZE/4;k++){
	  addr=4*k;
	  e_read(&dev, i, j, addr, &read_data, sizeof(int));
	  read_buffer[k]=read_data;
	  //printf("addr=%x data=%x\n",addr,read_data);
	}
      }
      else{
	e_read(&dev, i, j, 0x0, &read_buffer, RAM_SIZE);
      }
      for(k=0;k<RAM_SIZE/4;k++){
	printf("(%2d,%2d)     0x%08x   0x%08x\n",i,j,k*4,read_buffer[k]);
      }
    }
  }
  //Close
  e_close(&dev);
  e_finalize();
  
  //Always return sucess if it runs to completion
  return EXIT_SUCCESS;
}
예제 #10
0
int main()
{
    //counters for row and colum, cored id and loop counter
    unsigned   row_loop,col_loop;
    // this will contain the epiphany platform configuration
    e_platform_t epiphany;
    e_epiphany_t dev;
    e_return_stat_t result;

    int  message;
    int  message2;
    int loop;
    int addr;;

    e_init(NULL); // initialise the system establish connection to the Device
    e_reset_system(); // reset the epiphnay chip
    e_get_platform_info(&epiphany);//gets the configuration info for the parallella platofrm


    //one core within the parallella work group is 1 x 2 i.e dual core
    e_open(&dev,0,0,1,2);
    //reset the group
    e_reset_group(&dev);
    //load the group
    result =  e_load("hello_world.srec",&dev,0,0,E_FALSE);
    if (result != E_OK) {
        fprintf(stderr,"Error Loading the Epiphany Application 1 %i\n", result);
    }

    result =  e_load("hello_world2.srec",&dev,0,1,E_FALSE);
    if (result != E_OK) {
        fprintf(stderr,"Error Loading the Epiphany Application 2 %i\n", result);
    }
    e_start_group(&dev);
    usleep(10000);

    fprintf(stderr,"extracting from core memory \n ");
    addr = 0x3000;

    for(loop = 0; loop <20; loop ++) {

        e_read(&dev,0,1,addr, &message, sizeof(int));
        if (loop == 0)
            fprintf(stderr,"message from  core 0x%03x \n ", message);
        else
            fprintf(stderr,"message from  core %d \n ", message);
        addr = addr+0x04;
    }
    e_close(&dev);
    e_finalize();
    fprintf(stderr,"demo complete \n ");
    return 0;

}
예제 #11
0
/**
 * Finalises the cores and shuts then down
 */
void finaliseCores(void) {
	if (e_close(&epiphany)) {
		fprintf(stderr, "\nERROR: Can't close connection to Epiphany device!\n\n");
		exit(1);
	}
	if (e_free(&management_DRAM)) {
		fprintf(stderr, "\nERROR: Can't release Epiphany DRAM!\n\n");
		exit(1);
	}

	e_finalize();
}
예제 #12
0
int main(int argc, char *argv[]){

  unsigned int read_buffer[RAM_SIZE/4];
  e_epiphany_t dev; 
  int k;

  //Open
  e_init(NULL);
  e_reset_system();
  e_open(&dev, 0, 0, 1, 1);
  e_read(&dev, 0, 0, 0x0, &read_buffer, RAM_SIZE);
  e_close(&dev);
  e_finalize();  
  printf("TEST \"e-read-buf\" PASSED\n");
  return EXIT_SUCCESS;
}
예제 #13
0
int main()
{
    //counters for row and colum, cored id and loop counter
    unsigned row, col, id, row_loop,col_loop;
    // this will contain the epiphany platform configuration
    e_platform_t epiphany;
    e_epiphany_t dev;
    e_mem_t memory;
    char message[_BufSize];
    e_return_stat_t result;

    e_init(NULL); // initialise the system establish connection to the Device
    e_reset_system(); // reset the epiphnay chip
    e_get_platform_info(&epiphany);//gets the configuration info for the parallella platofrm
    // allocatethe shared memory for recieivng  the message from the core
    e_alloc(&memory, _BufOffset, _BufSize);

    row = 0;
    col = 0;

    for(row_loop=0; row_loop <4; row_loop ++)
    {
        for(col_loop=0; col_loop <4; col_loop ++)
        {
            //one core within the parallella work group is 1 x 1 i.e single core
            e_open(&dev,row_loop,col_loop,1,1);
            //reset the group
            e_reset_group(&dev);
            //load the group
            result =  e_load("hello_world.srec",&dev,0,0,E_TRUE);
            if (result != E_OK) {
                fprintf(stderr,"Error Loading the Epiphany Application %i\n", result);
            }
            usleep(10000);
            e_read(&memory,0,0,0x0, message, _BufSize);
            fprintf(stderr,"message from  core = %s\n", message);
            e_close(&dev);
        }
    }

    e_free(&memory);
    e_finalize();

    return 0;

}
예제 #14
0
/* Hack: Doing a e_init() / e_reset_system() / e_finalize() salute will shut
 * down the north, south, and west eLinks. */
static int disable_nsw_elinks()
{
	int rc = E_OK;

	rc = e_init(NULL);
	if (rc != E_OK) {
		fprintf(stderr, "ERROR: Failed to initialize Epiphany "
				"platform.\n");
		return rc;
	}

	rc = e_reset_system();
	if (rc != E_OK) {
		fprintf(stderr, "ERROR: e_reset_system() failed.\n");
	}

	e_finalize();

	return rc;
}
예제 #15
0
int main(int argc, char *argv[]){

  e_epiphany_t dev; 
  unsigned int write_buffer[N];
  int i;

  for (i=0; i<N; i++){
    write_buffer[i] = 0x12345678;
  }

  //Open
  e_init(NULL);
  e_reset_system();
  e_open(&dev, 0, 0, 1, 1);  
  e_write(&dev, 0, 0, 0, &write_buffer, N*sizeof(int));
  e_close(&dev);
  e_finalize();  
  printf("TEST \"e-write-buf\" PASSED\n");
  return EXIT_SUCCESS;
}
예제 #16
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i, j, k, m, q, mode, signal;
	e_platform_t platform;
	e_epiphany_t dev;
	unsigned desired, real;
	unsigned time[16][2];
	time[0][0]=0;
	time[0][1]=0;
	
	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

    	// Open a workgroup
	e_open(&dev, 0, 0, platform.rows, platform.cols);
	
	// Load device program		
	e_load("e_loadstore.elf",&dev, 0, 0, E_TRUE);

	//Waiting for finish
	usleep(500000);

	// Read back timer values
	e_read(&dev, 0, 0, (0x6000), &time[0][0], sizeof(real));
	e_read(&dev, 0, 0, (0x6004), &time[0][1], sizeof(real));

	//Print Results
	float ratio= 100*((float)time[0][1]/(float)time[0][0]-1.0f);	
	printf("Local  STR loop cycles=%d\n", time[0][0]);
	printf("Remote STR loop cycles=%d\n", time[0][1]);
	printf("Performance hit       =%f%%\n", ratio);

	// Finalize the e-platform connection.
	e_finalize();

	return 0;
}
예제 #17
0
int main(int argc, char *argv[])
{
    unsigned int row, col;
    unsigned int data;
    int i,j;
    e_platform_t platform;
    e_epiphany_t dev;
    e_mem_t emem;
    char emsg[_BufSize];

    // initialize system, read platform params from
    // default HDF. Then, reset the platform and
    // get the actual system parameters.
    e_set_host_verbosity(H_D0);
    e_init(NULL);
    e_reset_system();
    e_get_platform_info(&platform);

    // Allocate a buffer in shared external memory
    // for message passing from eCore to host.
    e_alloc(&emem, _BufOffset, _BufSize);

    // Open a workgroup
    e_open(&dev, 0, 0, platform.rows, platform.cols);

    //Turn off the LVDS Links from the a core program
    e_load("e_link_lowpower_mode.srec", &dev, 0, 0, E_TRUE);

    // Close the workgroup
    e_close(&dev);

    // Release the allocated buffer and finalize the
    e_free(&emem);
    e_finalize();

    return 0;
}
예제 #18
0
int main(int argc, char *argv[]){
  e_loader_diag_t e_verbose;
  e_platform_t platform;
  e_epiphany_t dev;
  int status=1;//pass
  char elfFile[4096];
  //e_set_loader_verbosity(L_D3);

  //Gets ELF file name from command line
  strcpy(elfFile, argv[1]);

  //Initalize Epiphany device
  e_init(NULL);                      
  e_reset_system();
  e_get_platform_info(&platform);                          
  e_open(&dev, 0, 0, 1, 1); //open core 0,0


  //Load program to cores and run
  e_load_group(elfFile, &dev, 0, 0, 1, 1, E_TRUE);
  e_check_test(&dev, 0, 0, &status);

  
  //Close down Epiphany device
  e_close(&dev);
  e_finalize();
  
  //self check
  if(status){
    return EXIT_SUCCESS;
  }
  else{
    return EXIT_FAILURE;
  }   

}
예제 #19
0
int main()
{
	int rc;
	DECLARE_WATCHDOG(wd);

	fprintf(stderr, "Parallella thermal watchdog daemon starting...\n");

	get_limits_from_env(&wd);

	fprintf(stderr, "Allowed temperature range [%d -- %d] C.\n",
			wd.min_temp, wd.max_temp);


	/* First, ensure chip is in lowest possible power state */
	rc = disable_nsw_elinks();
	if (rc != E_OK) {
		fprintf(stderr, "ERROR: Failed to disable Epiphany eLinks\n");
		return rc;
	}

	/* We need to call e_init() to initialize platform data */
	rc = e_init(NULL);
	if (rc != E_OK) {
		fprintf(stderr, "ERROR: Failed to initialize Epiphany "
				"platform.\n");
		return rc;
	}

#if DEBUG
	e_set_host_verbosity(H_D1);
#endif

	/* Make sure we can successfully disable the chip */
	rc = disable_chip();
	if (rc != E_OK) {
		fprintf(stderr, "ERROR: Disabling Epiphany chip failed.\n");
		goto exit_e_finalize;
	}

	/* Ensure we can access the XADC temperature sensor */
	rc = update_temp_sensor(&wd);
	if (rc) {
		perror("ERROR: Temperature sensor sysfs entries not present");
		fprintf(stderr, "Make sure to compile your kernel with"
			" \"CONFIG_IIO=y\" and \"CONFIG_XILINX_XADC=y\".\n");

		goto exit_disable_chip;
	}

	/* Set up SIGTERM handler */
	signal (SIGTERM, sigterm_handler);


	fprintf(stderr, "Entering mainloop.\n");
	rc = mainloop(&wd);
	if (rc) {
		fprintf(stderr, "ERROR: mainloop failed\n");
	} else {
		fprintf(stderr, "Exiting normally\n");
	}

exit_disable_chip:
	disable_chip();
exit_e_finalize:
	e_finalize();

	return rc;

}
예제 #20
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i, j, m, n, k;
	e_platform_t platform;
	e_epiphany_t dev;
	int err = 0;
	unsigned flag = 0x00000000;
	unsigned flag1 = 0x00000000;
	unsigned flag2 = 0x00000000;
	unsigned flag3 = 0x00000000;
	srand(1);

	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);
	
    	// Open a workgroup
	e_open(&dev, 0, 0, platform.rows, platform.cols);
	
	
	// Load the device program onto core (0,0)
	e_load_group("e_dma_2d_test.srec", &dev, 0, 0, platform.rows, platform.cols, E_FALSE);

	// Launch to each core
	for (i=0; i<platform.rows; i++)
	{	
		for(j=0; j<platform.cols; j++)
		{
			row=i;
			col=j;
			coreid = (row + platform.row) * 64 + col + platform.col;
			fprintf(stderr,"%3d: Message from eCore 0x%03x (%2d,%2d) : \n",(row*platform.cols+col),coreid,row,col);
			// Start device
			e_start(&dev, i, j);
			usleep(500000);
			// Wait for core program execution to finish
			// Read message from shared buffer
				
			e_read(&dev, i, j, 0x6000, &flag, sizeof(flag));
			e_read(&dev, i, j, 0x6100, &flag1, sizeof(flag1));
			e_read(&dev, i, j, 0x6200, &flag2, sizeof(flag2));
			e_read(&dev, i, j, 0x6300, &flag3, sizeof(flag3));

			// Print the message and close the workgroup.
			if(flag == 0xffffffff)
			{
				fprintf(stderr, "PASS for word size!\n");
			}else
			{
				fprintf(stderr, "Fail for word size!\n");
				err = 1;
			}

			if(flag1 == 0xffffffff)
			{
				fprintf(stderr, "PASS for doubleword size!\n");
			}else
			{
				fprintf(stderr, "Fail for doubleword size!\n");
				err = 1;
			}

			if(flag2 == 0xffffffff)
			{
				fprintf(stderr, "PASS for halfword size!\n");
			}else
			{
				fprintf(stderr, "Fail for halfword size!\n");
				err = 1;
			}
                      
			if(flag3 == 0xffffffff)
			{
				fprintf(stderr, "PASS for byte size!\n");
			}else
			{
				fprintf(stderr, "Fail for byte size!\n");
				err = 1;
			}
		}
	}

	// Close the workgroup
	e_close(&dev);
	
	// Finalize the e-platform connection.
	e_finalize();

	return err;
}
예제 #21
0
int main(int argc, char *argv[]){
  e_platform_t platform;
  e_epiphany_t dev;
  unsigned int data,stage;
  int i,j;
  int row,col;
  
  if(argc < 2){
    usage();
    exit;
  }
  else{
    stage = atoi(argv[1]);
  }

  //Open device
  //e_set_loader_verbosity(H_D2);
  e_init(NULL);
  e_get_platform_info(&platform);
  e_open(&dev,0, 0, platform.rows, platform.cols);
  //Reset the system
  e_reset_system();
  
  //---------------------------------------
  //Shut down link (NORTH==0,2)
  if(stage>0){
    row=0;
    col=2;    
    ee_write_esys(E_SYS_CONFIG, 0x10000000);
    
    data = 0x000000FFF;
    e_write(&dev, row, col, 0xf0304, &data, sizeof(int));  
    
    data = 0x000000FFF;
    e_write(&dev, row, col, 0xf0308, &data, sizeof(int));  
    
    ee_write_esys(E_SYS_CONFIG, 0x00000000);
  }
  //---------------------------------------
  //Shut down south link (SOUTH==7,2)
  if(stage>1){   
    col=2;
    if ((dev.type == E_E64G401)){
      row=7;
    }
    else{
      row=3;
    }
    ee_write_esys(E_SYS_CONFIG, 0x90000000);
    
    data = 0x000000FFF;
    e_write(&dev, row, col, 0xf0304, &data, sizeof(int));  
    
    data = 0x000000FFF;
    e_write(&dev, row, col, 0xf0308, &data, sizeof(int));  
    
    ee_write_esys(E_SYS_CONFIG, 0x00000000);
  }
  //---------------------------------------
  //Shut down west link (WEST==2,0)
  if(stage>2){
    row=2;
    col=0;
    ee_write_esys(E_SYS_CONFIG, 0xd0000000);
    
    data = 0x000000FFF;
    e_write(&dev, row, col, 0xf0304, &data, sizeof(int));  
    
    data = 0x000000FFF;
    e_write(&dev, row, col, 0xf0308, &data, sizeof(int));  
    
    ee_write_esys(E_SYS_CONFIG, 0x00000000);
  }
  //---------------------------------------
  if(stage>4){
    //Configuring clock divider(EAST==2,7)
    row=2;
    if ((dev.type == E_E64G401)){
      col=7;
    }
    else{
      col=3;
    }
    ee_write_esys(E_SYS_CONFIG, 0x50000000);
    //Change clock divider to solve FPGA receiver speed path
    data = 0x1;
    e_write(&dev, row, col, 0xf0300, &data, sizeof(int));
    //Up the current drive on the wait signal
    //data = 0x02000000;
    //e_write(&dev, 0, 0, 0xf0304, &data, sizeof(int));
    //Return to normal mode
    ee_write_esys(E_SYS_CONFIG, 0x00000000);
    
  }
  if(stage>3){
    //Enable clock gating
    for (i=0; i<platform.rows; i++) {
      for (j=0; j<platform.cols; j++) {
	//eCore clock gating
	data=0x00400000;
	e_write(&dev, i, j, 0xf0400, &data, sizeof(data));
	//eMesh clock gating
	data=0x00000002;
	e_write(&dev, i, j, 0xf0700, &data, sizeof(data));
      }
    }
  }
  if(stage>5){
    //Enable timeout
    ee_write_esys(E_SYS_CONFIG, 0x00000001);
  }
  //-------------------------------------------------------
  e_close(&dev);
  e_finalize();  
  return 0;
}
예제 #22
0
int main(int argc, char *argv[])
{
        ros::init(argc, argv, "epiphany_node");

	unsigned row, col, coreid, i;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t   mbuf;

	srand(1);

	e_set_loader_verbosity(L_D0);
	e_set_host_verbosity(H_D0);

	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

	// Allocate a buffer in shared external memory
	// for message passing from eCore to host.
	if ( E_OK != e_shm_alloc(&mbuf, ShmName, ShmSize) ) {
		fprintf(stderr, "Failed to allocate shared memory. Error is %s\n",
				strerror(errno));
		return EXIT_FAILURE;
	}

	for (i=0; i<SeqLen; i++)
	{
		char buf[ShmSize];

		// Draw a random core
		row = rand() % platform.rows;
		col = rand() % platform.cols;
		coreid = (row + platform.row) * 64 + col + platform.col;
		fprintf(stderr, "%3d: Message from eCore 0x%03x (%2d,%2d): ", i, coreid, row, col);

		// Open the single-core workgroup and reset the core, in
		// case a previous process is running. Note that we used
		// core coordinates relative to the workgroup.
		e_open(&dev, row, col, 1, 1);
		e_reset_group(&dev);

		// Load the device program onto the selected eCore
		// and launch after loading.
		if ( E_OK != e_load("e_hello_world.srec", &dev, 0, 0, E_TRUE) ) {
			fprintf(stderr, "Failed to load e_hello_world.srec\n");
			return EXIT_FAILURE;
		}

		// Wait for core program execution to finish, then
		// read message from shared buffer.
		usleep(10000);

		e_read(&mbuf, 0, 0, 0, buf, ShmSize);

		// Print the message and close the workgroup.
		printf("\"%s\"\n", buf);
		e_close(&dev);
	}

	// Release the allocated buffer and finalize the
	// e-platform connection.
	e_shm_release(ShmName);
	e_finalize();

	return 0;
}
예제 #23
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i, j, m, n, k;
	e_platform_t platform;
	e_epiphany_t dev;
	unsigned flag;
	int err = 0;
	srand(1);

	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.

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


	// Allocate a buffer in shared external memory
	// for message passing from eCore to host.
	//e_alloc(&emem, _BufOffset, _BufSize);	
	
    	// Open a workgroup
	e_open(&dev, 0, 0, platform.rows, platform.cols);
	
	
	// Load the device program onto receiver core (1,1) and transmitter core (2,1)
	e_load("e_dma_slave_test.srec", &dev, r_row, r_col, E_FALSE);
	e_load("e_dma_slave_test1.srec", &dev, t_row, t_col, E_FALSE);

	// Start the receiver core
	
	row=r_row;
	col=r_col;
	coreid = (row + platform.row) * 64 + col + platform.col;
	fprintf(stderr,"%3d: Message from eCore 0x%03x (%2d,%2d) : \n",(row*platform.cols+col),coreid,row,col);

	// Tell transmitter the coordinate of receiver core
	e_write(&dev, t_row, t_col, 0x6500, &row, sizeof(row));
	e_write(&dev, t_row, t_col, 0x6504, &col, sizeof(col));

	usleep(10000);

	// Start device
	e_start(&dev, r_row, r_col);
	usleep(10000);

	// Start the transmitter core
	e_start(&dev, t_row, t_col);
	
	// Wait for core program execution to finish
	usleep(300000);
	
	// Read message from the mailbox in transmitter core		
	e_read(&dev, t_row, t_col, 0x6100, &flag, sizeof(flag));
			
	// Check if the result is right and print the message.
	if(flag==(unsigned)0xffffffff)
	{
		fprintf(stderr, "PASS!\n");
	}else
	{
		err = 1;
		fprintf(stderr,"Fail!\n");
	}

	// Close the workgroup
	e_close(&dev);
	
	// Finalize the
	// e-platform connection.
	e_finalize();

	return err;
}
예제 #24
0
int main(int argc, char *argv[])
{
    unsigned rows, cols, coreid, i, j;
    e_platform_t platform;
    e_epiphany_t dev;
    e_mem_t emem;

    // initialize system, read platform params from
    // default HDF. Then, reset the platform and
    // get the actual system parameters.
    e_init(NULL);
    e_reset_system();
    e_get_platform_info(&platform);

    // Allocate a buffer in shared external memory
    // for message passing from eCore to host.
    e_alloc(&emem, _BufOffset, _BufSize);

    //open the workgroup
    rows = platform.rows;
    cols = platform.cols;
    e_open(&dev, 0, 0, rows, cols);

    //load the device program on the board
    e_load_group("emain.srec", &dev, 0, 0, rows, cols, E_FALSE);

    //set up the event list table
    strcpy(event[0], "CLK");
    strcpy(event[1], "IDLE");
    strcpy(event[2], "IALU_INST");
    strcpy(event[3], "FPU_INST");
    strcpy(event[4], "DUAL_INST");
    strcpy(event[5], "E1_STALLS");
    strcpy(event[6], "RA_STALLS");
    strcpy(event[7], "EXT_FETCH_STALLS");
    strcpy(event[8], "EXT_LOAD_STALLS");
    strcpy(event[9], "IALU_INST");

    for (i=0; i<rows; i++)
    {
        for (j=0; j<cols; j++)
        {

            coreid = (i + platform.row) * 64 + j + platform.col;
            fprintf(stderr, "Message from eCore 0x%03x (%2d,%2d): \n", coreid, i, j);
            e_start(&dev, i, j);

            //wait for core to execute the program
            usleep(100000);

            e_read(&emem, 0, 0, 0x0, &result, sizeof(unsigned)*10);

            check();
        }
    }

    e_close(&dev);
    e_free(&emem);
    e_finalize();

    return 0;
}
예제 #25
0
int main(int argc, char *argv[])
{
	unsigned rows, cols, coreid, i, j;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t emem;
	int result;


	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

	// Allocate a buffer in shared external memory
	// for message passing from eCore to host.
	e_alloc(&emem, _BufOffset, _BufSize);

	//open the workgroup
	rows = platform.rows;
	cols = platform.cols;
	e_open(&dev, 0, 0, rows, cols);
	
	//load the device program on the board
	e_load_group("emainorigin.srec", &dev, 0, 0, rows, cols, E_FALSE);
	

//	for (i=0; i<rows; i++)
//	{
//		for (j=0; j<cols; j++)
//		{

//			i = 3; j = 3;
			
	for (i=0; i<1; i++)
	{
		for (j=0; j<2; j++)
		{
			
			
			coreid = (i + platform.row) * 64 + j + platform.col;
			fprintf(stderr, "Message from eCore 0x%03x (%2d,%2d): \n", coreid, i, j);
			e_start(&dev, i, j);
			usleep(100000);

			e_read(&dev, i, j, 0x5200, &result, sizeof(int));
			if(result == 0)
				fprintf(stderr, "\"test MULTICAST	passed!\"\n");	
			else
				fprintf(stderr, "\"test MULTICAST	failed!\t\t\tWarnning, test failed! Num of fualt is %d!\"\n", result);
			usleep(100000);	
		}	
	}	



	e_close(&dev);
	e_free(&emem);
	e_finalize();

	

	return 0;
}
예제 #26
0
int main(int argc, char *argv[]){

  //----------------------------
  e_platform_t platform;
  e_epiphany_t dev;
  e_hal_diag_t e_verbose;
  unsigned int i,j,k,addr;
  unsigned int data;
  int status=1;//pass

  int row0,col0,rows,cols;
  int verbose=0;

  unsigned int high_pattern = 0xaaaaaaaa;
  unsigned int low_pattern  = 0x55555555;

  unsigned int result;

  if (argc < 5){
    usage();
    exit(1);
  }  
  else{
    row0    = atoi(argv[1]);
    col0    = atoi(argv[2]);
    rows    = atoi(argv[3]);
    cols    = atoi(argv[4]);
  }
  //Open
  e_init(NULL);
  my_reset_system();
  e_get_platform_info(&platform);
  e_open(&dev, 0, 0, platform.rows, platform.cols);
  

  printf("-------------------------------------------------------\n");  

  for (i=row0; i<(row0+rows); i++) {
    for (j=col0; j<(col0+cols); j++) {   
      printf("Running host register file test for core (%d,%d)\n", i,j);      
      for(k=0;k<REGS;k++){
	addr=0xF0000+k;
	//high pattern
	e_write(&dev, i, j, addr, &high_pattern,  sizeof(int));
	e_read(&dev, i, j, addr, &result, sizeof(int));
	printf("res=%x\n",result);
	if(result!=high_pattern){
	  status=0;
	}
	//low pattern
	e_write(&dev, i, j, addr, &low_pattern,  sizeof(int));
	e_read(&dev, i, j, addr, &result, sizeof(int));
	if(result!=low_pattern){
	  status=0;
	}
      }
    }
  }
  //Close
  e_close(&dev);
  e_finalize();

  //Self Check
  if(status){
    return EXIT_SUCCESS;
  }
  else{
    return EXIT_FAILURE;
  }   
}
예제 #27
0
int main(int argc, char *argv[])
{
    unsigned rows, cols, ncores, coreid, i, j;
    const uint32_t one = 1, zero = 0;
    int result[_MAX_CORES];
    e_platform_t platform;
    e_epiphany_t dev;
    e_mem_t emem;
    int fault, highest;

    // initialize system, read platform params from
    // default HDF. Then, reset the platform and
    // get the actual system parameters.
    e_init(NULL);
    e_reset_system();
    e_get_platform_info(&platform);

    // Allocate a buffer in shared external memory
    // for message passing from eCore to host.
    e_alloc(&emem, _BufOffset, _BufSize);

    //open the workgroup
    rows   = platform.rows;
    cols   = platform.cols;
    e_open(&dev, 0, 0, rows, cols);

    //load the device program on the board
    e_load_group("emain.srec", &dev, 0, 0, rows, cols, E_FALSE);
    e_start_group(&dev);
    usleep(100000);

    ncores = rows * cols;
    printf("num-cores = %4d\n", ncores);
    fault = 0x0;
    for (i=0; i < 0x10000; i++) {

        /* Pause leader core so we can read without races */
        e_write(&dev, 0, 0, 0x7000, &one, sizeof(one));

        /* Lazily assume cores will be paused and writes from all cores
         * to ERAM have propagated after below sleep. This must be
         * calibrated w.r.t Epiphany chip clock frequency and delay
         * cycles in the device code */
        usleep(1000);

        /* read the results */
        e_read(&emem, 0, 0, 0x0, &result, ncores*sizeof(int));

        /* Resume */
        e_write(&dev, 0, 0, 0x7000, &zero, sizeof(zero));

        highest = result[0];
        for (j=0; j<ncores; j++) {
            if (result[j] != result[0]) {
                fault++;
                if (highest < result[j])
                    highest = result[j];
            }
        }

        /* Don't print every iteration */
        if (i % 0x10)
            continue;

        printf("[%03x] ", i);
        for (j=0; j<ncores; j++)
            printf("%04x ", result[j]);
        printf("\n");

        if (highest >= NBARRIERS)
            break;

        /* Do a small wait so it is easy to see that the E cores are
         * running independently. */
        usleep(10000);
    }

    //print the success/error message duel to the number of fault
    if (fault == 0)
        printf("\ntest #20: Hardware Barrier Passed!\n");
    else
        printf("\ntest #20: Hardware Barrier Failed! Fault is 0x%08x!\n", fault);

    e_close(&dev);
    e_free(&emem);
    e_finalize();

    return fault != 0;
}
예제 #28
0
int main(int argc, char *argv[])
{
  printf("[Started]\n");

  srand(time(NULL));
  for (int i = 0; i < N; ++i) {
    input[i] = rand() % 10;
  }

  printf("Input:");
  for (int i = 0; i < N; ++i) {
    printf(" %"PRIu32, input[i]);
  }
  puts("");

////////////////////////////////////////////////////////////////////////////////

  e_platform_t platform;
  e_epiphany_t group;

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

  e_open(&group, 0, 0, 1, 3);
  e_reset_group(&group);

  e_load("core0.elf", &group, 0, 0, E_FALSE);
  e_load("core1.elf", &group, 0, 1, E_FALSE);

  //                                                    -- fetch d0 (0, 9) input
  // to bank1 of core 0
  e_write(&group, 0, 0, d0, input, N * sizeof(uint32_t));

  //                                                       -- onCore 0 (f d0 d1)
  printf("Running f on core 0\n");
  e_start(&group, 0, 0);
  // should poll until finish (maybe a software interrupt later?)
  usleep(1000);

  //                                                       -- onCore 1 (g d1 d2)
  printf("Running g on core 1\n");
  e_start(&group, 0, 1);
  // should poll until finish (maybe a software interrupt later?)
  usleep(1000);

  //                                                   -- flush d2 (0, 9) output
  // from bank1 of core 2
  e_read(&group, 0, 2, d2, output, N * sizeof(uint32_t));

  e_close(&group);
  e_finalize();

////////////////////////////////////////////////////////////////////////////////

  printf("Output:");
  for (int i = 0; i < N; ++i) {
    printf(" %"PRIu32, output[i]);
  }
  puts("");

  printf("[Finished]\n");
  return EXIT_SUCCESS;
}
예제 #29
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i, j, k, m, q, mode, signal;
	e_platform_t platform;
	e_epiphany_t dev;
	unsigned desired, real;
	unsigned time[16][13];
	unsigned flag[platform.rows*platform.cols];
	row = mas_row;
	col = mas_col;
	signal = 0xdeadbeef;
	
	// For dma copy, define the number of desired transaction
	desired = 0x3c00;
	
	// Initialize flag
	for(i=0; i<platform.rows*platform.cols; i++)
	{
		flag[i] = 0;
	}
	
	srand(1);
	
	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

    	// Open a workgroup
	e_open(&dev, 0, 0, platform.rows, platform.cols);
	
	// Let other cores know the core id of the specific core
	for(i=0; i<platform.rows; i++)
	{
		for(j=0; j<platform.cols; j++)
		{
			if((i!=mas_row)|(j!=mas_col))
			{
				e_write(&dev, i, j, 0x5000, &row, sizeof(row));
				e_write(&dev, i, j, 0x5004, &col, sizeof(col));
			}		
		}
	}
	
	// Load device program onto the receiver
		
	e_load("e_mesh_receiver.srec",&dev, mas_row, mas_col, E_TRUE);
	
	
	// Load device program onto the transmitter
	for (i=0; i<(platform.rows); i++)
	{
		for(j=0; j<(platform.cols); j++)
		{
			if((i!=mas_row)|(j!=mas_col))
			{
				e_load("e_mesh_transmitter.srec",&dev, i, j, E_TRUE);
			}
		}
	}
		
	// Wait for all cores to initialize
	
	usleep(1000);
	
	for(q=0; q<13; q++)
	{
		// Select the mesh event
		mode = q;	
		
		// Tell each core the mesh event
		for (i=0; i<(platform.rows); i++)
		{
			for(j=0; j<(platform.cols); j++)
			{
				e_write(&dev, i, j, 0x5400, &mode, sizeof(mode));
			}
		}
	
		usleep(10000);
		
		// Send the start signal to receiver core
		e_write(&dev, mas_row, mas_col, 0x5100, &signal, sizeof(signal));
		
		usleep(500000);
		
	 }
	 
	 // Read from mailbox of all the cores
	 for(i=0; i<platform.rows; i++)
	 {
	 	for(j=0; j<platform.cols; j++)
	 	{
	 		for(k=0; k<13; k++)
	 		{
	 			e_read(&dev, i, j, (0x6000+k*4), &time[i*platform.cols+j][k], sizeof(real));
	 		}
		}
	 }
	 
	// Test if the results make sense
	real = time[mas_row*platform.cols+mas_col][8]+time[mas_row*platform.cols+mas_col][9]+
		  time[mas_row*platform.cols+mas_col][10]+time[mas_row*platform.cols+mas_col][11]-
		  time[(mas_row-1)*platform.cols+mas_col][0]-time[(mas_row)*platform.cols+mas_col-1][0]-
		  time[(mas_row)*platform.cols+mas_col+1][0]-time[(mas_row+1)*platform.cols+mas_col][0];
		  
	if ((real < (unsigned)desired * 1.1) && (real > (unsigned)desired * 0.1))
	{
		fprintf(stderr, "PASS for verification!\n");	
	}else
	{
		fprintf(stderr, "FAIL for verification!\n");
	}

	// Close the workgroup
	e_close(&dev);
	
	// Finalize the e-platform connection.
	e_finalize();

	return 0;
}
예제 #30
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t emem;

    Mailbox mailbox;
    mailbox.flag = 0;
	// initialize system, read platform params from
	// default HDF. Then, reset the platform and
	// get the actual system parameters.
	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

	// Allocate a buffer in shared external memory
	// for message passing from eCore to host.
	e_alloc(&emem, _BufOffset, 1024);

    row = 0;
    col = 0;
    coreid = (row + platform.row) * 64 + col + platform.col;
    fprintf(stderr,"\n\nMultiplying A[%d][%d] x B[%d][%d] = C[%d][%d]\n",N,ROWS,N,ROWS,N,ROWS);

    // Open the single-core workgroup Note that we used
    // core coordinates relative to the workgroup.
    e_open(&dev, row, col, 1, 1);

    // Load the device program onto the selected eCore
    // and launch after loading.

    e_load("e_dev_main.elf", &dev, 0, 0, E_FALSE);
    e_start_group(&dev);


    // Wait for core program execution to finish, then                               
    // read mailbox from shared buffer.                                              
    unsigned int addr = offsetof(Mailbox, flag);                              
    while (mailbox.flag != 1) {                                               
        e_read(&emem, 0, 0, addr, &mailbox.flag, sizeof(mailbox.flag));
    }                                                                                

    // Wait for core program execution to finish, then
    // read message from shared buffer.
    //usleep(100000);


    e_read(&emem, 0, 0, 0x0, &mailbox, sizeof(mailbox));


    float c_o[N][N];
    addr = (unsigned int)mailbox.c_o;
    e_read(&dev, 0, 0, addr, &c_o[0][0], N * N * sizeof(float));
    print_to_file("../output/optresult",c_o);
    
    // Print the message and close the workgroup.
    e_close(&dev);



    printf("\nOptimized MATMUL time = %d cycles\tTime: %9.3f msec\n", mailbox.clocks1,clock_to_time(mailbox.clocks1)); 
    float gflops = ((2 * N * ROWS * N)/(clock_to_time(mailbox.clocks1)/1000))/1000/1000/1000;
    printf("\nGFlops: %9.6f\tPerformance = %9.4f %% of peak\n",gflops,gflops/1.2*100);
    fprintf(stderr,"\n");
	// Release the allocated buffer and finalize the
	// e-platform connection.
	e_free(&emem);
	e_finalize();


	return 0;
}