Changeset 369

Show
Ignore:
Timestamp:
07/31/06 02:28:24 (4 years ago)
Author:
vasi
Message:

faster...

Location:
icfp2006/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • icfp2006/trunk/Makefile

    r366 r369  
    1 CPPFLAGS = -Wall -O0 -g 
     1CCOPT = -O0 -g 
     2CCOPT_FAST = -fast -mcpu=7450 -mdynamic-no-pic 
     3DEBUG = 1 
     4CPPFLAGS = -Wall $(CCOPT) -DDEBUG=$(DEBUG) 
    25 
    3 all: um 
     6 
     7all: opt 
     8 
     9shark: CCOPT = $(CCOPT_FAST) 
     10shark: um 
     11 
     12opt: DEBUG = 0 
     13opt: shark 
    414 
    515um: um.o 
     
    818%.o: %.cpp 
    919        $(CXX) $(CPPFLAGS) -o $@ -c $< 
     20 
     21clean: 
     22        rm -f um *.o 
  • icfp2006/trunk/um.cpp

    r368 r369  
    22#include <cstdlib> 
    33#include <stdint.h> 
     4#include <sys/ioctl.h> 
    45#include <vector> 
    56using namespace std; 
     7 
    68 
    79typedef uint32_t platter_t; 
     
    3335 
    3436 
     37void check_input(); 
     38 
    3539void next_inst(); 
    3640void read_program(const char *fname); 
     
    6064         
    6165        read_program(argv[1]); 
     66        #if DEBUG 
     67                int done = 0; 
     68        #endif 
     69         
    6270        while (1) { 
     71                #if DEBUG 
     72                        if (done % 1000000 == 0) { 
     73                                fprintf(stderr, "MOps: %5d\n", done / 1000000); 
     74                        } 
     75                        ++done; 
     76                #endif 
    6377                next_inst(); 
    6478        } 
     
    105119        switch (OP) { 
    106120                case OP_INPUT: { 
    107                          int c = fgetc(Infile); 
    108                          CREG = static_cast<platter_t>(c == EOF ? -1 : c); 
    109                          break; 
     121                        #if DEBUG 
     122                                check_input(); 
     123                        #endif 
     124                        int c = fgetc(Infile); 
     125                        CREG = static_cast<platter_t>(c == EOF ? -1 : c); 
     126                        break; 
    110127                } 
    111128                 
     
    176193        } 
    177194} 
     195 
     196void check_input() { 
     197        if (Infile == stdin) { 
     198                int cnt; 
     199                ioctl(/* stdin */ 0, FIONREAD, &cnt); 
     200                if (cnt == 0) { 
     201                        fprintf(stderr, "> "); /* prompt the user */ 
     202                } 
     203        }        
     204}