Changeset 804 for soft/giet_vm/applications
- Timestamp:
- Mar 14, 2016, 3:35:05 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/transpose/transpose.c
r782 r804 92 92 int fd_out; 93 93 94 //////////////////////////////////////////// 95 __attribute__ ((constructor)) void execute( )96 //////////////////////////////////////////// 94 //////////////////////////////////////////////////////////////// 95 __attribute__ ((constructor)) void execute( unsigned int* tid ) 96 //////////////////////////////////////////////////////////////// 97 97 { 98 98 unsigned int l; // line index for loops … … 118 118 unsigned int cluster_id = (x_id * y_size) + y_id; // "continuous" index 119 119 unsigned int thread_id = (cluster_id * nprocs) + p_id; // "continuous" index 120 121 if ( VERBOSE ) 122 { 123 printf("\n@@@ thread %d / %d running on P[%d,%d,%d]\n", 124 *tid , nthreads , x_id , y_id , p_id ); 125 } 120 126 121 127 // parallel load of image: … … 146 152 if ( VERBOSE ) 147 153 { 148 printf("\n@@@ Thread[%d,%d,%d] call mmap for input file\n"154 printf("\n@@@ thread %d running on P[%d,%d,%d] call mmap for input file\n" 149 155 " length = %x / offset = %x / buf_in = %x\n", 150 x_id , y_id , p_id , length , offset , buf_in[cluster_id] );156 *tid , x_id , y_id , p_id , length , offset , buf_in[cluster_id] ); 151 157 } 152 158 … … 168 174 if ( VERBOSE ) 169 175 { 170 printf("\n@@@ Thread[%d,%d,%d] call mmap for output file\n"176 printf("\n@@@ thread %d running on P[%d,%d,%d] call mmap for output file\n" 171 177 " length = %x / offset = %x / buf_out = %x\n", 172 x_id , y_id , p_id , length , offset , buf_out[cluster_id] );178 *tid , x_id , y_id , p_id , length , offset , buf_out[cluster_id] ); 173 179 } 174 180 … … 482 488 } 483 489 484 // allocate thread[] array 490 // allocate thread[] array : thread identidiers defined by the kernel 485 491 pthread_t* thread = malloc( nthreads * sizeof(pthread_t) ); 492 493 // allocate tid[] array : continuous thred index defined by the user 494 unsigned int* tid = malloc( nthreads * sizeof(unsigned int) ); 486 495 487 496 // barrier initialisation … … 494 503 for ( n = 1 ; n < nthreads ; n++ ) 495 504 { 505 tid[n] = n; 496 506 if ( giet_pthread_create( &thread[n], 497 507 NULL, // no attribute 498 508 &execute, 499 NULL ) ) // no argument500 { 501 printf("\n[TRANSPOSE ERROR] creating thread % x\n", thread[n] );509 &tid[n] ) ) // pointer on thread index 510 { 511 printf("\n[TRANSPOSE ERROR] creating thread %d / id = %x\n", tid[n] , thread[n] ); 502 512 giet_pthread_exit( NULL ); 503 513 } … … 505 515 506 516 // run the execute() function 507 execute( );517 execute( &tid[0] ); 508 518 509 519 // wait other threads completion … … 512 522 if ( giet_pthread_join( thread[n], NULL ) ) 513 523 { 514 printf("\n[TRANSPOSE ERROR] joining thread % x\n", thread[n] );524 printf("\n[TRANSPOSE ERROR] joining thread %d / id = %x\n", tid[n] , thread[n] ); 515 525 giet_pthread_exit( NULL ); 516 526 }
Note: See TracChangeset
for help on using the changeset viewer.