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[]){ e_platform_t platform; e_epiphany_t dev; int a[N], b[N], c[CORES]; int done[CORES],all_done; int sop; int i,j; unsigned clr; clr = (unsigned)0x00000000; //Calculation being done printf("Calculating sum of products of two integer vectors of length %d initalized to all 0x1's using %d Ccores.\n",N,CORES); printf("........\n"); //Initalize Epiphany device e_init(NULL); e_reset_system(); //reset Epiphany e_get_platform_info(&platform); e_open(&dev, 0, 0, platform.rows, platform.cols); //open all cores //Initialize a/b input vectors on host side for (i=0; i<N; i++){ a[i] = 1; b[i] = 1; } //1. Copy data (N/CORE points) from host to Epiphany local memory //2. Clear the "done" flag for every core for (i=0; i<platform.rows; i++){ for (j=0; j<platform.cols;j++){ e_write(&dev, i, j, 0x2000, &a, (N/CORES)*sizeof(int)); e_write(&dev, i, j, 0x4000, &b, (N/CORES)*sizeof(int)); e_write(&dev, i, j, 0x7000, &clr, sizeof(clr)); } } //Load program to cores and run e_load_group("e_task.srec", &dev, 0, 0, platform.rows, platform.cols, E_TRUE); //Check if all cores are done while(1){ all_done=0; for (i=0; i<platform.rows; i++){ for (j=0; j<platform.cols;j++){ e_read(&dev, i, j, 0x7000, &done[i*platform.cols+j], sizeof(int)); all_done+=done[i*platform.cols+j]; } } if(all_done==16){ break; } } //Copy all Epiphany results to host memory space for (i=0; i<platform.rows; i++){ for (j=0; j<platform.cols;j++){ e_read(&dev, i, j, 0x6000, &c[i*platform.cols+j], sizeof(int)); } } //Calculates final sum-of-product using Epiphany results as inputs sop=0; for (i=0; i<CORES; i++){ sop += c[i]; } //Print out result printf("Sum of Product Is %d!\n",sop); fflush(stdout); //Close down Epiphany device e_close(&dev); e_finalize(); if(sop==4096){ return EXIT_SUCCESS; } else{ return EXIT_FAILURE; } }
int main(int argc, char *argv[]){ e_loader_diag_t e_verbose; e_platform_t platform; e_epiphany_t dev, *pdev; e_mem_t dram, *pdram; size_t size; int status=1;//pass char elfFile[4096]; pdev = &dev; pdram = &dram; int a,b; int i,j; unsigned result[N]; unsigned data = 0xDEADBEEF; unsigned tmp,fail; int idelay[TAPS]={0x00000000,0x00000000,//0 0x11111111,0x00000001,//1 0x22222222,0x00000002,//2 0x33333333,0x00000003,//3 0x44444444,0x00000004,//4 0x55555555,0x00000005,//5 0x66666666,0x00000006,//6 0x77777777,0x00000007,//7 0x88888888,0x00000008,//8 0x99999999,0x00000009,//9 0xaaaaaaaa,0x0000000a,//10 0xbbbbbbbb,0x0000000b,//11 0xcccccccc,0x0000000c,//12 0xdddddddd,0x0000000d,//13 0xeeeeeeee,0x0000000e,//14 0xffffffff,0x0000000f,//15 0x00000000,0x00000010,//16 0x11111111,0x00000011,//17 0x22222222,0x00000012,//18 0x33333333,0x00000013,//29 0x44444444,0x00000014,//20 0x55555555,0x00000015,//21 0x66666666,0x00000016,//22 0x77777777,0x00000017,//23 0x88888888,0x00000018,//24 0x99999999,0x00000019,//25 0xaaaaaaaa,0x0000001a,//26 0xbbbbbbbb,0x0000001b,//27 0xcccccccc,0x0000001c,//28 0xdddddddd,0x0000001d,//29 0xeeeeeeee,0x0000001e,//30 0xffffffff,0x0000001f};//31 //Gets ELF file name from command line strcpy(elfFile, "./bin/e-task.elf"); //Initalize Epiphany device e_set_host_verbosity(H_D0); e_init(NULL); my_reset_system(); e_get_platform_info(&platform); e_open(&dev, 0, 0, 1, 1); //open core 0,0 e_alloc(pdram, 0x00000000, 0x00400000); //Set Idelay ee_write_esys(0xF0310, idelay[2*7]); ee_write_esys(0xF0314, idelay[2*7+1]); //Start Program e_load_group(elfFile, &dev, 0, 0, 1, 1, E_FALSE); e_start_group(&dev); usleep(1000000); //Check status int pre_stat,mbox_lo,mbox_hi,post_stat; int ddata; for(i=0;i<32;i++){ e_read(pdram,0,0, i, &ddata, sizeof(ddata)); pre_stat = ee_read_esys(0xF0738); mbox_lo = ee_read_esys(0xF0730); //mbox_hi = ee_read_esys(0xF0734); post_stat = ee_read_esys(0xF0738); printf ("PRE_STAT=%08x POST_STAT=%08x LO=%08x HI=%08x DDATA=%04x\n", pre_stat, post_stat, mbox_lo, mbox_hi,ddata); } for(i=0;i<16;i++){ e_read(pdram,0,0, i*4, &ddata, sizeof(ddata)); printf ("DDATA=%04x\n", ddata); } //Close down Epiphany device e_close(&dev); e_finalize(); //self check if(status){ return EXIT_SUCCESS; } else{ return EXIT_FAILURE; } }
int main(int argc, char *argv[]) { char eprog[255]; e_bool_t ireset, istart; e_epiphany_t dev; e_platform_t plat; unsigned row, col, rows, cols; int iarg, iiarg; e_get_platform_info(&plat); ireset = E_FALSE; istart = E_FALSE; row = plat.row; col = plat.col; rows = cols = 1; iarg = iiarg = 1; while (iiarg < argc) { if (!strcmp(argv[iiarg], "-h") || !strcmp(argv[iiarg], "--help")) { usage(); return 0; } else if (!strcmp(argv[iiarg], "-r") || !strcmp(argv[iiarg], "--reset")) { ireset = E_TRUE; iarg++; } else if (!strcmp(argv[iiarg], "-s") || !strcmp(argv[iiarg], "--start")) { istart = E_TRUE; iarg++; } iiarg++; } switch (argc - iarg) { case 5: rows = atoi(argv[iarg+3]); cols = atoi(argv[iarg+4]); case 3: row = atoi(argv[iarg+1]); col = atoi(argv[iarg+2]); case 1: strncpy(eprog, argv[iarg], 254); break; default: usage(); exit(1); } e_init(NULL); if (ireset) e_reset_system(); e_open(&dev, row, col, rows, cols); printf("Loading program \"%s\" on cores (%d,%d)-(%d,%d)\n", eprog, row, col, (row+rows-1), (col+cols-1)); e_set_loader_verbosity(L_D1); e_load_group(eprog, &dev, 0, 0, rows, cols, istart); e_close(&dev); e_finalize(); return 0; }
int main(int argc, char *argv[]) { unsigned row, col, coreid, i, j; e_platform_t platform; e_epiphany_t dev; e_mem_t emem; double tdiff; mailbox.flag = -1; matrix_init(0.0); //matrix_init(54.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, sizeof(Mailbox_t)); 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",_Smtx,_Smtx,_Smtx,_Smtx,_Smtx,_Smtx); fprintf(stderr, "\nGroup rows: %d Group_cols: %d. Starting row: %d col : %d\n",group_rows_num,group_cols_num,row,col); // Open the single-core workgroup. Note that we used // core coordinates relative to the workgroup. e_open(&dev, row, col, group_rows_num, group_cols_num); // Load the device program onto the selected eCore // and launch after loading. int load_err=e_load_group("matmul_multi.elf", &dev, 0, 0, group_rows_num, group_cols_num, E_FALSE); char load_result[5]; if (load_err == E_OK) strcpy(load_result,"E_OK"); if (load_err == E_ERR) strcpy(load_result,"E_ERR"); if (load_err == E_WARN) strcpy(load_result,"E_WARN"); fprintf(stderr,"Load result: %s\n",load_result); //gettimeofday(&timer[0], NULL); e_start_group(&dev); unsigned int addr = offsetof(Mailbox_t, flag); while (mailbox.flag != 0) { e_read(&emem, 0, 0, addr, &mailbox.flag, sizeof(mailbox.flag)); } //fprintf(stderr,"\nReceived Ready signal from Epiphany: %d\n",mailbox.flag); //Initialize and write the matrix to shared memory addr = offsetof(Mailbox_t, A[0]); e_write(&emem, 0, 0, addr, (void *)mailbox.A, sizeof(mailbox.A)); addr = offsetof(Mailbox_t, B[0]); e_write(&emem, 0, 0, addr, (void *)mailbox.B, sizeof(mailbox.B)); addr = offsetof(Mailbox_t, C[0]); e_write(&emem, 0, 0, addr, (void *)mailbox.C, sizeof(mailbox.C)); mailbox.flag = 1; addr = offsetof(Mailbox_t, flag); //fprintf(stderr,"\nSending Ready signal to Epiphany: %d\n",mailbox.flag); e_write(&emem, 0, 0, addr, &mailbox.flag, sizeof(mailbox.flag)); while (mailbox.flag != 2) e_read(&emem, 0, 0, addr, &mailbox.flag, sizeof(mailbox.flag)); gettimeofday(&timer[0], NULL); while (mailbox.flag != 3) e_read(&emem, 0, 0, addr, &mailbox.flag, sizeof(mailbox.flag)); gettimeofday(&timer[1], NULL); //usleep(3000000); //e_read(&emem, 0, 0, addr, &mailbox.flag, sizeof(mailbox.flag)); // Wait for core program execution to finish, then // read mailbox from shared buffer. while (mailbox.flag != 4) { 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); addr = offsetof(Mailbox_t, output); e_read(&emem, 0, 0, addr, &mailbox.output, sizeof(mailbox.output)); addr = offsetof(Mailbox_t, C[0]); e_read(&emem, 0, 0, addr, (void *)mailbox.C, sizeof(mailbox.C)); print_to_file("../output/optresult",(void *)mailbox.C); // Print the message and close the workgroup. e_close(&dev); tdiff = (timer[1].tv_sec - timer[0].tv_sec) * 1000 + ((double) (timer[1].tv_usec - timer[0].tv_usec) / 1000.0); //printf("Optimized MATMUL time: %d cycles\tTime: %9.9f msec\n", mailbox.output.clocks,clock_to_time(mailbox.output.clocks)); //printf("Optimized MATMUL Exec time: %d cycles\tTime: %9.9f msec\n", mailbox.output.dummy1,clock_to_time(mailbox.output.dummy1)); //printf("Optimized MATMUL Shared memory Comms time: %d cycles\tTime: %9.9f msec\n", (mailbox.output.clocks-mailbox.output.dummy1),clock_to_time(mailbox.output.clocks-mailbox.output.dummy1)); // //printf("\nTime from host: %9.6f msec\n",tdiff); float gflops = ((2.0 * _Smtx * _Smtx * _Smtx)/(clock_to_time(mailbox.output.clocks)/1000))/1000/1000/1000; float gflops2 = ((2.0 * _Smtx * _Smtx * _Smtx)/(clock_to_time(mailbox.output.dummy1)/1000))/1000/1000/1000; printf("\nGFlops (On chip): %9.6f\tPerformance = %9.4f %% of peak\n",gflops2,gflops2/(1.2*group_rows_num*group_cols_num)*100); printf("\nGFlops (including off-chip transfers): %9.6f\tPerformance = %9.4f %% of peak\n",gflops,gflops/(1.2*group_rows_num*group_cols_num)*100); fprintf(stderr,"\n"); // Release the allocated buffer and finalize the // e-platform connection. e_free(&emem); e_finalize(); return 0; }
int main () { unsigned int row, col, core, t; e_platform_t platform; e_epiphany_t device; e_mem_t mem; static msg_block_t msg; memset(&msg, 0, sizeof(msg)); e_init(NULL); e_reset_system(); e_get_platform_info(&platform); e_alloc(&mem, BUF_OFFSET, sizeof(msg_block_t)); /* Cómo sé que ^ pone el buffer en 0x8f00000000? */ /* Esta definido en el hdf por default. */ srand(SEED); for (row = 0; row < platform.rows; row++) { for (col = 0; col < platform.cols; col++) { core = row*platform.cols + col; msg.shared_msg[core].seed = SEED + core; printf("A (%d,%d) le toco %d\n", row, col, msg.shared_msg[core].seed); } } printf("\n---\n\n"); e_open(&device, 0, 0, platform.rows, platform.cols); e_write(&mem, 0, 0, 0, &msg, sizeof(msg)); e_reset_group(&device); e_load_group("epiphany.srec", &device, 0, 0, platform.rows, platform.cols, E_TRUE); nano_wait(0, 10000000); /* Necesario para sincronizar? */ for (row = 0; row < platform.rows; row++) { for (col = 0; col < platform.cols; col++) { core = row*platform.cols + col; t = 0; while (E_TRUE) { /* espero hasta que cambie algo */ e_read(&mem, 0, 0, (off_t) ((char *)&msg.shared_msg[core] - (char *)&msg), &msg.shared_msg[core], sizeof(msg_info_t)); if (msg.shared_msg[core].coreid != 0) { printf("Termino %d\n", core); break; } printf("."); nano_wait(0, 1000000); if (t++ == 10) { printf("Colgo %d\n", core); break; } } } } /* Ya hice todo lo que tenia que hacer, falta updatear. */ nano_wait(0, 1000000); for (row = 0; row < platform.rows; row++) { for (col = 0; col < platform.cols; col++) { core = row*platform.cols + col; e_read(&mem, 0, 0, (off_t) ((char *)&msg.shared_msg[core] - (char *)&msg), &msg.shared_msg[core], sizeof(msg_info_t)); } } for (row = 0; row < platform.rows; row++) { for (col = 0; col < platform.cols; col++) { core = row*platform.cols + col; printf("Hola, soy %#03x [%u] (%-2d, %-2d)! Tengo el mensaje %#03x, " "recibi el mensaje %u, y tarde %u ticks en procesar todo. " "seed ahora vale %d.\n", msg.shared_msg[core].coreid, msg.shared_msg[core].coreid, msg.shared_msg[core].coreid >> 6, msg.shared_msg[core].coreid & 0x3f, msg.shared_msg[core].msg, msg.shared_msg[core].external, msg.shared_msg[core].timer, msg.shared_msg[core].seed); } } e_close(&device); e_free(&mem); e_finalize(); return 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); }
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[]){ //---------------------------- e_platform_t platform; e_epiphany_t dev; e_loader_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; char result,data_in,expected; char high_pattern = 0xff; char low_pattern = 0x00; 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); //e_set_loader_verbosity(L_D3); printf("-------------------------------------------------------\n"); for (i=row0; i<(row0+rows); i++) { for (j=col0; j<(col0+cols); j++) { printf("Running host march-C read/write test for core (%d,%d)\n", i,j); //M0: UP{w0} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr= k; //W0 data_in=low_pattern; e_write(&dev, i, j, k, &data_in, sizeof(data_in)); } //M1: UP{r0,w1,r1,w0,r0,w1} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr= k; //R0 expected=low_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M1: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W1 data_in=high_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //R1 expected=high_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M1: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W0 data_in=low_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //R0 expected=low_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M1: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W1 data_in=high_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); } //M2: UP{r1,w0,w1} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr=(k); //R1 expected=high_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M2: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W0 data_in=low_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //W1 data_in=high_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); } //M3: DOWN{R1,W0,W1,W0} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr=(RAM_SIZE-k-WORD_SIZE); //R1 expected=high_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M3: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W0 data_in=low_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //W1 data_in=high_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //W0 data_in=low_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); } //M4:DOWN{R0,W1,W0} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr=(RAM_SIZE-k-WORD_SIZE); //R0 expected=low_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M4: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W1 data_in=high_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //W0 data_in=low_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); } //M5:DOWN{R0,W1,R1} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr=(RAM_SIZE-k-WORD_SIZE); //R0 expected=low_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M5: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W1 data_in=high_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //R1 expected=high_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M5: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } } //M6:DOWN{R1,W0,R0} for(k=0;k<(RAM_SIZE);k=k+WORD_SIZE){ addr=(RAM_SIZE-k-WORD_SIZE); //R1 expected=high_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M6: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } //W0 data_in=low_pattern; e_write(&dev, i, j, addr, &data_in, sizeof(data_in)); //R0 expected=low_pattern; e_read(&dev, i, j, addr, &result, sizeof(result)); if(result!=expected){ if(verbose){ printf("FAIL-PAT-M6: addr=0x%x expected=0x%x result=0x%x\n",addr,expected,result); } status=0; } } } } //Close e_close(&dev); e_finalize(); //Self Check if(status){ return EXIT_SUCCESS; } else{ return EXIT_FAILURE; } }
int main(int argc, char *argv[]) { unsigned row, col, core; e_platform_t platform; e_epiphany_t dev; int all_done, core_done; int i, x, y; int res; unsigned int *fp; fb = open(FB, O_RDWR); if (fb == -1) { perror("Unable to open fb " FB); return 1; } // rest here res = ioctl(fb, FBIOGET_FSCREENINFO, &fix); if (res != 0) { perror("getscreeninfo failed"); close(fb); return 1; } //printf("framebuffer size %d @ %08x\n", fix.smem_len, fix.smem_start); res = ioctl(fb, FBIOGET_VSCREENINFO, &var); if (res != 0) { perror("getscreeninfo failed"); close(fb); return 1; } //printf("size %dx%d @ %d bits per pixel\n", var.xres_virtual, var.yres_virtual, var.bits_per_pixel); fp = mmap(NULL, fix.smem_len, O_RDWR, MAP_SHARED, fb, 0); if (fp == (void *)-1) { perror("mmap failed"); close(fb); return 1; } //printf("virtual @ %p\n", fp); int stride = var.xres_virtual; srand(time(NULL)); int nBodies = 30000; int startFlag = 0x00000001; int iters = 5000; // simulation iterations const float dt = 0.05f; // time step if (argc > 1) nBodies = atoi(argv[1]); if (argc > 2) iters = atoi(argv[2]); Body *buf = (Body *) malloc(sizeof(Body) * nBodies); Body *bufOutput = (Body *) malloc(sizeof(Body) * nBodies); randomizeBodies(buf, nBodies); // Init pos / vel data e_init(NULL); e_reset_system(); e_get_platform_info(&platform); e_open(&dev, 0, 0, 4, 4); e_reset_group(&dev); e_load_group("e_rob_nbody.srec", &dev, 0, 0, 4, 4, E_FALSE); for (row = 0; row < platform.rows; row++){ for (col = 0; col < platform.cols; col++){ e_write(&dev, row, col, 0x00000004, &nBodies, sizeof(int)); } } e_write(&dev, 0, 0, 0x1000, (Body *) buf, sizeof(Body) * nBodies); x = 0; // for(x = 0; x < iters; x++){ while(1){ //fprintf(stderr, "Iter %d\n", x); for (row = 0; row < platform.rows; row++){ for (col = 0; col < platform.cols; col++){ e_write(&dev, row, col, 0x00000008, &startFlag, sizeof(int)); } } e_start_group(&dev); //Check if all cores are done while(1){ all_done = 0; for (row = 0; row < platform.rows; row++){ for (col = 0; col < platform.cols; col++){ e_read(&dev, row, col, 0x00000008, &core_done, sizeof(int)); all_done += core_done; } } if(all_done == 0){ break; } } e_read(&dev, 0, 0, 0x1000, (Body *) bufOutput, sizeof(Body) * nBodies); if(x != 0){ draw_stars(buf, nBodies, fp, stride, 0x00000000); } else{ x = 1; } draw_stars(bufOutput, nBodies, fp, stride, 0x00ffffff); memcpy(buf, bufOutput, sizeof(Body) * nBodies); } e_close(&dev); // Release the allocated buffer and finalize the // e-platform connection. e_finalize(); return 0; }
int my_reset_system() { unsigned int row,col,i,j,data; e_epiphany_t dev; e_platform_t platform; e_init(NULL); e_get_platform_info(&platform); ee_write_esys(E_SYS_RESET, 0);//reset usleep(200000); //Open all cores e_open(&dev, 0, 0, platform.rows, platform.cols); //shut down north link if(1){ 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 west link (WEST==2,0) if(1){ 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); } //Shut down south link (SOUTH==7,2) if(1){ if ((dev.type == E_E64G401)){ row=7; col=2; } else{ row=3; col=2; } 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); } //Change elink clock divider (temporary workaround due to FPGA timing issue) if(1){ //east link register is in a different place in e64 if ((dev.type == E_E64G401)){ row=2; col=7; } else{ row=2; col=3; } //Writing to the east ELINK transmit config register ee_write_esys(E_SYS_CONFIG, 0x50000000); data = 0x1; e_write(&dev, row, col, 0xf0300, &data, sizeof(int)); ee_write_esys(E_SYS_CONFIG, 0x00000000); } //Reset chip one more time (west side)) if(0){ row=2; col=0; ee_write_esys(E_SYS_CONFIG, 0xd0000000); data = 0x000000001; e_write(&dev, row, col, 0xf0324, &data, sizeof(int)); ee_write_esys(E_SYS_CONFIG, 0x00000000); } //Enable Clock Gating if(1){ 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)); } } } //Close down device e_close(&dev); return E_OK; }
int main(int argc, char *argv[]) { e_platform_t platform; unsigned success; unsigned board_rows, board_cols; unsigned ROWS, COLS; unsigned MaxGroupRows = 2; unsigned MaxGroupCols = 2; unsigned MODE; unsigned row, col; unsigned i, j, k, limit; unsigned a[3000], b[3000], c[3000]; FILE *fo = stdout; e_init(NULL); e_get_platform_info(&platform); board_rows = platform.rows; board_cols = platform.cols; MODE = atoi(argv[1]); limit = atoi(argv[2]); srand(time(NULL)); // Init input vectors for (k=0; k<limit; k++) { a[k] = k; b[k] = k; c[k] = 0; } while (1) { ROWS = rand() % MaxGroupRows + 1; COLS = rand() % MaxGroupCols + 1; // Resource manager success = e_reserve(MODE, ROWS, COLS, &row, &col); if (success == E_OK) { // Open workgroup fprintf(fo, "\tOpen workgroup...\n"); e_open(&dev, row, col, ROWS, COLS); // Load the program fprintf(fo, "\tLoad program onto workgroup...\n"); e_load_group("e_demo.srec", &dev, 0, 0, ROWS, COLS, E_FALSE); for (i=0; i<ROWS; i++) { for (j=0; j<COLS; j++) { e_write(&dev, i, j, 0x1e00, &limit, sizeof(limit)); e_write(&dev, i, j, 0x2000, a, sizeof(unsigned)*limit); e_write(&dev, i, j, 0x4000, b, sizeof(unsigned)*limit); } } e_start_group(&dev); usleep(300000); // Release the resource fprintf(fo, "\tRelease workgroup resource...\n"); e_release(ROWS, COLS, row, col); fprintf(fo, "Group was successfully released.\n"); } else fprintf(fo, "Failed to reserve workgroup!\n"); e_close(&dev); } e_finalize(); return 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 = 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_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); // Load the device program onto core (0,0) e_load_group("e_dma_chain_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, 0x6100, &flag1, sizeof(flag1)); e_read(&dev, i, j, 0x6104, &flag2, sizeof(flag2)); e_read(&dev, i, j, 0x6108, &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; }
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, j, m, n, k; int err = 0; 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"); err = 1; } // 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 err; }
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; 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[]) { e_platform_t platform; e_epiphany_t device; w_mapper_t mapper; w_sa_config_t sa_config; w_list_t task1; w_core_id_t first_id, last_id; Mailbox mailbox; memset(&mailbox, 0, sizeof(mailbox)); w_init_list(&task1, 0); printf("=== Initializing system\n"); e_set_host_verbosity(H_D0); e_init(NULL); e_reset_system(); e_get_platform_info(&platform); printf("=== Creating workgroup\n"); e_open(&device, 0, 0, platform.rows, platform.cols); printf("=== Mapping device program\n"); e_reset_group(&device); // Initialize the mapping system: we will use this to automatically map our // application, to assign a device program to each core. mapper = w_create_mapper(platform.rows, platform.cols); // Tell the mapper about our application. It needs to know about allocated // tasks, constraints and faults are optional. By default the mapper assumes // no faults and no constraints. w_set_allocation_matrix(&mapper, allocation_matrix); w_set_constraint_matrix(&mapper, constraint_matrix); w_set_fault_matrix(&mapper, fault_matrix); // Find the ID of all cores allocated for task 1, and create a link between // each core. Links are used to indicate which tasks that communicate with // each other, and to minimize the distance between communicating tasks. w_find_in_matrix(&mapper.allocation_matrix, &task1, 1); connect_task1(&mapper, &task1); // Map the application using simulated annealing. This is will optimize our // poor allocation. sa_config = w_create_sa_config(); if (w_assign_sa(&mapper, &sa_config) != E_OK) { printf("ERROR: Assignment failed.\n"); return 1; } w_print_matrix(&mapper.assignment_matrix, "Assignment"); w_print_matrix(&mapper.mapping_matrix, "Mapping"); // Find the ID of all cores assigned to task 1. w_find_in_matrix(&mapper.assignment_matrix, &task1, 1); first_id = task1.elements[0]; last_id = task1.elements[task1.size - 1]; printf("=== Setting initial conditions\n"); init_task1(&device, &task1); printf("=== Loading device program\n"); // Load the device program onto all cores assigned to task 1. if (w_load(&device, &task1, "e_main.srec") != E_OK) { printf("ERROR: Unable to load device program.\n"); return 1; } printf("=== Starting device\n"); e_start_group(&device); printf("=== Starting counter\n"); mailbox.go = 1; w_write(&device, first_id, _MAILBOX_ADDRESS, &mailbox, sizeof(mailbox)); printf("=== Waiting for last core\n"); do { msleep(100); w_read(&device, last_id, _MAILBOX_ADDRESS, &mailbox, sizeof(mailbox)); } while (mailbox.done == 0); printf("Counted to %i (expected %i)\n", mailbox.counter, task1.size - 1); printf("=== Finalizing\n"); w_free_mapper(&mapper); w_free_list(&task1); e_close(&device); e_finalize(); printf("=== Done\n"); return 0; }
int main(int argc, char *argv[]) { int i,j; unsigned row, col, coreid; unsigned di, ci, go, go_all; e_platform_t platform; e_epiphany_t dev; e_mem_t emem; // Initialize progress state in mailbox for(i=0;i<corenum;i++) for(j=0;j<40;j++) M[i][j] ='\0'; // initialize system, read platform params from // default HDF. Then, reset the platform. e_init(NULL); fprintf(stderr, "finished init\n"); e_reset_connected_system(); fprintf(stderr, "finished reset\n"); e_get_platform_info(&platform); fprintf(stderr, "platform info: num_chips =0x%x ,emems = 0x%x\n",platform.num_chips,platform.num_emems); fprintf(stderr, "hdf_ platform info: core (0,0) id =%x\n ", (0 + platform.row) * 64 + 0 + platform.col ); fprintf(stderr, "platform info: rows =0x%x ,cols = 0x%x\n",platform.rows,platform.cols ); corenum=platform.rows*platform.cols; // Open the first and second cores for master and slave programs, resp. fprintf(stderr, "starting e_open\n"); usleep(1e6); e_open(&dev, 0, 0, platform.rows, platform.cols); fprintf(stderr, "finished e_open\n"); // Allocate the ext. mem. mailbox e_alloc(&emem, _BufOffset, sizeof(M)); // Load programs on cores. fprintf(stderr, "starting e_load\n"); e_load_group("e-int-test.master.srec", &dev, 0, 0, platform.rows, platform.cols, E_FALSE); fprintf(stderr, "starting e_load\n"); //e_load("e-int-test.slave.srec", &dev, 0, 1, E_FALSE); // clear mailbox. e_write(&emem, 0, 0, (off_t) (0x0000), (void *) &(M[0]), sizeof(M)); usleep(500e3); // Print mbox status. print_mbox(&dev, &emem, "1. Clearing mbox:"); // start the master program e_start_group(&dev); printf("started :\n"); usleep(2e6); print_mbox(&dev, &emem, "2. started:"); //usleep(4e6); usleep(3e6); print_mbox(&dev, &emem, "3. started:"); // At this point, the mailbox should contain all of the progress // indicators, and look like the following: // // 0x808 0x809 0x22222222 0x33333333 0x44444444 // // If there is a "0xdeadbeef" state in one of the slots, it means // that something went wrong. // Finalize e_close(&dev); 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; /* 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(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; }
int main(int argc, char *argv[]) { e_epiphany_t Epiphany, *pEpiphany; e_mem_t DRAM, *pDRAM; unsigned int msize; int row, col, cnum; ILuint ImgId; // ILenum Error; ILubyte *imdata; ILuint imsize, imBpp; unsigned int addr; size_t sz; timeval_t timer[4]; uint32_t time_p[TIMERS]; uint32_t time_d[TIMERS]; FILE *fo; // FILE *fi; int result; pEpiphany = &Epiphany; pDRAM = &DRAM; msize = 0x00400000; get_args(argc, argv); // fi = fopen(ifname, "rb"); // fo = stdout; fo = fopen("matprt.m", "w"); if ((fo == NULL)) // || (fi == NULL)) { fprintf(stderr, "Could not open Octave file \"%s\" ...exiting.\n", "matprt.m"); exit(4); } // fo = stderr; // Connect to device for communicating with the Epiphany system // Prepare device e_set_loader_verbosity(ar.verbose); e_init(NULL); e_reset_system(); e_get_platform_info(&platform); if (e_open(pEpiphany, 0, 0, platform.rows, platform.cols)) { fprintf(fo, "\nERROR: Can't establish connection to Epiphany device!\n\n"); exit(1); } if (e_alloc(pDRAM, 0x00000000, msize)) { fprintf(fo, "\nERROR: Can't allocate Epiphany DRAM!\n\n"); exit(1); } // Initialize Epiphany "Ready" state addr = offsetof(shared_buf_t, core.ready); Mailbox.core.ready = 0; e_write(pDRAM, 0, 0, addr, (void *) &(Mailbox.core.ready), sizeof(Mailbox.core.ready)); printf("Loading program on Epiphany chip...\n"); strcpy(ar.srecFile, "../../device/Release/e_fft2d.srec"); result = e_load_group(ar.srecFile, pEpiphany, 0, 0, platform.rows, platform.cols, (e_bool_t) (ar.run_target)); if (result == E_ERR) { printf("Error loading Epiphany program.\n"); exit(1); } // Check if the DevIL shared lib's version matches the executable's version. if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION) { fprintf(stderr, "DevIL version is different ...exiting!\n"); exit(2); } // Initialize DevIL. ilInit(); #ifdef ILU_ENABLED iluInit(); #endif // create the coreID list init_coreID(pEpiphany, coreID, _Nside, _Nside, 0x808); // Generate the main image name to use, bind it and load the image file. ilGenImages(1, &ImgId); ilBindImage(ImgId); printf("\n"); printf("Loading original image from file \"%s\".\n\n", ar.ifname); if (!ilLoadImage(ar.ifname)) { fprintf(stderr, "Could not open input image file \"%s\" ...exiting.\n", ar.ifname); exit(3); } // Display the image's dimensions to the end user. printf("Width: %d Height: %d Depth: %d Bpp: %d\n\n", ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), ilGetInteger(IL_IMAGE_DEPTH), ilGetInteger(IL_IMAGE_BITS_PER_PIXEL)); imdata = ilGetData(); imsize = ilGetInteger(IL_IMAGE_WIDTH) * ilGetInteger(IL_IMAGE_HEIGHT); imBpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL); if (imsize != (_Sfft * _Sfft)) { printf("Image file size is different from %dx%d ...exiting.\n", _Sfft, _Sfft); exit(5); } // Extract image data into the A matrix. for (unsigned int i=0; i<imsize; i++) { Mailbox.A[i] = (float) imdata[i*imBpp] + 0.0 * I; } fprintf(fo, "\n"); // Generate operand matrices based on a provided seed matrix_init(0); #ifdef _USE_DRAM_ // Copy operand matrices to Epiphany system addr = DRAM_BASE + offsetof(shared_buf_t, A[0]); sz = sizeof(Mailbox.A); printf( "Writing A[%ldB] to address %08x...\n", sz, addr); fprintf(fo, "%% Writing A[%ldB] to address %08x...\n", sz, addr); e_write(addr, (void *) Mailbox.A, sz); addr = DRAM_BASE + offsetof(shared_buf_t, B[0]); sz = sizeof(Mailbox.B); printf( "Writing B[%ldB] to address %08x...\n", sz, addr); fprintf(fo, "%% Writing B[%ldB] to address %08x...\n", sz, addr); e_write(addr, (void *) Mailbox.B, sz); #else // Copy operand matrices to Epiphany cores' memory printf( "Writing image to Epiphany\n"); fprintf(fo, "%% Writing image to Epiphany\n"); sz = sizeof(Mailbox.A) / _Ncores; for (row=0; row<(int) platform.rows; row++) for (col=0; col<(int) platform.cols; col++) { addr = BankA_addr; printf("."); fflush(stdout); cnum = e_get_num_from_coords(pEpiphany, row, col); // printf( "Writing A[%uB] to address %08x...\n", sz, addr); fprintf(fo, "%% Writing A[%uB] to address %08x...\n", sz, (coreID[cnum] << 20) | addr); fflush(fo); e_write(pEpiphany, row, col, addr, (void *) &Mailbox.A[cnum * _Score * _Sfft], sz); } printf("\n"); #endif // Call the Epiphany fft2d() function printf( "GO!\n"); fprintf(fo, "%% GO!\n"); fflush(stdout); fflush(fo); gettimeofday(&timer[0], NULL); fft2d_go(pDRAM); gettimeofday(&timer[1], NULL); printf( "Done!\n\n"); fprintf(fo, "%% Done!\n\n"); fflush(stdout); fflush(fo); // Read time counters // printf( "Reading time count...\n"); fprintf(fo, "%% Reading time count...\n"); addr = 0x7128+0x4*2 + offsetof(core_t, time_p[0]); sz = TIMERS * sizeof(uint32_t); e_read(pEpiphany, 0, 0, addr, (void *) (&time_p[0]), sz); // for (int i=0; i<TIMERS; i++) // printf("time_p[%d] = %u\n", i, time_p[i]); time_d[2] = time_p[7] - time_p[2]; // FFT setup time_d[3] = time_p[2] - time_p[3]; // bitrev (x8) time_d[4] = time_p[3] - time_p[4]; // FFT-1D (x8) time_d[5] = time_p[4] - time_p[5]; // corner-turn time_d[6] = time_p[7] - time_p[8]; // FFT-2D time_d[7] = time_p[6] - time_p[7]; // LPF time_d[9] = time_p[0] - time_p[9]; // Total cycles printf( "Finished calculation in %u cycles (%5.3f msec @ %3.0f MHz)\n\n", time_d[9], (time_d[9] * 1000.0 / eMHz), (eMHz / 1e6)); fprintf(fo, "%% Finished calculation in %u cycles (%5.3f msec @ %3.0f MHz)\n\n", time_d[9], (time_d[9] * 1000.0 / eMHz), (eMHz / 1e6)); printf( "FFT2D - %7u cycles (%5.3f msec)\n", time_d[6], (time_d[6] * 1000.0 / eMHz)); printf( " FFT Setup - %7u cycles (%5.3f msec)\n", time_d[2], (time_d[2] * 1000.0 / eMHz)); printf( " BITREV - %7u cycles (%5.3f msec)\n", time_d[3], (time_d[3] * 1000.0 / eMHz)); printf( " FFT1D - %7u cycles (%5.3f msec x2)\n", time_d[4], (time_d[4] * 1000.0 / eMHz)); printf( " Corner Turn - %7u cycles (%5.3f msec)\n", time_d[5], (time_d[5] * 1000.0 / eMHz)); printf( "LPF - %7u cycles (%5.3f msec)\n", time_d[7], (time_d[7] * 1000.0 / eMHz)); printf( "\n"); printf( "Reading processed image back to host\n"); fprintf(fo, "%% Reading processed image back to host\n"); // Read result matrix #ifdef _USE_DRAM_ addr = DRAM_BASE + offsetof(shared_buf_t, B[0]); sz = sizeof(Mailbox.B); printf( "Reading B[%ldB] from address %08x...\n", sz, addr); fprintf(fo, "%% Reading B[%ldB] from address %08x...\n", sz, addr); blknum = sz / RdBlkSz; remndr = sz % RdBlkSz; for (i=0; i<blknum; i++) { printf("."); fflush(stdout); e_read(addr+i*RdBlkSz, (void *) ((long unsigned)(Mailbox.B)+i*RdBlkSz), RdBlkSz); } printf("."); fflush(stdout); e_read(addr+i*RdBlkSz, (void *) ((long unsigned)(Mailbox.B)+i*RdBlkSz), remndr); #else // Read result matrix from Epiphany cores' memory sz = sizeof(Mailbox.A) / _Ncores; for (row=0; row<(int) platform.rows; row++) for (col=0; col<(int) platform.cols; col++) { addr = BankA_addr; printf("."); fflush(stdout); cnum = e_get_num_from_coords(pEpiphany, row, col); // printf( "Reading A[%uB] from address %08x...\n", sz, addr); fprintf(fo, "%% Reading A[%uB] from address %08x...\n", sz, (coreID[cnum] << 20) | addr); fflush(fo); e_read(pEpiphany, row, col, addr, (void *) &Mailbox.B[cnum * _Score * _Sfft], sz); } #endif printf("\n"); // Convert processed image matrix B into the image file date. for (unsigned int i=0; i<imsize; i++) { for (unsigned int j=0; j<imBpp; j++) imdata[i*imBpp+j] = cabs(Mailbox.B[i]); } // Save processed image to the output file. ilEnable(IL_FILE_OVERWRITE); printf("\nSaving processed image to file \"%s\".\n\n", ar.ofname); if (!ilSaveImage(ar.ofname)) { fprintf(stderr, "Could not open output image file \"%s\" ...exiting.\n", ar.ofname); exit(7); } // We're done with the image, so let's delete it. ilDeleteImages(1, &ImgId); // Simple Error detection loop that displays the Error to the user in a human-readable form. // while ((Error = ilGetError())) // PRINT_ERROR_MACRO; // 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); } fflush(fo); fclose(fo); //Returnin success if test runs expected number of clock cycles //Need to add comparison with golden reference image! if(time_d[9]>50000){ return EXIT_SUCCESS; } else{ return EXIT_FAILURE; } }
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; }
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(int argc, char *argv[]){ e_loader_diag_t e_verbose; e_platform_t platform; e_epiphany_t dev; int row0,col0,rows,cols,para; char elfFile[4096]; int status=1;//pass int i,j; if (argc < 5){ usage(); status=0; } else{ row0 = atoi(argv[1]); col0 = atoi(argv[2]); rows = atoi(argv[3]); cols = atoi(argv[4]); para = atoi(argv[5]); strcpy(elfFile, argv[6]); //Initalize Epiphany device e_init(NULL); e_reset_system(); e_get_platform_info(&platform); //e_set_loader_verbosity(L_D3); e_open(&dev, 0, 0, platform.rows, platform.cols); //open all cores //Load program one at a time, checking one a time if(para){ printf("Running in parallel\n"); for (i=row0; i<(row0+rows); i++) { for (j=col0; j<(col0+cols); j++) { e_load_group(elfFile, &dev, i, j, 1, 1, E_TRUE); } } } else{ e_load_group(elfFile, &dev, row0, col0, (row0+rows), (col0+cols), E_TRUE); } //Checking the test for (i=row0; i<(row0+rows); i++) { for (j=col0; j<(col0+cols); j++) { e_check_test(&dev, i, j, &status); } } //Close down Epiphany device e_close(&dev); e_finalize(); } //self check if(status){ return EXIT_SUCCESS; } else{ return EXIT_FAILURE; } }
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; }
int main(int argc, char *argv[]){ e_platform_t platform; e_epiphany_t dev; unsigned int row, col; unsigned int data; int row0,col0,rows,cols; int i,j; if(argc < 2){ usage(); return EXIT_FAILURE; } else{ row0 = atoi(argv[1]); col0 = atoi(argv[2]); rows = atoi(argv[3]); cols = atoi(argv[4]); } //Open e_init(NULL); e_get_platform_info(&platform); e_open(&dev, 0, 0, platform.rows, platform.cols); //e_set_host_verbosity(H_D3); //Put Code here printf("CORE CONFIG STATUS PC CTIMER0 CTIMER1 DMA0STATUS DMA1STATUS DEBUG IRET IMASK ILAT IPEND\n"); printf("--------------------------------------------------------------------------------------------------------------------------------------------\n"); for (i=row0; i<rows; i++) { for (j=col0; j<cols; j++) { printf("%02d%02d ", i,j); e_read(&dev, i, j, 0xf0400, &data, sizeof(unsigned));//config printf("0x%08x ",data); e_read(&dev, i, j, 0xf0404, &data, sizeof(unsigned));//status printf("0x%08x ",data); e_read(&dev, i, j, 0xf0408, &data, sizeof(unsigned));//pc printf("0x%08x ",data); e_read(&dev, i, j, 0xf0438, &data, sizeof(unsigned));//ctimer0 printf("0x%08x ",data); e_read(&dev, i, j, 0xf043C, &data, sizeof(unsigned));//ctimer1 printf("0x%08x ",data); e_read(&dev, i, j, 0xf051C, &data, sizeof(unsigned));//dam0status printf("0x%08x ",data); e_read(&dev, i, j, 0xf053C, &data, sizeof(unsigned));//dma1status printf("0x%08x ",data); e_read(&dev, i, j, 0xf040C, &data, sizeof(unsigned));//debug printf("0x%04x ",data); e_read(&dev, i, j, 0xf0420, &data, sizeof(unsigned));//iret printf("0x%04x ",data); e_read(&dev, i, j, 0xf0424, &data, sizeof(unsigned));//imask printf("0x%04x ",data); e_read(&dev, i, j, 0xf0428, &data, sizeof(unsigned));//ilat printf("0x%04x ",data); e_read(&dev, i, j, 0xf0434, &data, sizeof(unsigned));//ipend printf("0x%04x ",data); printf("\n"); } } //Close e_close(&dev); e_finalize(); return EXIT_SUCCESS; }
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[]){ //---------------------------- e_platform_t platform; e_epiphany_t dev; e_loader_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; } }