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; }
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; }
int main(int argc, char *argv[]) { e_platform_t platform; e_epiphany_t dev; e_mem_t emem; const uint32_t zero = 0; uint32_t result = 0; e_init(NULL); e_reset_system(); e_get_platform_info(&platform); if (e_alloc(&emem, 0, 128) != E_OK) exit(EXIT_FAILURE); e_write(&emem, 0, 0, 0, &zero, sizeof(zero)); e_open(&dev, 0, 0, 1, 1); if (e_load("emain.elf", &dev, 0, 0, E_TRUE) != E_OK) exit(EXIT_FAILURE); do { e_read(&emem, 0, 0, 0, &result, sizeof(result)); } while (!result); if (result != 1) { fprintf(stderr, "Test failed. elink RX remapping configured incorrectly. Faulty programs can\n" "likely access the system's first 1MB memory region. Go patch your kernel!\n"); exit(EXIT_FAILURE); } fprintf(stderr, "Test passed\n"); return 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; }
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; }
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; }
/** * Physically loads the binary interpreter onto the cores */ static void loadBinaryInterpreterOntoCores(struct interpreterconfiguration* configuration, char allActive) { unsigned int i; int result; char* binaryName=getEpiphanyExecutableFile(configuration); if (allActive && e_platform.chip[0].num_cores == TOTAL_CORES) { result = e_load_group(binaryName, &epiphany, 0, 0, epiphany.rows, epiphany.cols, E_TRUE); if (result != E_OK) fprintf(stderr, "Error loading Epiphany program\n"); } else { for (i=0;i<TOTAL_CORES;i++) { if (configuration->intentActive[i]) { int row=i/epiphany.cols; result = e_load(binaryName, &epiphany, row, i-(row*epiphany.cols), E_TRUE); if (result != E_OK) fprintf(stderr, "Error loading Epiphany program onto core %d\n", i); } } } free(binaryName); }
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; }
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; }
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; }
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; }
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; }
int main(int argc, char *argv[]) { e_platform_t platform; e_epiphany_t Epiphany, *pEpiphany; e_mem_t DRAM, *pDRAM; unsigned int msize; float seed; unsigned int addr; //, clocks; size_t sz; int result, rerval; pEpiphany = &Epiphany; pDRAM = &DRAM; msize = 0x00400000; // load j1.bin into shared mem uint8_t ROM[1<<16]; printf("load %s \n", argv[1]); FILE* f = fopen("j1.bin","r"); int i = 0; uint16_t op; while(fread(&op, 2, 1, f)) { *(ROM+i*2+1) = op&0xff; *(ROM+i*2) = op>>8; i++; } fclose(f); printf ("read %d words\n",i); for(int i=0;i<50;i++)printf("%x ", (uint16_t)*(ROM+2*i)); printf("\n"); get_args(argc, argv); fo = stdout; fi = stdin; // Connect to device for communicating with the Epiphany system // Prepare device e_set_host_verbosity(H_D0); e_init(NULL); e_reset_system(); e_get_platform_info(&platform); if (e_alloc(pDRAM, 0x00000000, msize)) { fprintf(fo, "\nERROR: Can't allocate Epiphany DRAM!\n\n"); exit(1); } if (e_open(pEpiphany, 0, 0, 1, 1)) { fprintf(fo, "\nERROR: Can't establish connection to Epiphany device!\n\n"); exit(1); } e_reset_core(pEpiphany, 0, 0); //fprintf(fo, "host base %x \n", pDRAM->base); fflush(fo); // init all for(int i=0;i<16;i++){ int n = 0; addr = offsetof(shared_buf_t, core.seq); e_mwrite_buf(pDRAM, addr, &n, sizeof(int)); addr = offsetof(shared_buf_t, core.go_out); e_mwrite_buf(pDRAM, addr, &n, sizeof(int)); } addr = offsetof(shared_buf_t, DRAM); e_mwrite_buf(pDRAM, addr, ROM, sizeof(ROM)); printf("Loading program on Epiphany chip...\n"); //e_set_loader_verbosity(ar.verbose); //result = e_load_group(ar.srecFile, pEpiphany, 0, 0, pEpiphany->rows, pEpiphany->cols, ar.run_target); result = e_load(ar.srecFile, pEpiphany, 0, 0, ar.run_target); if (result == E_ERR) { printf("Error loading Epiphany program.\n"); exit(1); } // Generate operand matrices based on a provided seed matrix_init(seed); sleep(2); struct sockaddr_in si_me, si_other; int s, slen, n=0; if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) { printf("socket open error\n"); return -1; } memset((char *) &si_me, 0, sizeof(si_me)); si_me.sin_family = AF_INET; si_me.sin_port = htons(27777); si_me.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(s, (struct sockaddr *) &si_me, sizeof(si_me))==-1) { printf("ERROR, bind failed\n"); return -1; } int ep_seq[16]; bzero(ep_seq, 16*sizeof(int) ); while (1) { // read command from udp client char buf[1024]; ssize_t len = recvfrom(s, buf, 255, 0, (struct sockaddr *)&si_other, (socklen_t*)&slen); if (len == -1) { printf("socket error\n"); break; } printf("Received packet from %s:%d\nlen %d Data: %s\n", inet_ntoa(si_other.sin_addr), ntohs(si_other.sin_port), len, buf); // R then L load vm, G run, R reset n = buf[0]; printf("seq %d core %d cmd %c\n", ep_seq[n], n, buf[1]); if('s' == buf[1])printf("set debug mask %x \n", buf[2]); else if('L' == buf[1]) { pthread_create(&trace_reader_a, NULL, trace_reader, pDRAM); } char string[256] = "aaa bbb ccc "; char s_out[256]; int addr_to = offsetof(shared_buf_t, core.go[n]); int addr_out = offsetof(shared_buf_t, core.go_out[n]); int addr_seq = offsetof(shared_buf_t, core.seq[n]); int addr_core_seq = offsetof(shared_buf_t, core.core_seq[n]); // send command memcpy(string,buf+1,10); sz= e_mwrite_buf(pDRAM, addr_to, string, 25 ); sz= e_mwrite_buf(pDRAM, addr_seq, &ep_seq[n], sizeof(uint32_t) ); ep_seq[n] ++; sleep(1); // read from core uint32_t core_out; sz = e_mread_buf(pDRAM, addr_out, s_out, 25); result = e_mread_buf(pDRAM, addr_core_seq, &core_out,sizeof(uint32_t)); printf("check seq %x and output %s\n", core_out, s_out); } // Close connection to device if (e_close(pEpiphany)) { fprintf(fo, "\nERROR: Can't close connection to Epiphany device!\n\n"); exit(1); } if (e_free(pDRAM)) { fprintf(fo, "\nERROR: Can't release Epiphany DRAM!\n\n"); exit(1); } return rerval; }
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; }
int main(int argc, char *argv[]) { unsigned row, col, coreid, i, j, m, n, k; e_platform_t platform; e_epiphany_t dev; unsigned time; unsigned signal = 0xdeadbeef; unsigned clr = 0x00000000; unsigned master_row, master_col; master_row = mas_row; master_col = mas_col; float result1; srand(1); // initialize system, read platform params from // default HDF. Then, reset the platform and 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 target core e_load("e_mesh_one.srec", &dev, mas_row, mas_col, E_TRUE); // Make sure that target core is prepared to receive data usleep(10000); // Let other cores know the core id of the target core for(i=0; i<platform.rows; i++) { for(j=0; j<platform.cols; j++) { e_write(&dev, i, j, 0x6000, &master_row, sizeof(master_row)); e_write(&dev, i, j, 0x6004, &master_col, sizeof(master_col)); } } // Load the device program onto all cores except for target core 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_one1.srec",&dev, i, j, E_TRUE); } } } usleep(10000); // Sent the signal to start transfer e_write(&dev, mas_row, mas_col, 0x6100, &signal, sizeof(signal)); // Wait for cores to run usleep(1000000); // Read message from target core e_read(&dev, mas_row, mas_col, 0x5000, &time, sizeof(time)); // Calculate the bandwidth result1 = (120*585938)/(time); // Print the message fprintf(stderr, "0x%08x!\n", time); fprintf(stderr, "The bandwidth of all-to-one is %.2fMB/s!\n", result1); // Close the workgroup e_close(&dev); // Finalize the e-platform connection. e_finalize(); return 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; unsigned flag1 = 0x00000000; unsigned flag2 = 0x00000000; unsigned test = 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); // Allocate a buffer in shared external memory // for message passing from eCore to host. if ( E_OK != e_shm_alloc(&emem, "shm_1", _BufSize) ) { fprintf(stderr, "Failed to allocate shared memory. Error is %s\n", strerror(errno)); exit(EXIT_FAILURE); } // Open a workgroup e_open(&dev, 0, 0, platform.rows, platform.cols); // Load the device program e_load("e_dma_message_a.srec", &dev, mas_row, mas_col, E_TRUE); // Wait for core program execution to finish usleep(1000000); // Results from every slave core row=mas_row; col=mas_col; coreid = (row + platform.row) * 64 + col + platform.col; fprintf(stderr,"%d: Message from eCore 0x%03x (%2d,%2d) : \n",(row*platform.cols+col),coreid,row,col); // Read message e_read(&dev, row, col, 0x6000, &flag1, sizeof(flag1)); e_read(&dev, row, col, 0x6004, &flag2, sizeof(flag2)); // Print the message and close the workgroup. if((flag1 == (unsigned) 0x87654321)&&(flag2 != (unsigned) 0x87654321)) { fprintf(stderr, "PASS!\n"); }else { fprintf(stderr, "FAIL!\n"); } // Release the allocated buffer and finalize the // e-platform connection. e_shm_release("shm_1"); // Close the workgroup e_close(&dev); // Finalize the e-platform connection. e_finalize(); return 0; }
int main(int argc, char *argv[]) { unsigned row, col, coreid, i, j, k; e_platform_t platform; e_epiphany_t dev; e_mem_t emem; unsigned time; unsigned time1; unsigned signal = 0xdeadbeef; row = mas_row; col = mas_col; 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 e_load("e_mesh_wait_r.srec", &dev, mas_row, mas_col, E_TRUE); usleep(10000); // 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++) { e_write(&dev, i, j, 0x6000, &row, sizeof(row)); e_write(&dev, i, j, 0x6004, &col, sizeof(col)); } } //for (i=0; i<(platform.rows-2); i++) //{ // for(j=0; j<(platform.cols-2); j++) // { // if((i!=mas_row)|(j!=mas_col)) // { e_load("e_mesh_wait.srec",&dev, mas_row, mas_col+1, E_TRUE); e_load("e_mesh_wait.srec",&dev, mas_row+1, mas_col, E_TRUE); // } // } //} usleep(10000); // Sent the signal to start transfer e_write(&dev, mas_row, mas_col, 0x6100, &signal, sizeof(signal)); usleep(1000000); // Read message from shared buffer e_read(&dev, mas_row, mas_col, 0x5000, &time, sizeof(time)); e_read(&dev, mas_row, mas_col+1, 0x7000, &time1, sizeof(time1)); // Print the message and close the workgroup. fprintf(stderr, "0x%08x\n", time); fprintf(stderr, "0x%08x\n", time1); // Close the workgroup e_close(&dev); // Release the allocated buffer and finalize the // e-platform connection. e_free(&emem); e_finalize(); return 0; }
int main(int argc, char *argv[]) { unsigned row, col, coreid, i, e_status; e_platform_t platform; e_epiphany_t dev; e_mem_t mbuf; int retval = EXIT_SUCCESS; srand((unsigned int)time(NULL)); e_set_host_verbosity(H_D0); // initialize system, read platform params from // default HDF. Then, reset the platform and // get the actual system parameters. if ( E_OK != e_init(NULL) ) { fprintf(stderr, "Epiphany HAL initialization failed\n"); return EXIT_FAILURE; } if ( E_OK != e_reset_system() ) { fprintf(stderr, "Epiphany system reset failed\n"); retval = EXIT_FAILURE; goto err_out3; } fprintf(stderr, "Getting platform info\n"); if ( E_OK != e_get_platform_info(&platform) ) { fprintf(stderr, "Failed to get Epiphany platform info\n"); retval = EXIT_FAILURE; goto err_out3; } fprintf(stderr, "Platform version: %s, HAL version 0x%08x\n", platform.version, platform.hal_ver); // Allocate a few buffers that won't be touched. if ( E_OK != e_shm_alloc(&mbuf, "shm_1", 4096) ) { fprintf(stderr, "Failed to allocate shared memory. Error is %s\n", strerror(errno)); retval = EXIT_FAILURE; goto err_out3; } // Allocate a few buffers that won't be touched. if ( E_OK != e_shm_alloc(&mbuf, "shm_2", 4096) ) { fprintf(stderr, "Failed to allocate shared memory. Error is %s\n", strerror(errno)); retval = EXIT_FAILURE; goto err_out2; } // 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)); retval = EXIT_FAILURE; goto err_out1; } // Scribble on memory from host side e_write(&mbuf, 0, 0, 0, (const void*)HostMsg, sizeof(HostMsg)); // Dump the shm table - we should see three valid regions { int i = 0; const e_shmtable_t *tbl = e_shm_get_shmtable(); printf("Shared Memory Regions:\n"); printf("------------------------\n"); if ( tbl ) { for ( i = 0; i < MAX_SHM_REGIONS; ++i ) { if ( tbl->regions[i].valid ) { printf("region %d: name = %s, paddr = %p, length=%d\n", i, tbl->regions[i].shm_seg.name, tbl->regions[i].shm_seg.paddr, tbl->regions[i].shm_seg.size); } } } printf("------------------------\n"); } 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_shm_test.elf", &dev, 0, 0, E_TRUE) ) { fprintf(stderr, "Failed to load e_shm_test.elf\n"); retval = EXIT_FAILURE; goto err_out; } // Wait for core program execution to finish, then // read message from shared buffer. usleep(100000); 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. err_out: e_shm_release(ShmName); err_out2: e_shm_release("shm_2"); err_out1: e_shm_release("shm_1"); err_out3: e_finalize(); return retval; }
int main(){ //EPIPHANY VARIABLES e_platform_t platform; e_epiphany_t dev; //DEBUG VARIABLES unsigned read_buffer[RAM_SIZE/4]; unsigned read_data; unsigned addr; int i,j,k; char filename[9] = "logs.txt"; FILE* file = fopen(filename,"w"); //TIME VARIABLEs struct timeval initTime, endTime; long int timediff; //initialize the cores e_init(NULL); e_get_platform_info(&platform); clearMemory(); e_open(&dev, 0,0,4,4); e_reset_group(&dev); //initialize physics objects and Physics Engine PhysicsEngine engine; engine.count = 0; PhysicsObject obj; obj.type = OBJECT_TYPE_POLYGON; addPointToObject(&obj,pointMake(0,0)); addPointToObject(&obj,pointMake(2,-2)); addPointToObject(&obj,pointMake(4,0)); addPointToObject(&obj,pointMake(2,2)); obj.rotationCenter = pointMake(2,0); obj.position = pointMake(0.5,0.99); obj.rotation = 0; obj.inverseInertia = 1; obj.inverseMass = 1; obj.linearVelocity = pointMake(0,-1); obj.angularVelocity = 0; addObject(&engine,obj); //------- PhysicsObject obj2; obj2.type = OBJECT_TYPE_POLYGON; addPointToObject(&obj2,pointMake(0,-1)); addPointToObject(&obj2,pointMake(2,-4)); addPointToObject(&obj2,pointMake(4,-1)); obj2.rotationCenter = pointMake(2,-2); obj2.position = pointMake(0,0); obj2.rotation = 0; obj2.inverseInertia = 1; obj2.inverseMass = 1; obj2.linearVelocity = pointMake(0,0); obj2.angularVelocity = 0; addObject(&engine,obj2); //calculate minimun circles minimunCircles(&engine); printf("%x\n",sizeof(PhysicsObject)); distributeObjectsToCores(&engine,&dev); printf("frame->%x\n",sizeof(Frame)); char start = 1; for(i=0;i<4;i++){ for(j=0;j<4;j++){ e_load("epiphanyProgram.srec",&dev,i,j,E_TRUE); e_write(&dev,i,j,COMMADDRESS_READY, &start,sizeof(char)); //usleep(20000); } } //usleep(3000000); long long int TotalTime; gettimeofday(&initTime,NULL); Frame frm1, frm2; while(1){ e_read(&dev,0,0,COMMADDRESS_FRAMES,&frm1,sizeof(Frame)); e_read(&dev,0,1,COMMADDRESS_FRAMES,&frm2,sizeof(Frame)); printf("Frame---%d\nvelocity(%g,%g)\nposition(%g,%g)\nangVel%g\n",frm1.frameNumber,frm1.velocity.x,frm1.velocity.y,frm1.position.x,frm1.position.y,frm1.angVelocity); printf("Frame---%d\nvelocity(%g,%g)\nposition(%g,%g)\nangVel%g\n",frm1.frameNumber,frm2.velocity.x,frm2.velocity.y,frm2.position.x,frm2.position.y,frm2.angVelocity); gettimeofday(&endTime, NULL); TotalTime =endTime.tv_sec*1000+endTime.tv_usec/1000-initTime.tv_usec/1000-initTime.tv_sec*1000; float fps= frm1.frameNumber; fps = fps*1000/(float)TotalTime; printf("FPS=%g\n",fps); if(frm1.frameNumber >=20 && frm2.frameNumber >= 20){ break; } } gettimeofday(&endTime, NULL); TotalTime =endTime.tv_sec*1000+endTime.tv_usec/1000-initTime.tv_usec/1000-initTime.tv_sec*1000; printf("TotalTime = %lld\n", TotalTime); //-------------------------DUMP MEMORY ----------------------------- //read all memory e_open(&dev, 0, 0, platform.rows, platform.cols); fprintf(file,"(ROW,COL) ADDRESS DATA\n"); fprintf(file,"-----------------------------\n"); for (i=0; i<(platform.rows); i++) { for (j=0; j<(platform.cols); j++) { 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; } for(k=0;k<RAM_SIZE/4;k++){ fprintf(file,"(%2d,%2d) 0x%08x 0x%08x\n",i,j,k*4,read_buffer[k]); } } } fclose(file); e_close(&dev); e_finalize(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { unsigned row, col, coreid, i, j, m, n, k; int err = 0; unsigned mail0, mail1; e_platform_t platform; e_epiphany_t dev; e_mem_t emem; unsigned flag1 = 0x00000000; unsigned flag2 = 0x00000000; unsigned test = 0x00000000; mail0 = mas_row; mail1 = mas_col; 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 all slave cores for(i=0; i<platform.rows; i++) { for(j=0; j<platform.cols; j++) { if((i!=mas_row)|(j!=mas_col)) { e_load("e_dma_message_slave_test.srec", &dev, i, j, E_TRUE); } } } usleep(100000); // Send the coordinate of the transmitter to the receiver e_write(&dev, mas_row, mas_col, 0x6500, &mail0, sizeof(mail0)); e_write(&dev, mas_row, mas_col, 0x6600, &mail1, sizeof(mail1)); e_load("e_dma_message_test.srec", &dev, mas_row, mas_col, E_TRUE); // Wait for core program execution to finish usleep(1000000); // Results from every slave core coreid = (mas_row + platform.row) * 64 + mas_col + platform.col; fprintf(stderr,"Now the master core is 0x%03x (%2d,%2d)!\n",coreid, mas_row, mas_col); for (i=0; i<platform.rows; i++) { for(j=0; j<platform.cols; j++) { if((i!=mas_row)|(j!=mas_col)) { row=i; col=j; coreid = (row + platform.row) * 64 + col + platform.col; fprintf(stderr,"%d: Message from eCore 0x%03x (%2d,%2d) : \n",(row*platform.cols+col),coreid,row,col); // Read message from slave e_read(&dev, row, col, 0x6000, &flag1, sizeof(flag1)); e_read(&dev, row, col, 0x6100, &flag2, sizeof(flag2)); // Print the message and close the workgroup. if(flag1 == (unsigned) 0xdeadbeef) { fprintf(stderr, "PASS!\n"); }else { fprintf(stderr, "FAIL!\n"); 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; /* Assume 600 Mhz clock frequency. */ unsigned clk_max = 5600; /* 10 stddev */ unsigned clk_min = 1500; unsigned num; unsigned counter = 0; const uint32_t one = 1; const uint32_t zero = 0; 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); // 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_FALSE); // Load the device program onto all the other eCores e_load_group("e_mutex_test.srec", &dev, 0, 1, 1, 3, E_FALSE); e_load_group("e_mutex_test.srec", &dev, 1, 0, 3, 4, E_FALSE); usleep(1000); /* Clear the go flag */ e_write(&dev, 0, 0, 0x6400, &zero, sizeof(zero)); usleep(1000); /* Start all cores */ e_start_group(&dev); /* Give core0 plenty of time to initialize mutex */ usleep(10000); /* Go! */ e_write(&dev, 0, 0, 0x6400, &one, sizeof(one)); // Wait for core program execution to finish usleep(10000); /* Read results from core0 */ e_read(&dev, 0, 0, 0x6200, &num, sizeof(num)); e_read(&dev, 0, 0, 0x6300, &counter, sizeof(counter)); /* Clear go flag */ e_write(&dev, 0, 0, 0x6400, &zero, sizeof(zero)); // Print the message fprintf(stderr, "The counter now is %d\n", counter); fprintf(stderr, "The clock cycle is %d\n", num); if((num < clk_max)&&(num > clk_min)) { fprintf(stderr, "Clock: PASS\n"); } else { fprintf(stderr, "Clock: FAIL\n"); err = 1; } if (counter == 16) { fprintf(stderr, "Counter: PASS\n"); } else { fprintf(stderr, "Counter: FAIL\n"); err = 1; } // Close the workgroup e_close(&dev); // Finalize the e-platform connection. e_finalize(); return err; }
int main() { e_epiphany_t group0; e_mem_t shm1; host_chan_t chan2; e_mem_t shm3; pthread_t t5; bool r12; e_init(0); e_reset_system(); e_open(&group0, 0, 0, 4, 4); e_reset_group(&group0); setup_queues(); e_alloc(&shm1, sa2, 2048); init_host_chan(&chan2, &group0, 0, 0, &shm1, la0, la1); init_core_chan(&group0, 0, 1, la3, la4); e_load("core0.srec", &group0, 0, 0, 1); init_core_chan(&group0, 0, 2, la6, la7); e_load("core1.srec", &group0, 0, 1, 1); init_core_chan(&group0, 0, 3, la9, la10); e_load("core2.srec", &group0, 0, 2, 1); init_core_chan(&group0, 1, 3, la12, la13); e_load("core3.srec", &group0, 0, 3, 1); init_core_chan(&group0, 1, 2, la15, la16); e_load("core7.srec", &group0, 1, 3, 1); init_core_chan(&group0, 1, 1, la18, la19); e_load("core6.srec", &group0, 1, 2, 1); init_core_chan(&group0, 1, 0, la21, la22); e_load("core5.srec", &group0, 1, 1, 1); init_core_chan(&group0, 2, 0, la24, la25); e_load("core4.srec", &group0, 1, 0, 1); init_core_chan(&group0, 2, 1, la27, la28); e_load("core8.srec", &group0, 2, 0, 1); init_core_chan(&group0, 2, 2, la30, la31); e_load("core9.srec", &group0, 2, 1, 1); init_core_chan(&group0, 2, 3, la33, la34); e_load("core10.srec", &group0, 2, 2, 1); init_core_chan(&group0, 3, 3, la36, la37); e_load("core11.srec", &group0, 2, 3, 1); init_core_chan(&group0, 3, 2, la39, la40); e_load("core15.srec", &group0, 3, 3, 1); init_core_chan(&group0, 3, 1, la42, la43); e_load("core14.srec", &group0, 3, 2, 1); init_core_chan(&group0, 3, 0, la45, la46); e_load("core13.srec", &group0, 3, 1, 1); e_alloc(&shm3, sa50, 2048); init_host_chan(&chan4, &group0, 3, 0, &shm3, la48, la49); e_load("core12.srec", &group0, 3, 0, 1); pthread_create(&t5, NULL, thread_t5, NULL); r12 = true; while (1) { bool v13; float _a14[512]; float *a14 = _a14; bool v15; v13 = r12; if (!v13) break; v15 = receive_samples(a14); if (v15) { uint32_t r16; float _a17[512]; float *a17 = _a17; uint32_t v18; bool v19; r16 = 512; r16 = 512; for (v18 = 0; v18 < 512; v18++) { a17[v18] = a14[v18]; } v19 = host_write_h2c(chan2, a17, 0, r16); r12 = v19; } else { r12 = false; } } host_close_chan(chan2); pthread_join(t5, NULL); teardown_queues(); e_free(&shm1); e_free(&shm3); e_reset_group(&group0); e_close(&group0); e_finalize(); return 0; }