Esempio n. 1
0
int main(int argc, char *argv[])
{
	Epiphany epiphany("etest.srec", false);

	e_start(epiphany.getEpipAddr(), 0, 0);

	char dataFromShared[64];
	unsigned dataFromLocal;
	usleep(10000);
	e_read(epiphany.getEmemAddr(), 0, 0, 0x0, dataFromShared, 64);
	e_read(epiphany.getEpipAddr(), 0, 0, 0x2000, &dataFromLocal, sizeof(unsigned));
	fprintf(stdout, "Data from shared mem (string): %s\nData from local mem (coreid): %x\n", dataFromShared, dataFromLocal);

	return EXIT_SUCCESS;
}
Esempio n. 2
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;
}
Esempio n. 3
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;
}
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;
}
Esempio n. 5
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;
}
Esempio n. 6
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;
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i, j, m, n, k;
	int err = 0;
	e_platform_t platform;
	e_epiphany_t dev;
	unsigned flag;
	unsigned flag1;
	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_int_test.elf", &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);
			
			// Wait for core program execution to finish
			usleep(500000);
			
			// Read message from shared buffer	
			e_read(&dev, i, j, 0x2250, &flag, sizeof(flag));
			e_read(&dev, i, j, 0x3000, &flag1, sizeof(flag1));
			
			// Print the message and close the workgroup.
			if((flag==(unsigned)0xdeadbeef)&&(flag1==(unsigned)0xdeadbeef))
			{
				fprintf(stderr, "PASS!\n");
			}else
			{
				fprintf(stderr,"Fail!\nThe interrupt output is 0x%08x!\nThe return output is 0x%08x!\n",flag,flag1);
				err = 1;
			}
		}
	}

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

	return err;
}
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];
	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_host_verbosity(H_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);
	
	// Reset the workgroup
	for (m=0; m<platform.rows; m++)
	{	for(n=0; n<platform.cols;n++)
		{	
			ee_reset_core(&dev, m, n);
		}
	}
	
	// Load the device program onto all the eCores
	e_load_group("e_nested_test.srec", &dev, 0, 0, platform.rows, platform.cols, E_FALSE);

	// Select one core to work 
	for (i=0; i<platform.rows; i++)
	{
		for (j=0; j<platform.cols; j++)
		{
			// Draw to a certain core
			row=i;
			col=j;
			coreid = (row + platform.row) * 64 + col + platform.col;
			fprintf(stderr,"%d: Message from eCore 0x%03x (%2d,%2d): \n",(i*platform.cols+j),coreid,row,col);
		
			e_start(&dev, i, j);			
			usleep(1000000);
			
			// Wait for core program execution to finish
			// Read message from shared buffer
				
			e_read(&emem, 0, 0, 0x0, &emsg, _BufSize);

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

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

	return 0;
}
Esempio n. 9
0
int main(int argc, char *argv[])
{
	unsigned row, col, coreid, i,j,m,n,k,l;
        unsigned int acc = 0;
        uint32_t flag[41];
	const uint32_t zero = 0;
	uint32_t done = 0;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t emem;
	char emsg[_BufSize];
	int errors = 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 all the eCores
	// To get the verified values
	//e_load_group("e_math_test.elf", &dev, 0, 0, platform.rows,  platform.cols, E_FALSE);

	// To test
	e_load_group("e_math_test", &dev, 0, 0, platform.rows, platform.cols, E_FALSE);

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

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

				e_write(&dev, i, j, 0x5ffc, &zero, sizeof(zero));
				e_start(&dev, i, j);

				done = 0;
				while (!done) {
					e_read(&dev, i, j, 0x5ffc, &done, sizeof(done));
					usleep(1000);
				}

				// Wait for core program execution to finish
				// Read message from shared buffer
				//usleep(100000);


				e_read(&emem, 0, 0, 0x0, emsg, _BufSize);
				e_read(&dev, i, j, 0x6000, &flag, sizeof(flag));

				// Print the message and close the workgroup.
                                if(flag[40] == 40) {
                                  for (l = 0; l < 40; l+=4) {
                                    fprintf(stdout, "%d ", flag[l]);
                                    fprintf(stdout, "%d ", flag[l + 1]);
                                    fprintf(stdout, "%d ", flag[l + 2]);
                                    fprintf(stdout, "%d | ", flag[l + 3]);
                                  }
                                  acc = 0;
                                  for (l = 0; l < 40; l++) {
                                    acc += flag[l];
                                    acc += flag[l + 1];
                                    acc += flag[l + 2];
                                    acc += flag[l + 3];
                                  }
                                  fprintf(stdout, "total: %d\n", acc);

                                } else {
                                  fprintf(stderr,"FAIL! %d\n", flag[20]);
								  errors++;
                                }
				//Only print out messages on core 0
				if(i==0 & j==0){
				  fprintf(stderr, "%s\n", emsg);
				}
		}
	}

	// Close the workgroup
	e_close(&dev);

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

	return errors;
}
Esempio n. 10
0
int main(int argc, char *argv[])
{
	unsigned rows, cols, coreid, i, j, flag, fail = 0;
	e_platform_t platform;
	e_epiphany_t dev;
	e_mem_t emem;
	unsigned time[sizeN];
	unsigned result[sizeN];

	// 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);

	e_alloc(&emem, 0x01800000, 0x4000);

	//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.elf", &dev, 0, 0, rows, cols, E_FALSE);

	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);

			flag = 0;
			e_write(&emem, 0, 0, 0x3000, &flag, sizeof(flag));

			e_start(&dev, i, j);

			//wait for core to execute the program
			while (!flag) {
				e_read(&emem, 0, 0, 0x3000, &flag, sizeof(flag));
				usleep(1000);
			}

			//check results
			e_read(&emem, 0, 0, 0x1000, &result[0], sizeN*sizeof(unsigned));
			e_read(&emem, 0, 0, 0x2000, &time[0], sizeN*sizeof(unsigned));

			if ((result[1] == result[0]) && (result[1] == result[2]) && (time[1]<time[0]) && (time[1]<time[2]))
				fprintf(stderr, "\ntest hardware_loop passed!\n\n");
			else
			{
				fprintf(stderr, "\ntest hardware_loop failed!\n");
				fprintf(stderr, "result:\tauto =  %10d   hw =  %10d   sf =  %10d \n", result[0],result[1],result[2]);
				fprintf(stderr, "time:  \tauto = %5d cycles  hw = %5d cycles  sf = %5d cycles \n\n", time[0],time[1],time[2]);
				fail++;
			}

		}
	}

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

	return !(fail == 0);
}