Changeset 626 for trunk/user


Ignore:
Timestamp:
Apr 29, 2019, 7:25:09 PM (6 years ago)
Author:
alain
Message:

This version has been tested on the sort multithreaded application
for TSAR_IOB architectures ranging from 1 to 8 clusters.
It fixes three bigs bugs:
1) the dev_ioc device API has been modified: the dev_ioc_sync_read()
and dev_ioc_sync_write() function use now extended pointers on the
kernel buffer to access a mapper stored in any cluster.
2) the hal_uspace API has been modified: the hal_copy_to_uspace()
and hal_copy_from_uspace() functions use now a (cxy,ptr) couple
to identify the target buffer (equivalent to an extended pointer.
3) an implementation bug has been fixed in the assembly code contained
in the hal_copy_to_uspace() and hal_copy_from_uspace() functions.

Location:
trunk/user
Files:
3 edited

Legend:

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

    r625 r626  
    1515// The children processes are created by the <load> command, and are
    1616// attached to the same TXT terminal as the parent KSH process.
    17 // A child process can be lauched in foreground or in background:
     17// A child process can be launched in foreground or in background:
    1818// . when the child process is launched in foreground, the KSH process loses
    1919//   the TXT terminal ownership, that is transfered to the child process.
     
    391391    if( argc < 2 )
    392392    {
    393         printf("  usage: display  vmm      cxy    pid\n"
    394                "         display  sched    cxy    lid\n"             
     393        printf("  usage: display  vmm      cxy      pid\n"
     394               "         display  sched    cxy      lid\n"             
    395395               "         display  process  cxy\n"             
    396396               "         display  txt      txtid\n"             
     
    398398               "         display  chdev\n"             
    399399               "         display  dqdt\n"             
    400                "         display  locks    pid    trdid\n"
     400               "         display  locks    pid      trdid\n"
    401401               "         display  barrier  pid\n"
    402                "         display  mapper   path   page_id  nbytes\n");
     402               "         display  mapper   path     page     nbytes\n"
     403               "         display  fat      page     entries\n"
     404               "         display  fat      cxy      0\n");
    403405    }
    404406    ////////////////////////////////////
     
    558560            {
    559561                printf("  error: cannot display page %d of mapper %s\n", page_id, argv[2] );
     562            }
     563        }
     564    }
     565    ///////////////////////////////////////////
     566    else if( strcmp( argv[1] , "fat" ) == 0 )
     567    {
     568        if( argc != 4 )
     569        {
     570                    printf("  usage: display fat page_id nb_entries\n");
     571            }
     572        else
     573        {
     574                unsigned int page_id    = atoi(argv[2]);
     575            unsigned int nb_entries = atoi(argv[3]);
     576
     577            if( display_fat( page_id, nb_entries ) )
     578            {
     579                printf("  error: cannot display page %d of fat\n", page_id );
    560580            }
    561581        }
     
    11411161}  // end execute()
    11421162
     1163
     1164
    11431165///////////////////////////////
    11441166static void interactive( void )
     
    11561178#endif
    11571179
    1158 /* 
    1159 // To lauch one or several commands without interactive mode
     1180/*
     1181// Lauch one or several commands without interactive mode
    11601182
    11611183// 1. first command
     
    11671189else
    11681190{
    1169     printf("\n[ksh] load bin/user/pgcd.elf\n");
     1191    printf("\n[ksh] display fat 0 32\n");
    11701192}
    11711193
    1172 strcpy( cmd , "load bin/user/pgcd.elf" );
     1194strcpy( cmd , "display fat 0 32" );
    11731195execute( cmd );
    11741196
     
    11811203else
    11821204{
    1183     printf("\n[ksh] ls home\n");
     1205    printf("\n[ksh] load bin/user/pgcd.elf\n");
    11841206}
    11851207
    1186 strcpy( cmd , "ls home" );
     1208strcpy( cmd , "load bin/user/pgcd.elf" );
    11871209execute( cmd );
    11881210
  • trunk/user/pgcd/pgcd.c

    r625 r626  
    1212#include <almosmkh.h>
    1313
     14#define   INSTRUMENTATION  0
     15#define   IDBG             0
     16
    1417/////////////////
    1518void main( void )
     
    1720    int                opx;
    1821    int                opy;
     22    int                x;
     23    int                y;
    1924    unsigned long long cycle;
    2025    unsigned int       cxy;
     
    2429    get_core( &cxy , &lid );
    2530
    26     printf( "\n\n[pgcd] starts on core[%x,%d] / cycle %d\n",
     31    printf( "\n[pgcd] starts on core[%x,%d] / cycle %d\n\n",
    2732    cxy , lid , (unsigned int)cycle );
    2833
    29     while (1)
     34    // get operand X
     35    printf("operand X = ");
     36    opx = get_uint32();
     37    printf("\n");
     38
     39    // get operand Y
     40    printf("operand Y = ");
     41    opy = get_uint32();
     42    printf("\n");
     43
     44    // check operands
     45    if( (opx == 0) || (opy == 0) )
    3046    {
    31         printf("\n*******************\n");
    32         printf("operand X = ");
    33         opx = get_uint32();
    34         printf("\n");
    35         printf("operand Y = ");
    36         opy = get_uint32();
    37         printf("\n");
     47        printf("\n[pgcd error] operands must be strictly positive\n");
     48        exit(0);
     49    }
    3850
    39         if( (opx == 0) || (opy == 0) )
    40         {
    41            printf("operands must be positive and larger than 0 => exit\n");
    42            exit( 0 );
    43         }
    44         else
    45         {
    46             while (opx != opy)
    47             {
    48                 if(opx > opy)   opx = opx - opy;
    49                 else            opy = opy - opx;
    50             }
    51             printf("pgcd      = %d", opx);
    52         }
     51    // compute PGCD
     52    x = opx;
     53    y = opy;
     54    while (x != y)
     55    {
     56        if(x > y)   x = x - y;
     57        else        y = y - x;
    5358    }
     59
     60    // display result
     61    printf("pgcd      = %d\n", x);
     62
     63#if INSTRUMENTATION
     64
     65    char   name[64];
     66    char   path[128];
     67
     68    // build a file name from X and Y values
     69    snprintf( name , 64 , "pgcd_%d_%d", opx, opy );
     70
     71    // build file pathname
     72    snprintf( path , 128 , "home/%s" , name );
     73
     74#if IDBG
     75idbg();
     76#endif
     77
     78    // open file
     79    FILE * stream = fopen( path , NULL );
     80
     81    if( stream == NULL )
     82    {
     83        printf("\n[pgcd error] cannot open instrumentation file <%s>\n", name );
     84        exit(0);
     85    }
     86
     87    printf("\n[pgcd] file %s successfully open\n", path);
     88
     89#if IDBG
     90idbg();
     91#endif
     92
     93    // register results to file
     94    int ret = fprintf( stream , "pgcd( %d , %d ) = %d\n", opx, opy, x );
     95
     96    if( ret < 0 )
     97    {
     98        printf("\n[pgcd error] cannot write to instrumentation file <%s>\n", name );
     99        exit(0);
     100    }
     101
     102    printf("\n[pgcd] file %s successfully written\n", path);
     103
     104    display_mapper( path , 0 , 64 );
     105
     106    // close instrumentation file
     107
     108#if IDBG
     109idbg();
     110#endif
     111
     112    if( fclose( stream ) )
     113    {
     114        printf("\n[pgcd error] cannot close the file <%s>\n", name );
     115        exit(0);
     116    }
     117
     118    printf("\n[pgcd] file %s successfully closed\n", path);
     119
     120#endif
     121
     122    exit(0);
     123       
    54124} // end pgcd
    55125
  • trunk/user/sort/sort.c

    r625 r626  
    2929#include <hal_macros.h>
    3030
    31 #define ARRAY_LENGTH        256        // number of items
     31#define ARRAY_LENGTH        1024       // number of items
    3232#define MAX_THREADS         1024       // 16 * 16 * 4
    3333
     
    3838#define CHECK_RESULT        0          // for debug
    3939#define INSTRUMENTATION     1          // register computation times on file
     40#define IDBG                0          // activate interactive debug in main
    4041
    4142/////////////////////////////////////////////////////////////
     
    439440#if INSTRUMENTATION
    440441
    441     char   name[64];
    442     char   path[128];
     442    char               name[64];
     443    char               path[128];
     444    unsigned long long instru_cycle;
    443445
    444446    // build a file name from n_items / n_clusters / n_cores
     
    461463           name, sequencial, parallel );
    462464
     465#if IDBG
     466idbg();
     467#endif
     468
    463469    // open file
     470    get_cycle( &instru_cycle );
    464471    FILE * stream = fopen( path , NULL );
     472
    465473    if( stream == NULL )
    466474    {
    467         printf("\n[sort error] cannot open instrumentation file <%s>\n", name );
     475        printf("\n[sort error] cannot open instrumentation file <%s>\n", path );
    468476        exit(0);
    469477    }
    470478
    471     printf("\n[sort] file %s successfully open\n", path);
     479    printf("\n[sort] file <%s> open at cycle %d\n", path, (unsigned int)instru_cycle );
     480
     481#if IDBG
     482idbg();
     483#endif
    472484
    473485    // register results to file
     486    get_cycle( &instru_cycle );
    474487    int ret = fprintf( stream , "\n----- %s -----\n"
    475488                                " - sequencial : %d cycles\n"
     
    477490    if( ret < 0 )
    478491    {
    479         printf("\n[sort error] cannot write to instrumentation file <%s>\n", name );
     492        printf("\n[sort error] cannot write to instrumentation file <%s>\n", path );
    480493        exit(0);
    481494    }
    482495
    483     printf("\n[sort] file %s successfully written\n", path);
     496    printf("\n[sort] file <%s> written at cycle %d\n", path, (unsigned int)instru_cycle );
     497
     498#if IDBG
     499idbg();
     500#endif
    484501
    485502    // close instrumentation file
    486 
    487     if( fclose( stream ) )
    488     {
    489         printf("\n[sort error] cannot close the file <%s>\n", name );
     503    get_cycle( &instru_cycle );
     504    ret = fclose( stream );
     505
     506    if( ret )
     507    {
     508        printf("\n[sort error] cannot close instrumentation file <%s>\n", path );
    490509        exit(0);
    491510    }
    492511
    493     printf("\n[sort] file %s successfully closed\n", path);
     512    printf("\n[sort] file <%s> closed at cycle %d\n", path, (unsigned int)instru_cycle );
    494513
    495514#endif
Note: See TracChangeset for help on using the changeset viewer.