Changeset 669 for soft/giet_vm/applications
- Timestamp:
- Jul 27, 2015, 8:40:45 PM (9 years ago)
- Location:
- soft/giet_vm/applications
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/classif/main.c
r549 r669 11 11 // It can run on architectures containing up to 16 * 16 clusters, 12 12 // and up to 8 processors per cluster. 13 // 14 // It requires N+2 TTY terminals, as each task in cluster[0][0] displays messages. 13 15 // 14 16 // This application is described as a TCG (Task and Communication Graph) … … 142 144 if ( (x==0) && (y==0) ) 143 145 { 144 giet_tty_alloc(); 146 // allocate a private TTY 147 giet_tty_alloc(0); 145 148 146 149 giet_tty_printf("\n*** Task load on P[%d][%d][%d] starts at cycle %d\n" … … 299 302 if ( (x==0) && (y==0) ) 300 303 { 301 giet_tty_alloc(); 304 // allocate a private TTY 305 giet_tty_alloc(0); 302 306 303 307 giet_tty_printf("\n*** Task store on P[%d][%d][%d] starts at cycle %d\n" … … 439 443 if ( (x==0) && (y==0) ) 440 444 { 441 giet_tty_alloc(); 445 // allocate a private TTY 446 giet_tty_alloc(0); 442 447 443 448 giet_tty_printf("\n*** Task analyse on P[%d][%d][%d] starts at cycle %d\n" -
soft/giet_vm/applications/convol/convol.py
r610 r669 40 40 41 41 data_base = 0x20000000 42 data_size = 0x000 10000 # 64Kbytes (non replicated)42 data_size = 0x00020000 # 128 Kbytes (non replicated) 43 43 44 44 heap_base = 0x40000000 … … 49 49 50 50 # create Vspace 51 vspace = mapping.addVspace( name = 'convol', startname = 'conv_data' )51 vspace = mapping.addVspace( name = 'convol', startname = 'conv_data', active = False ) 52 52 53 53 # data vseg in cluster[0,0] : non local -
soft/giet_vm/applications/convol/main.c
r589 r669 1 1 /////////////////////////////////////////////////////////////////////////////////////// 2 // File : main.c ( forconvol application)2 // File : main.c (convol application) 3 3 // Date : june 2014 4 4 // author : Alain Greiner … … 22 22 23 23 #define USE_SQT_BARRIER 1 24 #define VERBOSE 024 #define VERBOSE 1 25 25 #define SUPER_VERBOSE 0 26 26 … … 49 49 #define max(x,y) ((x) > (y) ? (x) : (y)) 50 50 #define min(x,y) ((x) < (y) ? (x) : (y)) 51 52 // macro to use a shared TTY 53 #define printf(...) lock_acquire( &tty_lock ); \ 54 giet_tty_printf(__VA_ARGS__); \ 55 lock_release( &tty_lock ) 51 56 52 57 // global instrumentation counters (cluster_id, lpid] … … 60 65 unsigned int D_END[CLUSTERS_MAX][PROCS_MAX]; 61 66 62 // global synchronization barrier 67 // global synchronization barriers 63 68 64 69 #if USE_SQT_BARRIER … … 71 76 volatile unsigned int load_image_ok = 0; 72 77 volatile unsigned int instrumentation_ok = 0; 78 79 // lock protecting access to shared TTY 80 user_lock_t tty_lock; 73 81 74 82 // global pointers on distributed buffers in all clusters … … 138 146 START[cluster_id][lpid] = date; 139 147 140 #if VERBOSE141 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n", x,y,lpid, date );142 #endif143 144 148 // parameters checking 145 149 … … 161 165 162 166 /////////////////////////////////////////////////////////////////// 163 // task[0][0][0] makes barrier initialisation167 // task[0][0][0] makes various initialisations 164 168 /////////////////////////////////////////////////////////////////// 165 169 166 170 if ( (x==0) && (y==0) && (lpid==0) ) 167 171 { 168 giet_shr_printf("\n[CONVOL] task[0,0,0] starts barrier init at cycle %d\n" 169 "- CLUSTERS = %d\n" 170 "- PROCS = %d\n" 171 "- TASKS = %d\n" 172 "- LINES/TASK = %d\n", 173 giet_proctime(), nclusters, nprocs, ntasks, lines_per_task ); 172 // get a shared TTY 173 giet_tty_alloc( 1 ); 174 175 // initializes TTY lock 176 lock_init( &tty_lock ); 177 178 // initializes the distributed heap[x,y] 179 unsigned int cx; 180 unsigned int cy; 181 for ( cx = 0 ; cx < x_size ; cx++ ) 182 { 183 for ( cy = 0 ; cy < y_size ; cy++ ) 184 { 185 heap_init( cx , cy ); 186 } 187 } 188 174 189 #if USE_SQT_BARRIER 175 190 sqt_barrier_init( &barrier, x_size , y_size , nprocs ); … … 178 193 #endif 179 194 180 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes barrier init at cycle %d\n", 181 giet_proctime() ); 195 printf("\n[CONVOL] task[0,0,0] completes initialisation at cycle %d\n" 196 "- CLUSTERS = %d\n" 197 "- PROCS = %d\n" 198 "- TASKS = %d\n" 199 "- LINES/TASK = %d\n", 200 giet_proctime(), nclusters, nprocs, ntasks, lines_per_task ); 182 201 183 202 barrier_init_ok = 1; … … 196 215 197 216 #if VERBOSE 198 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] enters malloc at cycle %d\n",217 printf( "\n[CONVOL] task[%d,%d,%d] enters malloc at cycle %d\n", 199 218 x,y,lpid, date ); 200 219 #endif … … 207 226 208 227 #if VERBOSE 209 giet_shr_printf( "\n[CONVOL] Shared Buffer Virtual Addresses in cluster(%d,%d)\n"210 211 212 213 214 215 216 217 218 219 220 228 printf( "\n[CONVOL] Shared Buffer Virtual Addresses in cluster(%d,%d)\n" 229 "### GA = %x\n" 230 "### GB = %x\n" 231 "### GC = %x\n" 232 "### GD = %x\n" 233 "### GZ = %x\n", 234 x, y, 235 GA[cluster_id], 236 GB[cluster_id], 237 GC[cluster_id], 238 GD[cluster_id], 239 GZ[cluster_id] ); 221 240 #endif 222 241 } … … 257 276 { 258 277 // open file 259 file = giet_fat_open( " misc/philips_image.raw" , 0 );278 file = giet_fat_open( "/misc/philips_1024.raw" , 0 ); 260 279 if ( file < 0 ) giet_exit( "[CONVOL ERROR] task[0,0,0] cannot open" 261 " file misc/philips_image.raw" );280 " file /misc/philips_1024.raw" ); 262 281 263 giet_shr_printf( "\n[CONVOL] task[0,0,0] open file misc/philips_image.raw"264 282 printf( "\n[CONVOL] task[0,0,0] open file /misc/philips_1024.raw" 283 " at cycle %d\n", giet_proctime() ); 265 284 266 285 for ( c = 0 ; c < nclusters ; c++ ) 267 286 { 268 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts load "269 287 printf( "\n[CONVOL] task[0,0,0] starts load " 288 "for cluster %d at cycle %d\n", c, giet_proctime() ); 270 289 271 290 giet_fat_lseek( file, … … 277 296 frame_size/nclusters ); 278 297 279 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes load "280 298 printf( "\n[CONVOL] task[0,0,0] completes load " 299 "for cluster %d at cycle %d\n", c, giet_proctime() ); 281 300 } 282 301 load_image_ok = 1; … … 296 315 297 316 #if VERBOSE 298 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display"299 300 317 printf( "\n[CONVOL] task[%d,%d,%d] starts initial display" 318 " at cycle %d\n", 319 x, y, lpid, giet_proctime() ); 301 320 #endif 302 321 … … 319 338 320 339 #if VERBOSE 321 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display"322 323 340 printf( "\n[CONVOL] task[%d,%d,%d] completes initial display" 341 " at cycle %d\n", 342 x, y, lpid, giet_proctime() ); 324 343 #endif 325 344 … … 347 366 348 367 #if VERBOSE 349 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"350 351 368 printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter" 369 " at cycle %d\n", 370 x, y, lpid, date ); 352 371 #else 353 372 if ( (x==0) && (y==0) && (lpid==0) ) 354 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"355 373 printf( "\n[CONVOL] task[0,0,0] starts horizontal filter" 374 " at cycle %d\n", date ); 356 375 #endif 357 376 … … 412 431 413 432 #if SUPER_VERBOSE 414 giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );433 printf(" - line %d computed at cycle %d\n", l, giet_proctime() ); 415 434 #endif 416 435 … … 421 440 422 441 #if VERBOSE 423 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"424 425 442 printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter" 443 " at cycle %d\n", 444 x, y, lpid, date ); 426 445 #else 427 446 if ( (x==0) && (y==0) && (lpid==0) ) 428 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"429 447 printf( "\n[CONVOL] task[0,0,0] completes horizontal filter" 448 " at cycle %d\n", date ); 430 449 #endif 431 450 … … 451 470 452 471 #if VERBOSE 453 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"454 455 472 printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter" 473 " at cycle %d\n", 474 x, y, lpid, date ); 456 475 #else 457 476 if ( (x==0) && (y==0) && (lpid==0) ) 458 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter"459 477 printf( "\n[CONVOL] task[0,0,0] starts vertical filter" 478 " at cycle %d\n", date ); 460 479 #endif 461 480 … … 532 551 533 552 #if SUPER_VERBOSE 534 giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());553 printf(" - column %d computed at cycle %d\n", p, giet_proctime()); 535 554 #endif 536 555 … … 541 560 542 561 #if VERBOSE 543 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"544 545 562 printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter" 563 " at cycle %d\n", 564 x, y, lpid, date ); 546 565 #else 547 566 if ( (x==0) && (y==0) && (lpid==0) ) 548 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter"549 567 printf( "\n[CONVOL] task[0,0,0] completes vertical filter" 568 " at cycle %d\n", date ); 550 569 #endif 551 570 … … 568 587 569 588 #if VERBOSE 570 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display"571 572 589 printf( "\n[CONVOL] task[%d,%d,%d] starts final display" 590 " at cycle %d\n", 591 x, y, lpid, date); 573 592 #else 574 593 if ( (x==0) && (y==0) && (lpid==0) ) 575 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display"576 594 printf( "\n[CONVOL] task[0,0,0] starts final display" 595 " at cycle %d\n", date ); 577 596 #endif 578 597 … … 600 619 601 620 #if VERBOSE 602 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display"603 604 621 printf( "\n[CONVOL] task[%d,%d,%d] completes final display" 622 " at cycle %d\n", 623 x, y, lpid, date); 605 624 #else 606 625 if ( (x==0) && (y==0) && (lpid==0) ) 607 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display"608 626 printf( "\n[CONVOL] task[0,0,0] completes final display" 627 " at cycle %d\n", date ); 609 628 #endif 610 629 … … 625 644 { 626 645 date = giet_proctime(); 627 giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation"628 646 printf("\n[CONVOL] task[0,0,0] starts instrumentation" 647 " at cycle %d\n\n", date ); 629 648 630 649 int cc, pp; … … 678 697 } 679 698 680 giet_shr_printf(" - START : min = %d / max = %d / med = %d / delta = %d\n",699 printf(" - START : min = %d / max = %d / med = %d / delta = %d\n", 681 700 min_start, max_start, (min_start+max_start)/2, max_start-min_start); 682 701 683 giet_shr_printf(" - H_BEG : min = %d / max = %d / med = %d / delta = %d\n",702 printf(" - H_BEG : min = %d / max = %d / med = %d / delta = %d\n", 684 703 min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg); 685 704 686 giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",705 printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n", 687 706 min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end); 688 707 689 giet_shr_printf(" - V_BEG : min = %d / max = %d / med = %d / delta = %d\n",708 printf(" - V_BEG : min = %d / max = %d / med = %d / delta = %d\n", 690 709 min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg); 691 710 692 giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",711 printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n", 693 712 min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end); 694 713 695 giet_shr_printf(" - D_BEG : min = %d / max = %d / med = %d / delta = %d\n",714 printf(" - D_BEG : min = %d / max = %d / med = %d / delta = %d\n", 696 715 min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg); 697 716 698 giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",717 printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n", 699 718 min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end); 700 719 701 giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" );702 giet_shr_printf( " - BOOT OS = %d\n", (min_start )/1000 );703 giet_shr_printf( " - LOAD IMAGE = %d\n", (min_h_beg - min_start)/1000 );704 giet_shr_printf( " - H_FILTER = %d\n", (max_h_end - min_h_beg)/1000 );705 giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );706 giet_shr_printf( " - V_FILTER = %d\n", (max_v_end - min_v_beg)/1000 );707 giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );708 giet_shr_printf( " - DISPLAY = %d\n", (max_d_end - min_d_beg)/1000 );720 printf( "\n General Scenario (Kcycles for each step)\n" ); 721 printf( " - BOOT OS = %d\n", (min_start )/1000 ); 722 printf( " - LOAD IMAGE = %d\n", (min_h_beg - min_start)/1000 ); 723 printf( " - H_FILTER = %d\n", (max_h_end - min_h_beg)/1000 ); 724 printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 ); 725 printf( " - V_FILTER = %d\n", (max_v_end - min_v_beg)/1000 ); 726 printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 ); 727 printf( " - DISPLAY = %d\n", (max_d_end - min_d_beg)/1000 ); 709 728 710 729 instrumentation_ok = 1; -
soft/giet_vm/applications/coproc/main.c
r589 r669 34 34 giet_proc_xyp( &x, &y, &lpid ); 35 35 36 giet_shr_printf("\n*** Starting coproc application on processor" 36 // get a private TTY terminal 37 giet_tty_alloc( 0 ); 38 39 giet_tty_printf("\n*** Starting coproc application on processor" 37 40 "[%d,%d,%d] at cycle %d\n", 38 41 x, y, lpid, giet_proctime() ); … … 63 66 64 67 if ( VERBOSE ) 65 giet_ shr_printf("\n*** get GCD coprocessor at cycle %d\n", giet_proctime() );68 giet_tty_printf("\n*** get GCD coprocessor at cycle %d\n", giet_proctime() ); 66 69 67 70 //////////////////////// initializes channel for OPA … … 87 90 88 91 if ( VERBOSE ) 89 giet_ shr_printf("\n*** channels initialized at cycle %d\n", giet_proctime() );92 giet_tty_printf("\n*** channels initialized at cycle %d\n", giet_proctime() ); 90 93 91 94 /////////////////////// starts communication channels … … 93 96 94 97 if ( VERBOSE ) 95 giet_ shr_printf("\n*** start GCD coprocessor at cycle %d\n", giet_proctime() );98 giet_tty_printf("\n*** start GCD coprocessor at cycle %d\n", giet_proctime() ); 96 99 97 100 /////////////////////// wait coprocessor completion … … 102 105 103 106 if ( VERBOSE ) 104 giet_ shr_printf("\n*** GCD computation completed at cycle %d\n", giet_proctime() );107 giet_tty_printf("\n*** GCD computation completed at cycle %d\n", giet_proctime() ); 105 108 106 109 // display result 107 110 for ( word = 0 ; word < VECTOR_SIZE ; word++ ) 108 111 { 109 giet_ shr_printf("pgcd( %d , %d ) = %d\n",112 giet_tty_printf("pgcd( %d , %d ) = %d\n", 110 113 opa[word] , opb[word] , res[word] ); 111 114 } -
soft/giet_vm/applications/display/main.c
r644 r669 17 17 #define NIMAGES 10 18 18 19 #define INTERACTIVE 119 #define INTERACTIVE 0 20 20 21 21 unsigned char buf0[NPIXELS*NLINES] __attribute__((aligned(64))); … … 47 47 48 48 // get a private TTY 49 giet_tty_alloc( );49 giet_tty_alloc(0); 50 50 51 51 giet_tty_printf("\n[DISPLAY] P[%d,%d,%d] starts at cycle %d\n" -
soft/giet_vm/applications/gameoflife/gameoflife.py
r610 r669 49 49 50 50 # create vspace 51 vspace = mapping.addVspace( name = 'g ol', startname = 'gol_data')51 vspace = mapping.addVspace( name = 'gameoflife', startname = 'gol_data', active = False ) 52 52 53 53 # data vseg : shared (only in cluster[0,0]) -
soft/giet_vm/applications/gameoflife/main.c
r515 r669 5 5 // Alain Greiner <alain.greiner@lip6.fr> february 2015 6 6 // 7 // This application is an emulation of the Game of Life automaton.7 // This multi-threaded application is an emulation of the Game of Life automaton. 8 8 // The world size is defined by the HEIGHT and WIDTH parameters. 9 9 // There is one task per processor. 10 10 // Each task compute HEIGHT/nbprocs lines. 11 // Task running on processor P(0,0,0) initialises the barrier, and12 // the chained buffer DMA controler.11 // Task running on processor P(0,0,0) initialises the barrier, the TTY terminal, 12 // and the chained buffer DMA controler. 13 13 // 14 14 // The number of processors must be a power of 2 not larger than HEIGHT. … … 19 19 #include "user_barrier.h" 20 20 #include "mapping_info.h" 21 #include "hard_config.h" 21 22 22 23 #define WIDTH 128 … … 24 25 #define NB_ITERATION 1000000000 25 26 26 #define PRINTF(...) ({ if ( proc_id==0) { giet_ shr_printf(__VA_ARGS__); } })27 #define PRINTF(...) ({ if ( proc_id==0) { giet_tty_printf(__VA_ARGS__); } }) 27 28 28 29 typedef unsigned char uint8_t; … … 31 32 32 33 uint8_t DISPLAY[2][HEIGHT][WIDTH] __attribute__((aligned(64))); 34 35 unsigned int status0[16]; 36 unsigned int status1[16]; 33 37 34 38 giet_sqt_barrier_t barrier; … … 121 125 //////////////////////////////////////// 122 126 __attribute__((constructor)) void main() 127 //////////////////////////////////////// 123 128 { 124 129 // get processor identifier … … 131 136 unsigned int x_size; 132 137 unsigned int y_size; 133 unsigned int n _local_procs;134 giet_procs_number( &x_size, &y_size, &n _local_procs );138 unsigned int nprocs; 139 giet_procs_number( &x_size, &y_size, &nprocs ); 135 140 136 141 // compute continuous processor index & number of procs 137 unsigned int proc_id = (((x * y_size) + y) * n _local_procs) + p;138 unsigned int n_global_procs = x_size * y_size * n _local_procs;142 unsigned int proc_id = (((x * y_size) + y) * nprocs) + p; 143 unsigned int n_global_procs = x_size * y_size * nprocs; 139 144 140 145 unsigned int i; 141 142 if ( n_global_procs > HEIGHT )143 {144 PRINTF("[GAMEOFLIFE ERROR] Number or processors too large :"145 " nb_procs = %d / image heigth = %d\n", n_global_procs, HEIGHT );146 giet_exit("error");147 }148 146 149 147 unsigned int nb_line = HEIGHT / n_global_procs; 150 148 unsigned int base_line = nb_line * proc_id; 151 149 152 PRINTF("\n*** Starting barrier and CMA initialisation at cycle %d ***\n" 153 " nprocs = %d / nlines = %d\n", 154 giet_proctime() , n_global_procs, HEIGHT ); 155 156 //////////// barrier & CMA initialization ( P(0,0,0) ) 157 150 // parameters checking 151 giet_assert( (n_global_procs <= HEIGHT), 152 " Number or processors larger than world height" ); 153 154 giet_assert( ((WIDTH == FBUF_X_SIZE) && (HEIGHT == FBUF_Y_SIZE)), 155 "Frame Buffer size does not fit the world size" ); 156 157 giet_assert( ((x_size == 1) || (x_size == 2) || (x_size == 4) || 158 (x_size == 8) || (x_size == 16)), 159 "x_size must be a power of 2 no larger than 16" ); 160 161 giet_assert( ((y_size == 1) || (y_size == 2) || (y_size == 4) || 162 (y_size == 8) || (y_size == 16)), 163 "y_size must be a power of 2 no larger than 16" ); 164 165 giet_assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)), 166 "nprocs must be a power of 2 no larger than 4" ); 167 168 // P[0,0,0] makes initialisation 158 169 if ( proc_id == 0 ) 159 170 { 160 // initialises CMA component 171 // get a private TTY for P[0,0,0] 172 giet_tty_alloc( 0 ); 173 174 // get a Chained Buffer DMA channel 161 175 giet_fbf_cma_alloc(); 162 giet_fbf_cma_start( &DISPLAY[0][0][0] , 163 &DISPLAY[1][0][0] , 164 HEIGHT * WIDTH ); 176 177 // initializes the source and destination buffers 178 giet_fbf_cma_init_buf( &DISPLAY[0][0][0] , 179 &DISPLAY[1][0][0] , 180 status0 , 181 status1 ); 182 183 // activates CMA channel 184 giet_fbf_cma_start( HEIGHT * WIDTH ); 185 186 // initializes distributed heap 187 unsigned int cx; 188 unsigned int cy; 189 for ( cx = 0 ; cx < x_size ; cx++ ) 190 { 191 for ( cx = 0 ; cx < x_size ; cx++ ) 192 { 193 heap_init( cx , cy ); 194 } 195 } 165 196 166 197 // initialises barrier 167 sqt_barrier_init( &barrier , x_size , y_size , n_local_procs ); 198 sqt_barrier_init( &barrier , x_size , y_size , nprocs ); 199 200 PRINTF("\n[GAMEOFLIFE] P[0,0,0] completes initialisation at cycle %d\n" 201 " nprocs = %d / nlines = %d\n", 202 giet_proctime() , n_global_procs, HEIGHT ); 168 203 169 204 // activates all other processors … … 175 210 } 176 211 177 PRINTF("\n*** Starting world initialisation at cycle %d ***\n",178 giet_proctime() );179 180 212 ///////////// world initialization ( All processors ) 181 213 182 // initialisesWORLD[0]214 // All processors initialize WORLD[0] 183 215 init_world( 0 , base_line , nb_line ); 184 216 … … 192 224 if ( proc_id == 0 ) giet_fbf_cma_display ( 0 ); 193 225 194 PRINTF("\n *** Starting evolution at cycle %d ***\n", giet_proctime() );226 PRINTF("\n[GAMEOFLIFE] starts evolution at cycle %d\n", giet_proctime() ); 195 227 196 228 //////////// evolution : 2 steps per iteration -
soft/giet_vm/applications/shell/main.c
r660 r669 163 163 } 164 164 165 ///////////////////////////////////////// 165 166 static void cmd_rm(int argc, char **argv) 166 167 { … … 326 327 int count = 0; 327 328 328 giet_shr_printf("\n[SHELL] Enter at cycle %d\n", giet_proctime()); 329 giet_tty_alloc(); 329 // get a private TTY 330 giet_tty_alloc( 0 ); 331 332 // display first prompt 330 333 prompt(); 331 334 -
soft/giet_vm/applications/sort/main.c
r515 r669 3 3 // Date : November 2013 4 4 // Author : Cesar Fuguet Tortolero <cesar.fuguet-tortolero@lip6.fr> 5 /////////////////////////////////////////////////////////////////////////////// 6 // This multi-threaded application implement a multi-stage sort application. 7 // The various stages are separated by synchronisation barriers. 8 // There is one thread per physical processors. Computation is organised as 9 // a binary tree: All threads contribute to the first stage of parallel sort 10 // but, the number of participating threads is divided by 2 at each next stage. 11 // Number_of_stages = number of barriers = log2(Number_of_threads) 5 12 // 6 // Description : 7 // 8 // Sort application using the GIET-VM OS. This application uses the 9 // barrier routines to apply a sort algorithm in several stages. 10 // 11 // Constraints : 12 // 13 // - It supports up to 1024 processors and the number of processors 14 // must be a power of 2. 15 // 16 // _ The array of values to be sorted (ARRAY_LENGTH) must be power of 2 17 // larger than the number of processors. 18 // 19 // - This application must be executed on a cache coherent architecture. 20 // 13 // Constraints : 14 // - It supports up to 1024 processors and the number of processors 15 // must be a power of 2. 16 // _ The array of values to be sorted (ARRAY_LENGTH) must be power of 2 17 // larger than the number of processors. 18 // - This application uses a private TTY terminal, shared by all threads, 19 // that is protectted by an user-level SQT lock. 21 20 /////////////////////////////////////////////////////////////////////////////// 22 21 23 22 #include "stdio.h" 24 23 #include "mapping_info.h" 25 #include "hard_config.h"26 24 #include "user_barrier.h" 25 #include "user_lock.h" 27 26 28 27 #define ARRAY_LENGTH 0x1000 29 28 #define IPT (ARRAY_LENGTH / threads) // ITEMS PER THREAD 30 29 31 //////////////////////////////////////////////////////////////////////////////// 32 // Processors other than 0 display algorithm state if VERBOSE non zero 33 34 #define VERBOSE 1 35 36 //////////////////////////////////////////////////////////////////////////////// 37 // Define printf according to verbosity option and number of available TTY 38 39 #if (VERBOSE == 1) 40 # define printf(...) giet_shr_printf(__VA_ARGS__) 41 #else 42 # define printf(...) 43 #endif 44 45 #define task0_printf(...) if(thread_id == 0) giet_shr_printf(__VA_ARGS__) 46 47 int array0[ARRAY_LENGTH]; 48 int array1[ARRAY_LENGTH]; 49 50 volatile int init_ok = 0; 30 // macro to use a shared TTY 31 #define printf(...) lock_acquire( &tty_lock ); \ 32 giet_tty_printf(__VA_ARGS__); \ 33 lock_release( &tty_lock ) 34 35 int array0[ARRAY_LENGTH]; 36 int array1[ARRAY_LENGTH]; 37 38 volatile int init_ok = 0; 39 giet_barrier_t barrier[10]; 40 user_lock_t tty_lock; 51 41 52 42 void bubbleSort( … … 63 53 int init_pos_result); 64 54 65 ///////////////////////////////////////////////////////66 // This application supports at most 1024 processors67 // Number of barriers = log2(threads)68 69 giet_barrier_t barrier[10];70 71 55 ////////////////////////////////////////// 72 __attribute__ ((constructor)) void sort() 56 __attribute__ ((constructor)) void main() 57 ////////////////////////////////////////// 73 58 { 74 int thread_id = giet_thread_id();75 59 int * src_array = NULL; 76 60 int * dst_array = NULL; 77 61 int i; 78 79 unsigned int time_start = giet_proctime();80 unsigned int time_end;81 82 // compute number of threads (one thread per proc)83 62 unsigned int x_size; 84 63 unsigned int y_size; … … 86 65 unsigned int threads; 87 66 67 // each thread gets its thread_id 68 int thread_id = giet_thread_id(); 69 70 unsigned int time_start = giet_proctime(); 71 unsigned int time_end; 72 73 // each thread compute number of threads (one thread per proc) 88 74 giet_procs_number( &x_size , &y_size , &nprocs ); 89 75 threads = x_size * y_size * nprocs; 90 76 77 // thread 0 makes TTY and barrier initialisations 78 // other threads wait initialisation completion. 79 if ( thread_id == 0 ) 80 { 81 // request a shared TTY used by all threads 82 giet_tty_alloc(1); 83 84 // TTY lock initialisation 85 lock_init( &tty_lock ); 86 87 printf("\n[ SORT T0 ] Starting sort application with %d threads " 88 "at cycle %d\n", threads, time_start); 89 90 // Barriers Initialization 91 for (i = 0; i < __builtin_ctz( threads ); i++) 92 { 93 barrier_init( &barrier[i], threads >> i ); 94 } 95 96 init_ok = 1; 97 } 98 else 99 { 100 while( !init_ok ); 101 } 102 103 // each thread checks number of tasks 91 104 if ( (threads != 1) && (threads != 2) && (threads != 4) && 92 105 (threads != 8) && (threads != 16 ) && (threads != 32) && … … 94 107 (threads != 512) && (threads != 1024) ) 95 108 { 96 task0_printf("[SORT ERROR] Number of processors must be power of 2\n" 97 " x_size = %d / y_size = %d / nprocs = %d\n", 98 x_size , y_size , nprocs ); 99 giet_exit("error"); 100 } 101 102 task0_printf("\n[ Thread 0 ] Starting sort application with %d threads " 103 "at cycle %d\n", threads, time_start); 104 105 /////////////////////////// 106 // Barriers Initialization 107 108 if (thread_id == 0) 109 { 110 for (i = 0; i < __builtin_ctz( threads ); i++) 111 { 112 barrier_init(&barrier[i], threads >> i); 113 } 114 115 init_ok = 1; 116 } 117 else 118 { 119 while(!init_ok); 120 } 121 122 //////////////////////// 123 // Array Initialization 124 109 giet_exit("error : number of processors must be power of 2"); 110 } 111 112 113 // Each thread contribute to Array Initialization 125 114 for (i = IPT * thread_id; i < IPT * (thread_id + 1); i++) 126 115 { … … 128 117 } 129 118 130 /////////////////////////////////// 131 // Parallel sort of array elements 132 133 printf("[ Thread %d ] Stage 0: Sorting...\n\r", thread_id); 119 // all threads contribute to the first stage of parallel sort 120 printf("[ SORT T%d ] Stage 0: Sorting...\n\r", thread_id); 134 121 135 122 bubbleSort(array0, IPT, IPT * thread_id); 136 123 137 printf("[ Thread %d ] Finishing Stage 0\n\r", thread_id); 138 124 printf("[ SORT T%d ] Finishing Stage 0\n\r", thread_id); 125 126 // the number of threads is divided by 2 at each next stage 139 127 for (i = 0; i < __builtin_ctz( threads ); i++) 140 128 { 141 barrier_wait( &barrier[i]);129 barrier_wait( &barrier[i] ); 142 130 143 131 if((thread_id % (2 << i)) != 0) 144 132 { 145 printf("[ Thread%d ] Quit\n\r", thread_id );133 printf("[ SORT T%d ] Quit\n\r", thread_id ); 146 134 giet_exit("Completed"); 147 135 } 148 136 149 printf("[ Thread%d ] Stage %d: Sorting...\n\r", thread_id, i+1);137 printf("[ SORT T%d ] Stage %d: Sorting...\n\r", thread_id, i+1); 150 138 151 139 if((i % 2) == 0) … … 167 155 ); 168 156 169 printf("[ Thread%d ] Finishing Stage %d\n\r", thread_id, i + 1);157 printf("[ SORT T%d ] Finishing Stage %d\n\r", thread_id, i + 1); 170 158 } 171 159 … … 173 161 int failure_index; 174 162 175 //////////////////////////////176 163 // Verify the resulting array 177 178 164 if(thread_id != 0) 179 165 { … … 186 172 if(dst_array[i] > dst_array[i+1]) 187 173 { 188 189 174 success = 0; 190 175 failure_index = i; … … 195 180 time_end = giet_proctime(); 196 181 197 printf("[ Thread0 ] Finishing sort application at cycle %d\n"198 "[ Thread0 ] Time elapsed = %d\n",182 printf("[ SORT T0 ] Finishing sort application at cycle %d\n" 183 "[ SORT T0 ] Time elapsed = %d\n", 199 184 time_end, (time_end - time_start) ); 200 185 … … 205 190 else 206 191 { 207 printf("[ Thread0 ] Failure!! Incorrect element: %d\n\r",192 printf("[ SORT T0 ] Failure!! Incorrect element: %d\n\r", 208 193 failure_index); 209 194 for(i=0; i<ARRAY_LENGTH; i++) -
soft/giet_vm/applications/sort/sort.py
r610 r669 45 45 46 46 # create Vspace 47 vspace = mapping.addVspace( name = 'sort', startname = 'sort_data' )47 vspace = mapping.addVspace( name = 'sort', startname = 'sort_data', active = False ) 48 48 49 49 # data vseg : non local (only in cluster[0,0]) -
soft/giet_vm/applications/transpose/main.c
r661 r669 33 33 #define CLUSTER_MAX (X_MAX * Y_MAX) // max number of clusters 34 34 #define NN 256 // image size : nlines = npixels 35 #define INITIAL_FILE_PATH " misc/lena.raw"// pathname on virtual disk35 #define INITIAL_FILE_PATH "/misc/lena_256.raw" // pathname on virtual disk 36 36 #define TRANSPOSED_FILE_PATH "/home/lena_transposed.raw" // pathname on virtual disk 37 37 #define RESTORED_FILE_PATH "/home/lena_restored.raw" // pathname on virtual disk 38 38 #define INSTRUMENTATION_OK 1 // display statistics on TTY 39 40 // macro to use a shared TTY 41 #define printf(...) lock_acquire( &tty_lock ); \ 42 giet_tty_printf(__VA_ARGS__); \ 43 lock_release( &tty_lock ) 39 44 40 45 /////////////////////////////////////////////////////// … … 61 66 unsigned check_line_after[NN]; 62 67 63 // global synchronisation barrier 68 // lock protecting shared TTY 69 user_lock_t tty_lock; 70 71 // global & local synchronisation variables 64 72 giet_sqt_barrier_t barrier; 65 73 … … 98 106 unsigned int task_id = (cluster_id * nprocs) + lpid; // "continuous" task index 99 107 108 // checking parameters 109 giet_assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)), 110 "[TRANSPOSE ERROR] number of procs per cluster must be 1, 2 or 4"); 111 112 giet_assert( ((x_size == 1) || (x_size == 2) || (x_size == 4) || 113 (x_size == 8) || (x_size == 16)), 114 "[TRANSPOSE ERROR] x_size must be 1,2,4,8,16"); 115 116 giet_assert( ((y_size == 1) || (y_size == 2) || (y_size == 4) || 117 (y_size == 8) || (y_size == 16)), 118 "[TRANSPOSE ERROR] y_size must be 1,2,4,8,16"); 119 120 giet_assert( (ntasks <= NN ), 121 "[TRANSPOSE ERROR] number of tasks larger than number of lines"); 100 122 101 123 /////////////////////////////////////////////////////////////////////// … … 107 129 if ( (x==0) && (y==0) && (lpid==0) ) 108 130 { 109 if ((nprocs != 1) && (nprocs != 2) && (nprocs != 4)) 110 { 111 giet_exit("[TRANSPOSE ERROR] number of procs per cluster must be 1, 2 or 4"); 112 } 113 if ((nclusters != 1) && (nclusters != 2) && (nclusters != 4) && 114 (nclusters != 8) && (nclusters != 16) && (nclusters != 32) && (nclusters != 64) ) 115 { 116 giet_exit("[TRANSPOSE ERROR] number of clusters must be 1,2,4,8,16,32,64"); 117 } 118 if ( ntasks > NN ) 119 { 120 giet_exit("[TRANSPOSE ERROR] number of tasks larger than number of lines"); 121 } 122 131 // shared TTY allocation 132 giet_tty_alloc( 1 ); 133 134 // TTY lock initialisation 135 lock_init( &tty_lock); 136 123 137 // distributed heap initialisation 124 138 unsigned int cx , cy; … … 134 148 sqt_barrier_init( &barrier, x_size , y_size , nprocs ); 135 149 136 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] completes heap & barrier initat cycle %d\n",137 150 printf("\n[TRANSPOSE] Proc [0,0,0] completes initialisation at cycle %d\n", 151 giet_proctime() ); 138 152 139 153 global_init_ok = 1; … … 157 171 158 172 if ( (x==0) && (y==0) ) 159 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes buffer allocation"160 161 162 163 164 173 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes buffer allocation" 174 " for cluster[%d,%d] at cycle %d\n" 175 " - buf_in = %x\n" 176 " - buf_out = %x\n", 177 x, y, lpid, x, y, giet_proctime(), 178 (unsigned int)buf_in[cluster_id], (unsigned int)buf_out[cluster_id] ); 165 179 166 180 /////////////////////////////////////////////////////////////////////// … … 173 187 if ( fd_initial < 0 ) 174 188 { 175 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n",176 189 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 190 x , y , lpid , INITIAL_FILE_PATH ); 177 191 giet_exit(" open() failure"); 178 192 } 179 193 else if ( (x==0) && (y==0) && (lpid==0) ) 180 194 { 181 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n",182 195 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 196 INITIAL_FILE_PATH , fd_initial ); 183 197 } 184 198 … … 187 201 if ( fd_transposed < 0 ) 188 202 { 189 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n",203 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 190 204 x , y , lpid , TRANSPOSED_FILE_PATH ); 191 205 giet_exit(" open() failure"); … … 193 207 else if ( (x==0) && (y==0) && (lpid==0) ) 194 208 { 195 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n",196 209 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 210 TRANSPOSED_FILE_PATH , fd_transposed ); 197 211 } 198 212 … … 201 215 if ( fd_restored < 0 ) 202 216 { 203 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n",204 217 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 218 x , y , lpid , RESTORED_FILE_PATH ); 205 219 giet_exit(" open() failure"); 206 220 } 207 221 else if ( (x==0) && (y==0) && (lpid==0) ) 208 222 { 209 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n",210 223 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 224 RESTORED_FILE_PATH , fd_restored ); 211 225 } 212 226 … … 244 258 SEEK_SET ) != offset ) 245 259 { 246 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fd = %d\n",247 260 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fd = %d\n", 261 x , y , lpid , fd_in ); 248 262 giet_exit(" seek() failure"); 249 263 } … … 254 268 pixels ) != pixels ) 255 269 { 256 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot read fd = %d\n",257 270 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot read fd = %d\n", 271 x , y , lpid , fd_in ); 258 272 giet_exit(" read() failure"); 259 273 } 260 274 261 275 if ( (x==0) && (y==0) ) 262 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes load"263 264 276 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes load" 277 " for iteration %d at cycle %d\n", 278 x, y, lpid, iteration, giet_proctime() ); 265 279 } 266 280 … … 314 328 } 315 329 316 if ( lpid == 0 )317 { 318 if ( (x==0) && (y==0) )319 giet_shr_printf("\n[TRANSPOSE] proc [%d,%d,0] completes transpose"320 321 330 // if ( lpid == 0 ) 331 { 332 // if ( (x==0) && (y==0) ) 333 printf("\n[TRANSPOSE] proc [%d,%d,0] completes transpose" 334 " for iteration %d at cycle %d\n", 335 x, y, iteration, giet_proctime() ); 322 336 323 337 } … … 340 354 npt ); 341 355 342 if ( (x==0) && (y==0) && (lpid==0) )343 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes display"344 345 356 // if ( (x==0) && (y==0) && (lpid==0) ) 357 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes display" 358 " for iteration %d at cycle %d\n", 359 x, y, lpid, iteration, giet_proctime() ); 346 360 347 361 DISP_END[x][y][lpid] = giet_proctime(); … … 364 378 SEEK_SET ) != offset ) 365 379 { 366 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fr = %d\n",367 380 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fr = %d\n", 381 x , y , lpid , fd_out ); 368 382 giet_exit(" seek() failure"); 369 383 } … … 374 388 pixels ) != pixels ) 375 389 { 376 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot write fd = %d\n",377 390 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot write fd = %d\n", 391 x , y , lpid , fd_out ); 378 392 giet_exit(" write() failure"); 379 393 } 380 394 381 395 if ( (x==0) && (y==0) ) 382 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes store"383 384 396 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes store" 397 " for iteration %d at cycle %d\n", 398 x, y, lpid, iteration, giet_proctime() ); 385 399 } 386 400 … … 437 451 } 438 452 439 giet_shr_printf("\n ---------------- Instrumentation Results ---------------------\n");440 441 giet_shr_printf(" - LOAD_START : min = %d / max = %d / med = %d / delta = %d\n",442 443 444 445 giet_shr_printf(" - LOAD_END : min = %d / max = %d / med = %d / delta = %d\n",446 447 448 449 giet_shr_printf(" - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n",450 451 452 453 giet_shr_printf(" - TRSP_END : min = %d / max = %d / med = %d / delta = %d\n",454 455 456 457 giet_shr_printf(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n",458 459 460 461 giet_shr_printf(" - DISP_END : min = %d / max = %d / med = %d / delta = %d\n",462 463 464 465 giet_shr_printf(" - STOR_START : min = %d / max = %d / med = %d / delta = %d\n",466 467 468 469 giet_shr_printf(" - STOR_END : min = %d / max = %d / med = %d / delta = %d\n",470 471 453 printf("\n ---------------- Instrumentation Results ---------------------\n"); 454 455 printf(" - LOAD_START : min = %d / max = %d / med = %d / delta = %d\n", 456 min_load_start, max_load_start, (min_load_start+max_load_start)/2, 457 max_load_start-min_load_start); 458 459 printf(" - LOAD_END : min = %d / max = %d / med = %d / delta = %d\n", 460 min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2, 461 max_load_ended-min_load_ended); 462 463 printf(" - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n", 464 min_trsp_start, max_trsp_start, (min_trsp_start+max_trsp_start)/2, 465 max_trsp_start-min_trsp_start); 466 467 printf(" - TRSP_END : min = %d / max = %d / med = %d / delta = %d\n", 468 min_trsp_ended, max_trsp_ended, (min_trsp_ended+max_trsp_ended)/2, 469 max_trsp_ended-min_trsp_ended); 470 471 printf(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n", 472 min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2, 473 max_disp_start-min_disp_start); 474 475 printf(" - DISP_END : min = %d / max = %d / med = %d / delta = %d\n", 476 min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2, 477 max_disp_ended-min_disp_ended); 478 479 printf(" - STOR_START : min = %d / max = %d / med = %d / delta = %d\n", 480 min_stor_start, max_stor_start, (min_stor_start+max_stor_start)/2, 481 max_stor_start-min_stor_start); 482 483 printf(" - STOR_END : min = %d / max = %d / med = %d / delta = %d\n", 484 min_stor_ended, max_stor_ended, (min_stor_ended+max_stor_ended)/2, 485 max_stor_ended-min_stor_ended); 472 486 } 473 487 … … 497 511 } 498 512 499 // clean up500 if ( (x==0) && (y == 0) && (lpid == 0) )501 {502 giet_fat_remove( "/home/lena_transposed" , 0 );503 giet_fat_remove( "/home/lena_restored" , 0 );504 505 giet_fat_remove( "/home" , 1 );506 }507 508 513 giet_exit("Completed"); 509 514 -
soft/giet_vm/applications/transpose/transpose.py
r610 r669 49 49 50 50 # create vspace 51 vspace = mapping.addVspace( name = 'transpose', startname = 'trsp_data' )51 vspace = mapping.addVspace( name = 'transpose', startname = 'trsp_data', active = False ) 52 52 53 53 # data vseg : shared (only in cluster[0,0])
Note: See TracChangeset
for help on using the changeset viewer.