Changeset 775 for soft


Ignore:
Timestamp:
Feb 4, 2016, 5:05:56 PM (8 years ago)
Author:
alain
Message:

Introduce the dump command in shell.

Location:
soft/giet_vm/applications
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/shell/shell.c

    r772 r775  
    4444static void cmd_time(int argc, char** argv)
    4545{
    46     giet_tty_printf("%d\n", giet_proctime());
     46    giet_tty_printf(" cycle = %d\n", giet_proctime());
    4747}
    4848
     
    5050static void cmd_ls(int argc, char** argv)
    5151{
    52     int fd;
    53     fat_dirent_t entry;
    54 
    55     if (argc < 2)
    56     {
    57         giet_tty_printf("  usage : %s <pathname>\n", argv[0]);
    58         return;
    59     }
    60 
    61     fd = giet_fat_opendir(argv[1]);
     52    int            fd;
     53    int            rec;
     54    char*          pathname;
     55    fat_dirent_t   entry;
     56
     57    if (argc == 2)
     58    {
     59        rec = 0;
     60        pathname = argv[1];
     61    }
     62    else if ( (argc == 3) && (strcmp( argv[1] , "-r" ) == 0) )
     63    {
     64        rec = 1;
     65        pathname = argv[2];
     66
     67        giet_tty_printf("  error : recursive mode not supported yet\n");
     68        return;
     69    }
     70    else
     71    {
     72        giet_tty_printf("  usage : ls [-r] pathname\n");
     73        return;
     74    }
     75
     76    fd  = giet_fat_opendir( pathname );
    6277
    6378    if (fd < 0)
     
    8499    if (argc < 2)
    85100    {
    86         giet_tty_printf("  usage : %s <path>\n", argv[0]);
     101        giet_tty_printf("  usage : mkdir pathname\n");
    87102        return;
    88103    }
     
    101116    if (argc < 3)
    102117    {
    103         giet_tty_printf("  usage : %s <src> <dst>\n", argv[0]);
     118        giet_tty_printf("  usage : cp src_pathname dst_pathname>\n");
    104119        return;
    105120    }
     
    141156    if (info.is_dir)
    142157    {
    143         giet_tty_printf("error : %s is a directory\n", argv[2] );  // TODO
     158        giet_tty_printf("  error : %s is a directory\n", argv[2] );  // TODO
    144159        goto exit;
    145160    }
     
    150165        int len = (size - i < 1024 ? size - i : 1024);
    151166        int wlen;
    152 
    153         giet_tty_printf("\rwrite %d/%d (%d%%)", i, size, 100*i/size);
    154167
    155168        len = giet_fat_read(src_fd, &buf, len);
     
    162175        i += len;
    163176    }
    164     giet_tty_printf("\n");
    165177
    166178exit:
     
    176188    if (argc < 2)
    177189    {
    178         giet_tty_printf("  usage : %s <file>\n", argv[0]);
     190        giet_tty_printf("  usage : rm pathname\n");
    179191        return;
    180192    }
     
    193205    if (argc < 2)
    194206    {
    195         giet_tty_printf("  usage : %s <pathname>\n", argv[0]);
     207        giet_tty_printf("  usage : rmdir pathname\n");
    196208        return;
    197209    }
     
    209221    if (argc < 3)
    210222    {
    211         giet_tty_printf("  usage : %s <src> <dst>\n", argv[0]);
     223        giet_tty_printf("  usage : %s src_pathname dst_pathname\n", argv[0]);
    212224        return;
    213225    }
     
    225237    if (argc < 2)
    226238    {
    227         giet_tty_printf("  usage : %s <vspace_name>\n", argv[0]);
     239        giet_tty_printf("  usage : %s vspace_name\n", argv[0]);
    228240        return;
    229241    }
     
    241253    if (argc < 2)
    242254    {
    243         giet_tty_printf("  usage : %s <vspace_name>\n", argv[0]);
     255        giet_tty_printf("  usage : %s vspace_name\n", argv[0]);
    244256        return;
    245257    }
     
    274286    if (argc < 3)
    275287    {
    276         giet_tty_printf("  usage : %s <vspace_name> <thread_name>\n", argv[0] );
     288        giet_tty_printf("  usage : %s vspace_name thread_name\n", argv[0] );
    277289        return;
    278290    }
     
    286298    if (argc < 3)
    287299    {
    288         giet_tty_printf("  usage : %s <vspace_name> <thread_name>\n", argv[0] );
     300        giet_tty_printf("  usage : %s vspace_name thread_name\n", argv[0] );
    289301        return;
    290302    }
     
    298310    if (argc < 3)
    299311    {
    300         giet_tty_printf("  usage : %s <vspace_name> <thread_name>\n", argv[0] );
     312        giet_tty_printf("  usage : %s vspace_name thread_name\n", argv[0] );
    301313        return;
    302314    }
     
    308320static void cmd_cat(int argc, char** argv)
    309321{
    310     if (argc < 2)
    311     {
    312         giet_tty_printf("  usage : %s <path_name> \n", argv[0] );
     322    if (argc != 2)
     323    {
     324        giet_tty_printf("  usage : cat pathname \n");
    313325        return;
    314326    }
     
    358370    }
    359371
    360 /*
    361     // allocate a temporary buffer for the file
    362     heap_init( x , y );
    363     buf = (char*)malloc( size ); 
    364     if( buf == NULL )
    365     {
    366         giet_tty_printf("  error : cannot allocate buffer with size = %d\n", size );
    367         goto exit;
    368     }
    369     // load the file
    370     len = giet_fat_read( fd , buf , size );
    371     if ( len != size )
    372     {
    373         giet_tty_printf("  error : cannot load file %s / size = %d / len = %d\n",
    374                         argv[1] , size , len );
    375         goto exit;
    376     }
    377 */
    378372    // set terminating '0'
    379373    buf[size] = 0;
     
    387381}
    388382
     383///////////////////////////////////////////
     384static void cmd_dump(int argc, char** argv)
     385{
     386    if ((argc == 2) && (strcmp( argv[1] , "-bs" ) == 0))
     387    {
     388        giet_fat_dump( DUMP_BS , NULL , 0 );
     389    }
     390    else if ((argc == 2) && (strcmp( argv[1] , "-fs" ) == 0))
     391    {
     392        giet_fat_dump( DUMP_FS , NULL , 0 );
     393    }
     394    else if ((argc == 3) && (strcmp( argv[1] , "-fat" ) == 0))
     395    {
     396        giet_fat_dump( DUMP_FAT , NULL , atoi( argv[2] ) );
     397    }
     398    else if ((argc == 4) && (strcmp( argv[1] , "-file" ) == 0))
     399    {
     400        giet_fat_dump( DUMP_FILE , argv[2] , atoi( argv[3] ) );
     401    }
     402    else if ((argc == 4) && (strcmp( argv[1] , "-dir" ) == 0))
     403    {
     404        giet_fat_dump( DUMP_DIR , argv[2] , atoi( argv[3] ) );
     405    }
     406    else
     407    {
     408        giet_tty_printf("  usage : dump [-bs] [-fs] [-fat block] "
     409                        "[-file pathname block] [-dir pathname block]\n");
     410        return;
     411    }
     412}
     413
     414
    389415////////////////////////////////////////////////////////////////////
    390416struct command_t cmd[] =
     
    393419    { "context",    "display a thread context",             cmd_context },
    394420    { "cp",         "replicate a file in file system",      cmd_cp },
     421    { "dump",       "display content of disk sector",       cmd_dump },
    395422    { "exec",       "start an application",                 cmd_exec },
    396423    { "help",       "list available commands",              cmd_help },
  • soft/giet_vm/applications/transpose/transpose.c

    r772 r775  
    4747#define PROCS_MAX             4                            // max number of procs per cluster
    4848#define CLUSTER_MAX           (X_MAX * Y_MAX)              // max number of clusters
    49 #define IMAGE_SIZE            256                          // default image size
    50 #define INPUT_FILE_PATH       "/misc/lena_256.raw"         // default input file pathname
    51 #define OUTPUT_FILE_PATH      "/home/lena_transposed.raw"  // default output file pathname
     49#define IMAGE_SIZE            128                          // default image size
     50#define INPUT_FILE_PATH       "/misc/images_128.raw"       // default input file pathname
     51#define OUTPUT_FILE_PATH      "/home/trsp_128.raw"         // default output file pathname
    5252#define INTERACTIVE           0                            // interactive capture of filenames
    53 #define VERBOSE               1                            // print comments on TTY
     53#define VERBOSE               0                            // print comments on TTY
    5454
    5555
     
    126126    if ( p_id == 0 )
    127127    {
    128         // map buf_in and buf_out
     128        // map buf_in
    129129        unsigned int length = npixels / nclusters;
    130130        unsigned int offset = length * cluster_id;
     
    144144                 
    145145        if ( VERBOSE )
    146         printf("\n@@@ Thread[%d,%d,%d] call mmap for input file\n"
    147                " length = %x / offset = %x / buf_in = %x\n",
    148                x_id , y_id , p_id , length , offset , buf_in[cluster_id] );
    149            
     146        {
     147            printf("\n@@@ Thread[%d,%d,%d] call mmap for input file\n"
     148                   " length = %x / offset = %x / buf_in = %x\n",
     149                   x_id , y_id , p_id , length , offset , buf_in[cluster_id] );
     150        }
     151
     152        // map buf_out           
    150153        buf_out[cluster_id] = giet_fat_mmap( NULL,
    151154                                             length,
     
    154157                                             fd_out,
    155158                                             offset );
     159
    156160        if ( buf_out[cluster_id] == NULL )
    157161        {
     
    162166                   
    163167        if ( VERBOSE )
    164         printf("\n@@@ Thread[%d,%d,%d] call mmap for output file\n"
    165                " length = %x / offset = %x / buf_out = %x\n",
    166                x_id , y_id , p_id , length , offset , buf_out[cluster_id] );
     168        {
     169            printf("\n@@@ Thread[%d,%d,%d] call mmap for output file\n"
     170                   " length = %x / offset = %x / buf_out = %x\n",
     171                   x_id , y_id , p_id , length , offset , buf_out[cluster_id] );
     172        }
    167173       
    168174    }
     
    275281    unsigned int max_disp_ended = 0;
    276282 
     283    char string[64];
     284
     285    snprintf( string , 64 , "/home/transpose_%d_%d_%d" , x_size , y_size , nprocs );
     286
    277287    // open instrumentation file
    278     unsigned int fd = giet_fat_open( "/home/transpose.inst" , O_CREAT);
     288    unsigned int fd = giet_fat_open( string , O_CREATE );
    279289    if ( fd < 0 )
    280290    {
    281         printf("\n[TRANSPOSE ERROR] main cannot open file transpose.inst\n");
     291        printf("\n[TRANSPOSE ERROR] cannot open instrumentation file %s\n", string );
    282292        giet_pthread_exit( NULL );
    283293    }
     
    305315    }
    306316
    307     printf("\n   ---------------- Instrumentation Results ---------------------\n");
    308 
    309     printf(" - MMAP_START : min = %d / max = %d / med = %d / delta = %d\n",
     317    giet_tty_printf( "\n ------ %s ------\n" , string );
     318    giet_fat_fprintf( fd , "\n ------ %s ------\n" , string );
     319
     320    giet_tty_printf( " - MMAP_START : min = %d / max = %d / med = %d / delta = %d\n",
    310321           min_load_start, max_load_start, (min_load_start+max_load_start)/2,
    311            max_load_start-min_load_start);
     322           max_load_start-min_load_start );
     323
    312324    giet_fat_fprintf( fd , " - MMAP_START : min = %d / max = %d / med = %d / delta = %d\n",
    313325           min_load_start, max_load_start, (min_load_start+max_load_start)/2,
    314            max_load_start-min_load_start);
    315 
    316     printf(" - MMAP_END   : min = %d / max = %d / med = %d / delta = %d\n",
     326           max_load_start-min_load_start );
     327
     328    giet_tty_printf( " - MMAP_END   : min = %d / max = %d / med = %d / delta = %d\n",
    317329           min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2,
    318            max_load_ended-min_load_ended);
     330           max_load_ended-min_load_ended );
     331
    319332    giet_fat_fprintf( fd , " - MMAP_END   : min = %d / max = %d / med = %d / delta = %d\n",
    320333           min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2,
    321            max_load_ended-min_load_ended);
    322 
    323     printf(" - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n",
     334           max_load_ended-min_load_ended );
     335
     336    giet_tty_printf( " - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n",
    324337           min_trsp_start, max_trsp_start, (min_trsp_start+max_trsp_start)/2,
    325            max_trsp_start-min_trsp_start);
     338           max_trsp_start-min_trsp_start );
     339
    326340    giet_fat_fprintf( fd , " - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n",
    327341           min_trsp_start, max_trsp_start, (min_trsp_start+max_trsp_start)/2,
    328            max_trsp_start-min_trsp_start);
    329 
    330     printf(" - TRSP_END   : min = %d / max = %d / med = %d / delta = %d\n",
     342           max_trsp_start-min_trsp_start );
     343
     344    giet_tty_printf( " - TRSP_END   : min = %d / max = %d / med = %d / delta = %d\n",
    331345           min_trsp_ended, max_trsp_ended, (min_trsp_ended+max_trsp_ended)/2,
    332            max_trsp_ended-min_trsp_ended);
     346           max_trsp_ended-min_trsp_ended );
     347
    333348    giet_fat_fprintf( fd , " - TRSP_END   : min = %d / max = %d / med = %d / delta = %d\n",
    334349           min_trsp_ended, max_trsp_ended, (min_trsp_ended+max_trsp_ended)/2,
    335            max_trsp_ended-min_trsp_ended);
    336 
    337     printf(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n",
     350           max_trsp_ended-min_trsp_ended );
     351
     352    giet_tty_printf( " - DISP_START : min = %d / max = %d / med = %d / delta = %d\n",
    338353           min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2,
    339            max_disp_start-min_disp_start);
     354           max_disp_start-min_disp_start );
     355
    340356    giet_fat_fprintf( fd , " - DISP_START : min = %d / max = %d / med = %d / delta = %d\n",
    341357           min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2,
    342            max_disp_start-min_disp_start);
    343 
    344     printf(" - DISP_END   : min = %d / max = %d / med = %d / delta = %d\n",
     358           max_disp_start-min_disp_start );
     359
     360    giet_tty_printf( " - DISP_END   : min = %d / max = %d / med = %d / delta = %d\n",
    345361           min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2,
    346            max_disp_ended-min_disp_ended);
     362           max_disp_ended-min_disp_ended );
     363
    347364    giet_fat_fprintf( fd , " - DISP_END   : min = %d / max = %d / med = %d / delta = %d\n",
    348365           min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2,
    349            max_disp_ended-min_disp_ended);
     366           max_disp_ended-min_disp_ended );
    350367
    351368    giet_fat_close( fd );
     
    453470    }
    454471
    455     fd_out = giet_fat_open( output_file_name , O_CREAT);   // create if required
     472    fd_out = giet_fat_open( output_file_name , O_CREATE );   // create if required
    456473    if ( fd_out < 0 )
    457474    {
  • soft/giet_vm/applications/transpose/transpose.py

    r764 r775  
    5050
    5151    # create vspace
    52     vspace = mapping.addVspace( name = 'transpose', startname = 'trsp_data', active = True )
     52    vspace = mapping.addVspace( name = 'transpose', startname = 'trsp_data', active = False )
    5353   
    5454    # data vseg : shared (only in cluster[0,0])
Note: See TracChangeset for help on using the changeset viewer.