Changeset 635 for trunk/user


Ignore:
Timestamp:
Jun 26, 2019, 11:42:37 AM (5 years ago)
Author:
alain
Message:

This version is a major evolution: The physical memory allocators,
defined in the kmem.c, ppm.c, and kcm.c files have been modified
to support remote accesses. The RPCs that were previously user
to allocate physical memory in a remote cluster have been removed.
This has been done to cure a dead-lock in case of concurrent page-faults.

This version 2.2 has been tested on a (4 clusters / 2 cores per cluster)
TSAR architecture, for both the "sort" and the "fft" applications.

Location:
trunk/user
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/user/fft/fft.c

    r630 r635  
    8787// parameters
    8888
    89 #define DEFAULT_M               12              // 4096 data points
     89#define DEFAULT_M               8               // 256 data points
    9090#define USE_DQT_BARRIER         0               // use DDT barrier if non zero
    9191#define MODE                    COSIN           // DATA array initialisation mode
     
    291291    main_tid = (((main_x * y_size) + main_y) * ncores) + main_lid;
    292292
    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 );
    295295
    296296    // allocate memory for the distributed data[i], trans[i], umain[i], twid[i] buffers
     
    312312    }
    313313
    314     printf("\n[fft] main completes remote_malloc\n");
     314#if DEBUG_MAIN
     315printf("\n[fft] main completes remote_malloc\n");
     316#endif
    315317
    316318    // arrays initialisation
     
    319321    InitT( twid );
    320322
    321     printf("\n[fft] main completes arrays init\n");
     323#if DEBUG_MAIN
     324printf("\n[fft] main completes arrays init\n");
     325#endif
    322326
    323327#if CHECK
     
    357361    }
    358362
    359     printf("\n[fft] main completes barrier init\n");
     363#if DEBUG_MAIN
     364printf("\n[fft] main completes barrier init\n");
     365#endif
    360366
    361367    // launch other threads to execute the slave() function
     
    393399                        exit( 0 );
    394400                    }
     401
    395402#if (DEBUG_MAIN & 1)
    396403unsigned long long debug_cycle;
     
    404411    }
    405412
    406     printf("\n[fft] main completes threads creation\n");
     413#if DEBUG_MAIN
     414printf("\n[fft] main completes threads creation\n");
     415#endif
    407416
    408417    get_cycle( &end_init_cycle );
  • trunk/user/init/init.c

    r625 r635  
    105105        {
    106106            cxy = HAL_CXY_FROM_XY( x , y );
    107             display_cluster_processes( cxy );
     107            display_cluster_processes( cxy , 0 );
    108108            for( lid = 0 ; lid < ncores ; lid++ )
    109109            {
  • trunk/user/ksh/ksh.c

    r633 r635  
    108108char            pathnew[PATH_MAX_SIZE];     // used by the rename command
    109109 
     110char            string[128];                // used by snprintf() for debug
     111
    110112//////////////////////////////////////////////////////////////////////////////////////////
    111113//         Shell  Commands
     
    121123
    122124#if DEBUG_CMD_CAT
    123 char string[64];
     125snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);
     126display_string( string );
    124127#endif
    125128
     
    133136
    134137    strcpy( pathname , argv[1] );
     138
     139#if DEBUG_CMD_CAT
     140snprintf( string , 128 , "[ksh] in %s : after strcpy" , __FUNCTION__ );
     141display_string( string );
     142#endif
    135143
    136144    // open the file
     
    145153
    146154#if DEBUG_CMD_CAT
    147 snprintf( string , 64 , "[ksh] %s : file %s open", __FUNCTION__, pathname );
     155snprintf( string , 128 , "[ksh] %s : file %s open", __FUNCTION__, pathname );
    148156display_string( string );
    149157#endif
     
    172180
    173181#if DEBUG_CMD_CAT
    174 snprintf( string , 64 , "[ksh] %s : size = %d", __FUNCTION__, size );
     182snprintf( string , 128 , "[ksh] %s : size = %d", __FUNCTION__, size );
    175183display_string( string );
    176184#endif
     
    198206
    199207#if DEBUG_CMD_CAT
    200 snprintf( string , 64 , "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf );
     208snprintf( string , 128 , "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf );
    201209display_string( string );
    202210#endif
     
    212220
    213221#if DEBUG_CMD_CAT
    214 snprintf( string , 64 , "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf );
     222snprintf( string , 128 , "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf );
    215223display_string( string );
    216224#endif
     
    261269
    262270#if DEBUG_CMD_CP
    263 char string[64];
     271snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);
     272display_string( string );
    264273#endif
    265274
     
    284293
    285294#if DEBUG_CMD_CP
    286 snprintf( string , 64 , "[ksh] %s : file %s open", __FUNCTION__, argv[1] );
     295snprintf( string , 128 , "[ksh] %s : file %s open", __FUNCTION__, argv[1] );
    287296display_string( string );
    288297#endif
     
    297306
    298307#if DEBUG_CMD_CP
    299 snprintf( string , 64 , "[ksh] %s : got stats for %s", __FUNCTION__, argv[1] );
     308snprintf( string , 128 , "[ksh] %s : got stats for %s", __FUNCTION__, argv[1] );
    300309display_string( string );
    301310#endif
     
    322331
    323332#if DEBUG_CMD_CP
    324 snprintf( string , 64 , "[ksh] %s : file %s open", __FUNCTION__, argv[2] );
     333snprintf( string , 128 , "[ksh] %s : file %s open", __FUNCTION__, argv[2] );
    325334display_string( string );
    326335#endif
     
    333342
    334343#if DEBUG_CMD_CP
    335 snprintf( string , 64 , "[ksh] %s : got stats for %s", __FUNCTION__, argv[2] );
     344snprintf( string , 128 , "[ksh] %s : got stats for %s", __FUNCTION__, argv[2] );
    336345display_string( string );
    337346#endif
     
    357366
    358367#if DEBUG_CMD_CP
    359 snprintf( string , 64 , "[ksh] %s : read %d bytes from %s", __FUNCTION__, len, argv[1] );
     368snprintf( string , 128 , "[ksh] %s : read %d bytes from %s", __FUNCTION__, len, argv[1] );
    360369display_string( string );
    361370#endif
     
    369378
    370379#if DEBUG_CMD_CP
    371 snprintf( string , 64 , "[ksh] %s : write %d bytes to %s", __FUNCTION__, len, argv[2] );
     380snprintf( string , 128 , "[ksh] %s : write %d bytes to %s", __FUNCTION__, len, argv[2] );
    372381display_string( string );
    373382#endif
     
    682691
    683692#if DEBUG_CMD_LOAD
    684 char string[64];
     693snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);
     694display_string( string );
    685695#endif
    686696
     
    725735
    726736#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 );
     737snprintf( string , 128 , "[ksh] %s : <%s> / bg %d / place %d / cxy %x",
     738__FUNCTION__, argv[1], background, placement, cxy );
    729739display_string( string );
    730740#endif
     
    744754
    745755#if DEBUG_CMD_LOAD
    746 snprintf( string , 64 , "[ksh] %s : child_pid %x after fork, before exec\n",
     756snprintf( string , 128 , "[ksh] %s : child (%x) after fork, before exec",
    747757__FUNCTION__ , getpid() );
    748758display_string( string );
     
    753763
    754764#if DEBUG_CMD_LOAD
    755 snprintf( string , 64 , "[ksh] %s : child_pid %x after exec / ret_exec %x\n",
     765snprintf( string , 128 , "[ksh] %s : child (%x) after exec / ret_exec %x",
    756766__FUNCTION__ , getpid(), ret_exec );
    757767display_string( string );
     
    769779
    770780#if DEBUG_CMD_LOAD
    771 snprintf( string , 64 , "[ksh] %s : ksh_pid %x after fork / ret_fork %x\n",
     781snprintf( string , 128 , "[ksh] %s : ksh (%x) after fork / ret_fork %x",
    772782__FUNCTION__, getpid(), ret_fork );
    773783display_string( string );
     
    821831
    822832#if DEBUG_CMD_LS
    823 char string[64];
     833snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);
     834display_string( string );
    824835#endif
    825836
     
    840851
    841852#if DEBUG_CMD_LS
    842 snprintf( string , 64 , "[ksh] %s : directory <%s> open / DIR %x\n",
     853snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x\n",
    843854__FUNCTION__, pathname , dir );
    844855display_string( string );
     
    863874
    864875#if DEBUG_CMD_LS
    865 snprintf( string , 64 , "[ksh] %s : directory <%s> closed\n",
     876snprintf( string , 128 , "[ksh] %s : directory <%s> closed\n",
    866877__FUNCTION__, pathname );
    867878display_string( string );
     
    929940
    930941#if DEBUG_CMD_PS
    931 char string[64];
     942snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);
     943display_string( string );
    932944#endif
    933945
     
    948960
    949961#if DEBUG_CMD_PS
    950 snprintf( string , 64 , "\n[ksh] %s : call display_cluster_process()", __FUNCTION__ );
     962snprintf( string , 128 , "\n[ksh] %s : call display_cluster_process()", __FUNCTION__ );
    951963display_string( string );
    952964#endif
     
    11061118
    11071119#if DEBUG_EXECUTE
    1108 printf("\n[ksh] %s : command <%s>\n",
    1109 __FUNCTION__ , buf );
     1120snprintf( string , 128 , "[ksh] enter %s for command <%s>" , __FUNCTION__ , buf );
     1121display_string( string );
    11101122#endif
    11111123
     
    11361148
    11371149#if DEBUG_EXECUTE
    1138 printf("\n[ksh] %s : argc %d / arg0 %s / arg1 %s\n",
     1150snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s\n",
    11391151__FUNCTION__ , argc , argv[0], argv[1] );
    11401152#endif
     
    11741186        char           cmd[CMD_MAX_SIZE];               // buffer for one command
    11751187
    1176 #if DEBUG_INTER
    1177 char string[128];
    1178 #endif
    1179 
    1180 
    1181 // 1. first direct command
     1188/* 1. first direct command
    11821189if( sem_wait( &semaphore ) )
    11831190{
     
    11871194else
    11881195{
    1189     printf("\n[ksh] load bin/user/fft.elf\n");
     1196    printf("\n[ksh] load bin/user/sort.elf\n");
    11901197}
    11911198
    1192 strcpy( cmd , "load bin/user/fft.elf" );
     1199strcpy( cmd , "load bin/user/sort.elf" );
    11931200execute( cmd );
    1194 //
     1201*/
    11951202
    11961203
     
    12041211else
    12051212{
    1206     printf("\n[ksh] rm home/fft_1_2_1_4096\n");
     1213    printf("\n[ksh] load bin/user/fft.elf\n");
    12071214}
    12081215
    1209 strcpy( cmd , "rm home/fft_1_2_1_4096" );
     1216strcpy( cmd , "load bin/user/fft.elf" );
    12101217execute( cmd );
    12111218*/
     
    12521259#if DEBUG_INTER
    12531260unsigned int pid = getpid();
    1254 snprintf( string , 128 , "\n[ksh] %s : request a new command", __FUNCTION__ );
     1261snprintf( string , 128 , "[ksh] %s : request a new command", __FUNCTION__ );
    12551262display_string( string );
    12561263#endif
     
    12821289                        count++;
    12831290#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 );
     1291snprintf( string , 128 , "[ksh] %s : get command <%s>", __FUNCTION__, cmd );
    12861292display_string( string );
    12871293display_vmm( 0 , 2 );
     
    14521458
    14531459#if DEBUG_MAIN
    1454 printf("\n[ksh] main thread started on core[%x,%d]\n", cxy , lid );
     1460snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d]\n", cxy , lid );
     1461display_string( string );
    14551462#endif
    14561463   
     
    14631470
    14641471#if DEBUG_MAIN
    1465 printf("\n[ksh] main initialized semaphore\n" );
     1472snprintf( string , 128 , "\n[ksh] main initialized semaphore\n" );
     1473display_string( string );
    14661474#endif
    14671475   
     
    14761484                    NULL );
    14771485#if DEBUG_MAIN
    1478 printf("\n[ksh] main thread launched interactive thread %x\n", trdid );
     1486snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x\n", trdid );
     1487display_string( string );
    14791488#endif
    14801489
  • 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
    123///////////////////////////////////////////////////////////////////////////////
    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//
    828// There is one thread per physical cores.
    929// Computation is organised as a binary tree:
     
    1535//       Number_of_stages = number of barriers = log2(Number_of_threads)
    1636//
     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//
    1742// Constraints :
    1843// - It supports up to 1024 cores: x_size, y_size, and ncores must be
     
    2954#include <hal_macros.h>
    3055
    31 #define ARRAY_LENGTH        4096       // number of items
     56#define ARRAY_LENGTH        128        // number of items
    3257#define MAX_THREADS         1024       // 16 * 16 * 4
    3358
    3459#define USE_DQT_BARRIER     1          // use DQT barrier if non zero
    3560#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
    3963#define CHECK_RESULT        0          // for debug
    4064#define INSTRUMENTATION     1          // register computation times on file
    41 #define IDBG                0          // activate interactive debug in main
    4265
    4366/////////////////////////////////////////////////////////////
     
    6285pthread_barrier_t   barrier;                 // synchronisation variables
    6386
    64 pthread_attr_t      attr[MAX_THREADS];       // thread attributes (one per thread)
    65 args_t              arg[MAX_THREADS];        // sort function arguments (one per thread)
     87pthread_t           trdid[MAX_THREADS];      // kernel identifiers
     88pthread_attr_t      attr[MAX_THREADS];       // thread attributes
     89args_t              arg[MAX_THREADS];        // sort function arguments
    6690
    6791////////////////////////////////////
     
    277301    unsigned int           lid;                // core local index for a thread
    278302    unsigned int           n;                  // index in array to sort
    279     pthread_t              trdid;              // kernel allocated thread index (unused)
    280303    pthread_barrierattr_t  barrier_attr;       // barrier attributes
    281304
     
    353376    // launch other threads to execute sort() function
    354377    // 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++ )
    360383            {
     384                // compute thread user index (continuous index)
    361385                thread_uid = (((x * y_size) + y) * ncores) + lid;
    362386
    363                 // set sort arguments for all threads
     387                // set arguments for all threads
    364388                arg[thread_uid].threads      = total_threads;
    365389                arg[thread_uid].thread_uid   = thread_uid;
     
    367391
    368392                // 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;
    372394                attr[thread_uid].cxy        = HAL_CXY_FROM_XY( x , y );
    373395                attr[thread_uid].lid        = lid;
     
    375397                if( thread_uid != main_uid )
    376398                {
    377                     if ( pthread_create( &trdid,              // not used because no join
     399                    if ( pthread_create( &trdid[thread_uid],  // buffer for kernel identifier
    378400                                         &attr[thread_uid],   // thread attributes
    379401                                         &sort,               // entry function
     
    383405                        exit( 0 );
    384406                    }
    385                     else
    386                     {
    387 #if DEBUG_MAIN
     407
     408#if (DEBUG_MAIN & 1)
    388409printf("\n[sort] main created thread %x \n", thread_uid );
    389410#endif
    390                     }
    391411                }
    392412            }
     
    402422#endif
    403423
    404 #if INTERACTIVE_MODE
    405 idbg();
    406 #endif
    407    
    408424    // the main thread run also the sort() function
    409425    sort( &arg[main_uid] );
    410426
     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)
     447printf("\n[fft] main thread %d joined thread %d\n", main_uid, thread_uid );
     448#endif
     449
     450                }
     451            }
     452        }
     453    }
     454
    411455    ////////////////////////////
    412456    get_cycle( &para_end_cycle );
     
    417461    // destroy barrier
    418462    pthread_barrier_destroy( &barrier );
    419 
    420 #if INTERACTIVE_MODE
    421 idbg();
    422 #endif
    423463
    424464#if CHECK_RESULT
Note: See TracChangeset for help on using the changeset viewer.