Changeset 635 for trunk/user
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (6 years ago)
- Location:
- trunk/user
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/user/fft/fft.c ¶
r630 r635 87 87 // parameters 88 88 89 #define DEFAULT_M 12 // 4096 data points89 #define DEFAULT_M 8 // 256 data points 90 90 #define USE_DQT_BARRIER 0 // use DDT barrier if non zero 91 91 #define MODE COSIN // DATA array initialisation mode … … 291 291 main_tid = (((main_x * y_size) + main_y) * ncores) + main_lid; 292 292 293 printf("\n[fft] starts on core[%x,%d] / %d complex points / %d thread(s) / PID %x\n",294 main_cxy, main_lid, N, nthreads, getpid() );293 printf("\n[fft] starts / core[%x,%d] / %d points / %d thread(s) / PID %x / cycle %d\n", 294 main_cxy, main_lid, N, nthreads, getpid(), (unsigned int)start_init_cycle ); 295 295 296 296 // allocate memory for the distributed data[i], trans[i], umain[i], twid[i] buffers … … 312 312 } 313 313 314 printf("\n[fft] main completes remote_malloc\n"); 314 #if DEBUG_MAIN 315 printf("\n[fft] main completes remote_malloc\n"); 316 #endif 315 317 316 318 // arrays initialisation … … 319 321 InitT( twid ); 320 322 321 printf("\n[fft] main completes arrays init\n"); 323 #if DEBUG_MAIN 324 printf("\n[fft] main completes arrays init\n"); 325 #endif 322 326 323 327 #if CHECK … … 357 361 } 358 362 359 printf("\n[fft] main completes barrier init\n"); 363 #if DEBUG_MAIN 364 printf("\n[fft] main completes barrier init\n"); 365 #endif 360 366 361 367 // launch other threads to execute the slave() function … … 393 399 exit( 0 ); 394 400 } 401 395 402 #if (DEBUG_MAIN & 1) 396 403 unsigned long long debug_cycle; … … 404 411 } 405 412 406 printf("\n[fft] main completes threads creation\n"); 413 #if DEBUG_MAIN 414 printf("\n[fft] main completes threads creation\n"); 415 #endif 407 416 408 417 get_cycle( &end_init_cycle ); -
TabularUnified trunk/user/init/init.c ¶
r625 r635 105 105 { 106 106 cxy = HAL_CXY_FROM_XY( x , y ); 107 display_cluster_processes( cxy );107 display_cluster_processes( cxy , 0 ); 108 108 for( lid = 0 ; lid < ncores ; lid++ ) 109 109 { -
TabularUnified trunk/user/ksh/ksh.c ¶
r633 r635 108 108 char pathnew[PATH_MAX_SIZE]; // used by the rename command 109 109 110 char string[128]; // used by snprintf() for debug 111 110 112 ////////////////////////////////////////////////////////////////////////////////////////// 111 113 // Shell Commands … … 121 123 122 124 #if DEBUG_CMD_CAT 123 char string[64]; 125 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__); 126 display_string( string ); 124 127 #endif 125 128 … … 133 136 134 137 strcpy( pathname , argv[1] ); 138 139 #if DEBUG_CMD_CAT 140 snprintf( string , 128 , "[ksh] in %s : after strcpy" , __FUNCTION__ ); 141 display_string( string ); 142 #endif 135 143 136 144 // open the file … … 145 153 146 154 #if DEBUG_CMD_CAT 147 snprintf( string , 64, "[ksh] %s : file %s open", __FUNCTION__, pathname );155 snprintf( string , 128 , "[ksh] %s : file %s open", __FUNCTION__, pathname ); 148 156 display_string( string ); 149 157 #endif … … 172 180 173 181 #if DEBUG_CMD_CAT 174 snprintf( string , 64, "[ksh] %s : size = %d", __FUNCTION__, size );182 snprintf( string , 128 , "[ksh] %s : size = %d", __FUNCTION__, size ); 175 183 display_string( string ); 176 184 #endif … … 198 206 199 207 #if DEBUG_CMD_CAT 200 snprintf( string , 64, "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf );208 snprintf( string , 128 , "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf ); 201 209 display_string( string ); 202 210 #endif … … 212 220 213 221 #if DEBUG_CMD_CAT 214 snprintf( string , 64, "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf );222 snprintf( string , 128 , "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf ); 215 223 display_string( string ); 216 224 #endif … … 261 269 262 270 #if DEBUG_CMD_CP 263 char string[64]; 271 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__); 272 display_string( string ); 264 273 #endif 265 274 … … 284 293 285 294 #if DEBUG_CMD_CP 286 snprintf( string , 64, "[ksh] %s : file %s open", __FUNCTION__, argv[1] );295 snprintf( string , 128 , "[ksh] %s : file %s open", __FUNCTION__, argv[1] ); 287 296 display_string( string ); 288 297 #endif … … 297 306 298 307 #if DEBUG_CMD_CP 299 snprintf( string , 64, "[ksh] %s : got stats for %s", __FUNCTION__, argv[1] );308 snprintf( string , 128 , "[ksh] %s : got stats for %s", __FUNCTION__, argv[1] ); 300 309 display_string( string ); 301 310 #endif … … 322 331 323 332 #if DEBUG_CMD_CP 324 snprintf( string , 64, "[ksh] %s : file %s open", __FUNCTION__, argv[2] );333 snprintf( string , 128 , "[ksh] %s : file %s open", __FUNCTION__, argv[2] ); 325 334 display_string( string ); 326 335 #endif … … 333 342 334 343 #if DEBUG_CMD_CP 335 snprintf( string , 64, "[ksh] %s : got stats for %s", __FUNCTION__, argv[2] );344 snprintf( string , 128 , "[ksh] %s : got stats for %s", __FUNCTION__, argv[2] ); 336 345 display_string( string ); 337 346 #endif … … 357 366 358 367 #if DEBUG_CMD_CP 359 snprintf( string , 64, "[ksh] %s : read %d bytes from %s", __FUNCTION__, len, argv[1] );368 snprintf( string , 128 , "[ksh] %s : read %d bytes from %s", __FUNCTION__, len, argv[1] ); 360 369 display_string( string ); 361 370 #endif … … 369 378 370 379 #if DEBUG_CMD_CP 371 snprintf( string , 64, "[ksh] %s : write %d bytes to %s", __FUNCTION__, len, argv[2] );380 snprintf( string , 128 , "[ksh] %s : write %d bytes to %s", __FUNCTION__, len, argv[2] ); 372 381 display_string( string ); 373 382 #endif … … 682 691 683 692 #if DEBUG_CMD_LOAD 684 char string[64]; 693 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__); 694 display_string( string ); 685 695 #endif 686 696 … … 725 735 726 736 #if DEBUG_CMD_LOAD 727 snprintf( string , 64 , "[ksh] %s : ksh_pid %x / path %s / bg %d / place %d (%x)\n",728 __FUNCTION__, ksh_pid,argv[1], background, placement, cxy );737 snprintf( string , 128 , "[ksh] %s : <%s> / bg %d / place %d / cxy %x", 738 __FUNCTION__, argv[1], background, placement, cxy ); 729 739 display_string( string ); 730 740 #endif … … 744 754 745 755 #if DEBUG_CMD_LOAD 746 snprintf( string , 64 , "[ksh] %s : child_pid %x after fork, before exec\n",756 snprintf( string , 128 , "[ksh] %s : child (%x) after fork, before exec", 747 757 __FUNCTION__ , getpid() ); 748 758 display_string( string ); … … 753 763 754 764 #if DEBUG_CMD_LOAD 755 snprintf( string , 64 , "[ksh] %s : child_pid %x after exec / ret_exec %x\n",765 snprintf( string , 128 , "[ksh] %s : child (%x) after exec / ret_exec %x", 756 766 __FUNCTION__ , getpid(), ret_exec ); 757 767 display_string( string ); … … 769 779 770 780 #if DEBUG_CMD_LOAD 771 snprintf( string , 64 , "[ksh] %s : ksh_pid %x after fork / ret_fork %x\n",781 snprintf( string , 128 , "[ksh] %s : ksh (%x) after fork / ret_fork %x", 772 782 __FUNCTION__, getpid(), ret_fork ); 773 783 display_string( string ); … … 821 831 822 832 #if DEBUG_CMD_LS 823 char string[64]; 833 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__); 834 display_string( string ); 824 835 #endif 825 836 … … 840 851 841 852 #if DEBUG_CMD_LS 842 snprintf( string , 64, "[ksh] %s : directory <%s> open / DIR %x\n",853 snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x\n", 843 854 __FUNCTION__, pathname , dir ); 844 855 display_string( string ); … … 863 874 864 875 #if DEBUG_CMD_LS 865 snprintf( string , 64, "[ksh] %s : directory <%s> closed\n",876 snprintf( string , 128 , "[ksh] %s : directory <%s> closed\n", 866 877 __FUNCTION__, pathname ); 867 878 display_string( string ); … … 929 940 930 941 #if DEBUG_CMD_PS 931 char string[64]; 942 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__); 943 display_string( string ); 932 944 #endif 933 945 … … 948 960 949 961 #if DEBUG_CMD_PS 950 snprintf( string , 64, "\n[ksh] %s : call display_cluster_process()", __FUNCTION__ );962 snprintf( string , 128 , "\n[ksh] %s : call display_cluster_process()", __FUNCTION__ ); 951 963 display_string( string ); 952 964 #endif … … 1106 1118 1107 1119 #if DEBUG_EXECUTE 1108 printf("\n[ksh] %s : command <%s>\n", 1109 __FUNCTION__ , buf);1120 snprintf( string , 128 , "[ksh] enter %s for command <%s>" , __FUNCTION__ , buf ); 1121 display_string( string ); 1110 1122 #endif 1111 1123 … … 1136 1148 1137 1149 #if DEBUG_EXECUTE 1138 printf("\n[ksh] %s : argc %d / arg0 %s / arg1%s\n",1150 snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s\n", 1139 1151 __FUNCTION__ , argc , argv[0], argv[1] ); 1140 1152 #endif … … 1174 1186 char cmd[CMD_MAX_SIZE]; // buffer for one command 1175 1187 1176 #if DEBUG_INTER 1177 char string[128]; 1178 #endif 1179 1180 1181 // 1. first direct command 1188 /* 1. first direct command 1182 1189 if( sem_wait( &semaphore ) ) 1183 1190 { … … 1187 1194 else 1188 1195 { 1189 printf("\n[ksh] load bin/user/ fft.elf\n");1196 printf("\n[ksh] load bin/user/sort.elf\n"); 1190 1197 } 1191 1198 1192 strcpy( cmd , "load bin/user/ fft.elf" );1199 strcpy( cmd , "load bin/user/sort.elf" ); 1193 1200 execute( cmd ); 1194 //1201 */ 1195 1202 1196 1203 … … 1204 1211 else 1205 1212 { 1206 printf("\n[ksh] rm home/fft_1_2_1_4096\n");1213 printf("\n[ksh] load bin/user/fft.elf\n"); 1207 1214 } 1208 1215 1209 strcpy( cmd , " rm home/fft_1_2_1_4096" );1216 strcpy( cmd , "load bin/user/fft.elf" ); 1210 1217 execute( cmd ); 1211 1218 */ … … 1252 1259 #if DEBUG_INTER 1253 1260 unsigned int pid = getpid(); 1254 snprintf( string , 128 , " \n[ksh] %s : request a new command", __FUNCTION__ );1261 snprintf( string , 128 , "[ksh] %s : request a new command", __FUNCTION__ ); 1255 1262 display_string( string ); 1256 1263 #endif … … 1282 1289 count++; 1283 1290 #if DEBUG_INTER 1284 snprintf( string , 128 , "[ksh] %s : get command <%s> / &log = %x / ptw = %d / &ptw = %x", 1285 __FUNCTION__, cmd , log_entries[ptw].buf , ptw , &ptw ); 1291 snprintf( string , 128 , "[ksh] %s : get command <%s>", __FUNCTION__, cmd ); 1286 1292 display_string( string ); 1287 1293 display_vmm( 0 , 2 ); … … 1452 1458 1453 1459 #if DEBUG_MAIN 1454 printf("\n[ksh] main thread started on core[%x,%d]\n", cxy , lid ); 1460 snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d]\n", cxy , lid ); 1461 display_string( string ); 1455 1462 #endif 1456 1463 … … 1463 1470 1464 1471 #if DEBUG_MAIN 1465 printf("\n[ksh] main initialized semaphore\n" ); 1472 snprintf( string , 128 , "\n[ksh] main initialized semaphore\n" ); 1473 display_string( string ); 1466 1474 #endif 1467 1475 … … 1476 1484 NULL ); 1477 1485 #if DEBUG_MAIN 1478 printf("\n[ksh] main thread launched interactive thread %x\n", trdid ); 1486 snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x\n", trdid ); 1487 display_string( string ); 1479 1488 #endif 1480 1489 -
TabularUnified trunk/user/sort/sort.c ¶
r629 r635 1 /* 2 * sort.c - Parallel sort 3 * 4 * Author Cesar Fuguet Tortolero (2013) 5 * Alain Greiner (2019) 6 * 7 * Copyright (c) UPMC Sorbonne Universites 8 * 9 * This is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; version 2.0 of the License. 12 * 13 * It is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 1 23 /////////////////////////////////////////////////////////////////////////////// 2 // File : sort.c 3 // Date : November 2013 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. 24 // This multi-threaded application implement a multi-stage sort. 25 // It has been writen by Cesar Fuget Tortolero in 2013. 26 // It has been ported on ALMOS-MKH by Alain Greiner in 2019. 27 // 8 28 // There is one thread per physical cores. 9 29 // Computation is organised as a binary tree: … … 15 35 // Number_of_stages = number of barriers = log2(Number_of_threads) 16 36 // 37 // The various stages are separated by synchronisation barriers, and the 38 // main thread uses the join syscall to check that all threads completed 39 // before printing the computation time (sequencial & parallel). 40 // These results can be - optionnaly - registered in an instrumentation file. 41 // 17 42 // Constraints : 18 43 // - It supports up to 1024 cores: x_size, y_size, and ncores must be … … 29 54 #include <hal_macros.h> 30 55 31 #define ARRAY_LENGTH 4096// number of items56 #define ARRAY_LENGTH 128 // number of items 32 57 #define MAX_THREADS 1024 // 16 * 16 * 4 33 58 34 59 #define USE_DQT_BARRIER 1 // use DQT barrier if non zero 35 60 #define DISPLAY_ARRAY 0 // display items values before and after 36 #define DEBUG_MAIN 1 // trace main function 37 #define DEBUG_SORT 1 // trace sort function 38 #define INTERACTIVE_MODE 0 // activate idbg() during instrumentation 61 #define DEBUG_MAIN 0 // trace main function 62 #define DEBUG_SORT 0 // trace sort function 39 63 #define CHECK_RESULT 0 // for debug 40 64 #define INSTRUMENTATION 1 // register computation times on file 41 #define IDBG 0 // activate interactive debug in main42 65 43 66 ///////////////////////////////////////////////////////////// … … 62 85 pthread_barrier_t barrier; // synchronisation variables 63 86 64 pthread_attr_t attr[MAX_THREADS]; // thread attributes (one per thread) 65 args_t arg[MAX_THREADS]; // sort function arguments (one per thread) 87 pthread_t trdid[MAX_THREADS]; // kernel identifiers 88 pthread_attr_t attr[MAX_THREADS]; // thread attributes 89 args_t arg[MAX_THREADS]; // sort function arguments 66 90 67 91 //////////////////////////////////// … … 277 301 unsigned int lid; // core local index for a thread 278 302 unsigned int n; // index in array to sort 279 pthread_t trdid; // kernel allocated thread index (unused)280 303 pthread_barrierattr_t barrier_attr; // barrier attributes 281 304 … … 353 376 // launch other threads to execute sort() function 354 377 // on cores other than the core running the main thread 355 for ( x =0 ; x<x_size ; x++ )356 { 357 for ( y =0 ; y<y_size ; y++ )358 { 359 for ( lid =0 ; lid<ncores ; lid++ )378 for ( x = 0 ; x < x_size ; x++ ) 379 { 380 for ( y = 0 ; y < y_size ; y++ ) 381 { 382 for ( lid = 0 ; lid < ncores ; lid++ ) 360 383 { 384 // compute thread user index (continuous index) 361 385 thread_uid = (((x * y_size) + y) * ncores) + lid; 362 386 363 // set sortarguments for all threads387 // set arguments for all threads 364 388 arg[thread_uid].threads = total_threads; 365 389 arg[thread_uid].thread_uid = thread_uid; … … 367 391 368 392 // set thread attributes for all threads 369 attr[thread_uid].attributes = PT_ATTR_DETACH | 370 PT_ATTR_CLUSTER_DEFINED | 371 PT_ATTR_CORE_DEFINED; 393 attr[thread_uid].attributes = PT_ATTR_CLUSTER_DEFINED | PT_ATTR_CORE_DEFINED; 372 394 attr[thread_uid].cxy = HAL_CXY_FROM_XY( x , y ); 373 395 attr[thread_uid].lid = lid; … … 375 397 if( thread_uid != main_uid ) 376 398 { 377 if ( pthread_create( &trdid , // not used because no join399 if ( pthread_create( &trdid[thread_uid], // buffer for kernel identifier 378 400 &attr[thread_uid], // thread attributes 379 401 &sort, // entry function … … 383 405 exit( 0 ); 384 406 } 385 else 386 { 387 #if DEBUG_MAIN 407 408 #if (DEBUG_MAIN & 1) 388 409 printf("\n[sort] main created thread %x \n", thread_uid ); 389 410 #endif 390 }391 411 } 392 412 } … … 402 422 #endif 403 423 404 #if INTERACTIVE_MODE405 idbg();406 #endif407 408 424 // the main thread run also the sort() function 409 425 sort( &arg[main_uid] ); 410 426 427 // wait other threads completion 428 for ( x = 0 ; x < x_size ; x++ ) 429 { 430 for ( y = 0 ; y < y_size ; y++ ) 431 { 432 for ( lid = 0 ; lid < ncores ; lid++ ) 433 { 434 // compute thread continuous index 435 thread_uid = (((x * y_size) + y) * ncores) + lid; 436 437 if( thread_uid != main_uid ) 438 { 439 if( pthread_join( trdid[thread_uid] , NULL ) ) 440 { 441 printf("\n[fft error] in main thread %d joining thread %d\n", 442 main_uid , thread_uid ); 443 exit( 0 ); 444 } 445 446 #if (DEBUG_MAIN & 1) 447 printf("\n[fft] main thread %d joined thread %d\n", main_uid, thread_uid ); 448 #endif 449 450 } 451 } 452 } 453 } 454 411 455 //////////////////////////// 412 456 get_cycle( ¶_end_cycle ); … … 417 461 // destroy barrier 418 462 pthread_barrier_destroy( &barrier ); 419 420 #if INTERACTIVE_MODE421 idbg();422 #endif423 463 424 464 #if CHECK_RESULT
Note: See TracChangeset
for help on using the changeset viewer.