Tuesday 15 April 2014

c - Bash No such file or Directory Error (Cache Simulator) -



c - Bash No such file or Directory Error (Cache Simulator) -

i design cache simulator count miss,hits,eviction.i tried compile programme next command ,it worked without error,

program #include <stdlib.h> #include <stdio.h> #include <getopt.h> #include <strings.h> #include <limits.h> //#include "cachelab.h" /* utilize 64-bit variable hold memory addresses*/ typedef unsigned long long int mem_addr_t; /* struct groups cache parameters */ typedef struct { int s; /* 2**s cache sets */ int b; /* cacheline block size 2**b bytes */ int e; /* number of cachelines per set */ int s; /* number of sets, derived s = 2**s */ int b; /* cacheline block size (bytes), derived b = 2**b */ } cache_param_t; int verbosity; /* printusage - print usage info */ void printusage( char *argv[] ) { printf( "usage: %s [-hv] -s <num> -e <num> -b <num> -t <file>\n", argv[0] ); printf( "options:\n" ); printf( " -h print help message.\n" ); printf( " -v optional verbose flag.\n" ); printf( " -s <num> number of set index bits.\n" ); printf( " -e <num> number of lines per set.\n" ); printf( " -b <num> number of block offset bits.\n" ); printf( " -t <file> trace file.\n" ); printf( "\nexamples:\n" ); printf( " %s -s 4 -e 1 -b 4 -t traces/yi.trace\n", argv[0] ); printf( " %s -v -s 8 -e 2 -b 4 -t traces/yi.trace\n", argv[0] ); exit( 0 ); } void printsummary( int hit_count, int miss_count, int eviction_count ) { printf( "hits: %d misses: %d evictions: %d\n", hit_count, miss_count, eviction_count ); } int main( int argc, char **argv ) { cache_param_t par; bzero( &par, sizeof ( par ) ); char *trace_file; char c; while ( ( c = getopt( argc, argv, "s:e:b:t:vh" ) ) != -1 ) { switch ( c ) { case 's': par.s = atoi( optarg ); break; case 'e': par.e = atoi( optarg ); break; case 'b': par.b = atoi( optarg ); break; case 't': trace_file = optarg; break; case 'v': verbosity = 1; break; case 'h': printusage( argv ); exit( 0 ); default: printusage( argv ); exit( 1 ); } } if ( par.s == 0 || par.e == 0 || par.b == 0 || trace_file == null ) { printf( "%s: missing required command line argument\n", argv[0] ); printusage( argv ); exit( 1 ); } /* todo: compute s , b based on info passed in */ //compute s , b, 2^s , 2^b respectively par.s = ( 1 << par.s ); par.b = ( 1 << par.b ); /* todo: initialize cache */ //structure line typedef struct { int valid; mem_addr_t tag; int timestamp; } line_st; //structure set; pointer array of lines typedef struct { line_st *lines; } cache_set; //structure cache; pointer array of sets typedef struct { cache_set *sets; } cache_t; //allocate space sets , lines cache_t cache; int i; cache.sets = malloc( par.s * sizeof ( cache_set ) ); (i = 0; < par.s; i++ ) { cache.sets[i].lines = malloc( sizeof ( line_st ) * par.e ); } //counters int hit_count = 0; int miss_count = 0; int eviction_count = 0; /* todo: run trace simulation */ char act; //l,s,m int size; //size read in file int tstamp = 0; //value lru int empty = -1; //index of empty space int h = 0; //is there nail int e = 0; //is there eviction int e; mem_addr_t addr; //open file , read in file *tracefile = fopen( trace_file, "r" ); if ( tracefile != null ) { while ( fscanf( tracefile, " %c %llx,%d", &act, &addr, &size ) == 3 ) { int toevict = 0; //keeps track of evict if ( deed != 'i' ) { //calculate address tag , set index mem_addr_t addr_tag = addr >> ( par.s + par.b ); int tag_size = ( 64 - ( par.s + par.b ) ); unsigned long long temp = addr << ( tag_size ); unsigned long long setid = temp >> ( tag_size + par.b ); cache_set set = cache.sets[setid]; int low = int_max; // changed, added #include <limits.h> (e = 0; e < par.e; e++ ) { if ( set.lines[e].valid == 1 ) { // changed order: nail before eviction candidates if ( set.lines[e].tag == addr_tag ) { hit_count++; h = 1; set.lines[e].timestamp = tstamp; tstamp++; } // changed whole else: oldest eviction. else if ( set.lines[e].timestamp < low ) { low = set.lines[e].timestamp; toevict = e; } } // changed: if haven't yet found empty, mark 1 found. else if( empty == -1 ) { empty = e; } } //if have miss if ( h != 1 ) { miss_count++; //if have empty line if ( empty > -1 ) { set.lines[empty].valid = 1; set.lines[empty].tag = addr_tag; set.lines[empty].timestamp = tstamp; tstamp++; } //if set total need evict else if ( empty < 0 ) { e = 1; set.lines[toevict].tag = addr_tag; set.lines[toevict].timestamp = tstamp; tstamp++; // changed: increment tstamp here eviction_count++; } } //if instruction m, nail if ( deed == 'm' ) { hit_count++; } //if -v flag set print out debug info if ( verbosity == 1 ) { printf( "%c ", deed ); printf( "%llx,%d", addr, size ); if ( h == 1 ) { printf( "hit " ); } else if ( h != 1 ) { printf( "miss " ); } if ( e == 1 ) { printf( "eviction " ); } // changed: don't print nail 1 time again since 'm' going print nail above. printf( "\n" ); } empty = -1; h = 0; e = 0; } } } /* todo: clean cache resources */ /* todo: print out real results */ printsummary( hit_count, miss_count, eviction_count ); void printsummary(int hits, int misses, int evictions) { printf("hits:%d misses:%d evictions:%d\n", hits, misses, evictions); file* output_fp = fopen(".csim_results", "w"); fprintf(output_fp, "%d %d %d\n", hits, misses, evictions); fclose(output_fp); } homecoming 0; } compile command gcc -wall hello.c -o hello.out -lm when tried execute code getting next error : error while running programme bash: ./hello:no such file or directory command used run follows run command ./hello [hv] -s 5 -e 1 -b 5 -t traces/trans.trace expected output hits 231 misses 7 evictions 0

i pretty sure path have set while executing programme right not able find solution encounter ? help me out !!

you compiled gcc -wall hello.c -o hello.out -lm, you're looking execute ./hello.out.

if want run ./hello, compile line:

gcc -wall hello.c -o hello -lm

c linux bash compiler-errors terminal

No comments:

Post a Comment