Ejemplo n.º 1
0
static void time_a_int32_z_float32( float32 function( int32 ) )
{
    clock_t startClock, endClock;
    int32 count, i;
    int8 inputNum;

    count = 0;
    inputNum = 0;
    startClock = clock();
    do {
        for ( i = minIterations; i; --i ) {
            function( inputs_int32[ inputNum ] );
            inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
        }
        count += minIterations;
    } while ( clock() - startClock < CLOCKS_PER_SEC );
    inputNum = 0;
    startClock = clock();
    for ( i = count; i; --i ) {
        function( inputs_int32[ inputNum ] );
        inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
    }
    endClock = clock();
    reportTime( count, endClock - startClock );

}
Ejemplo n.º 2
0
int main6(int argc, char *argv[]) {  
  Intstack cell, co;
  int rank, upb, nr = 0;
  assert(argc > 1);
  rank = atoi(argv[1]);
  upb = 1 << rank;
  co = newIntstack(upb, NULL);
  cell = readCell();
  while (cell) {
    nr = getCnr();
    printCell(nr, cell);
    complement(upb, cell, co);
    printf("COM ");
    printCell(0, co);
    freestack(cell);
    printf("\n");
    cell = readCell();
  }
  freestack(cell);
  freestack(co);
#if 0
  reportTime();
  reportCnt();
#endif
  finalizeScanner();
  return 0;
}
Ejemplo n.º 3
0
static void time_az_float64_pos( float64 function( float64 ) )
{
    clock_t startClock, endClock;
    int32 count, i;
    int8 inputNum;
    float64 a;

    count = 0;
    inputNum = 0;
    startClock = clock();
    do {
        for ( i = minIterations; i; --i ) {
            a.low = inputs_float64_pos[ inputNum ].low;
            a.high = inputs_float64_pos[ inputNum ].high;
            function( a );
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
        }
        count += minIterations;
    } while ( clock() - startClock < CLOCKS_PER_SEC );
    inputNum = 0;
    startClock = clock();
    for ( i = count; i; --i ) {
        a.low = inputs_float64_pos[ inputNum ].low;
        a.high = inputs_float64_pos[ inputNum ].high;
        function( a );
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
    }
    endClock = clock();
    reportTime( count, endClock - startClock );

}
Ejemplo n.º 4
0
static void time_ab_float32_z_flag( flag function( float32, float32 ) )
{
    clock_t startClock, endClock;
    int32 count, i;
    int8 inputNumA, inputNumB;

    count = 0;
    inputNumA = 0;
    inputNumB = 0;
    startClock = clock();
    do {
        for ( i = minIterations; i; --i ) {
            function(
                inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
            if ( inputNumA == 0 ) ++inputNumB;
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
        }
        count += minIterations;
    } while ( clock() - startClock < CLOCKS_PER_SEC );
    inputNumA = 0;
    inputNumB = 0;
    startClock = clock();
    for ( i = count; i; --i ) {
            function(
                inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
        if ( inputNumA == 0 ) ++inputNumB;
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
    }
    endClock = clock();
    reportTime( count, endClock - startClock );

}
Ejemplo n.º 5
0
int main10(int argc, char *argv[]) { /* Give the classification */
	int rank, option = 0;
	Arraylist ar;
	assert(argc> 1);
	rank = atoi(argv[1]);
	if (argc > 2)
		option = atoi(argv[2]);
	if (option == 2) {
		ar = readCellList();
		setRank(rank);
	} 
	else {
		ar = classify(rank, option);
	}
	if (option != 1) {
		sortAndWeed(rank, ar);
		freePerm();
		printCellList(ar);
#if 0
		printDoubletons(ar);
#endif
		freeStackList(ar);
	}
	if (option == 2)
		finalizeScanner();
	printf("\n");
	reportTime();
#if 0
	reportACnt();
	reportCnt();
#endif
	return 0;
}
Ejemplo n.º 6
0
static void time_abz_float64( float64 function( float64, float64 ) )
{
    clock_t startClock, endClock;
    int32 count, i;
    int8 inputNumA, inputNumB;
    float64 a, b;

    count = 0;
    inputNumA = 0;
    inputNumB = 0;
    startClock = clock();
    do {
        for ( i = minIterations; i; --i ) {
            a.low = inputs_float64[ inputNumA ].low;
            a.high = inputs_float64[ inputNumA ].high;
            b.low = inputs_float64[ inputNumB ].low;
            b.high = inputs_float64[ inputNumB ].high;
            function( a, b );
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
            if ( inputNumA == 0 ) ++inputNumB;
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
        }
        count += minIterations;
    } while ( clock() - startClock < CLOCKS_PER_SEC );
    inputNumA = 0;
    inputNumB = 0;
    startClock = clock();
    for ( i = count; i; --i ) {
        a.low = inputs_float64[ inputNumA ].low;
        a.high = inputs_float64[ inputNumA ].high;
        b.low = inputs_float64[ inputNumB ].low;
        b.high = inputs_float64[ inputNumB ].high;
        function( a, b );
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
        if ( inputNumA == 0 ) ++inputNumB;
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
    }
    endClock = clock();
    reportTime( count, endClock - startClock );

}
Ejemplo n.º 7
0
int  sendBuf( rbudpSender_t *rbudpSender, void * buffer, int bufSize,
              int sendRate, int packetSize ) {
    int done = 0;
    int status = 0;
    struct timeval curTime, startTime;
    double srate;
    gettimeofday( &curTime, NULL );
    startTime = curTime;
    int lastRemainNumberOfPackets = 0;
    int noProgressCnt = 0;
    initSendRudp( rbudpSender, buffer, bufSize, sendRate, packetSize );
    while ( !done ) {
        // blast UDP packets
        if ( rbudpSender->rbudpBase.verbose > 1 ) {
            TRACE_DEBUG( "sending UDP packets" );
        }
        reportTime( &curTime );
        status = udpSend( rbudpSender );
        if ( status < 0 ) {
            return status;
        }

        srate = ( double ) rbudpSender->rbudpBase.remainNumberOfPackets *
                rbudpSender->rbudpBase.payloadSize * 8 /
                ( double ) reportTime( &curTime );
        if ( rbudpSender->rbudpBase.verbose > 1 ) {
            TRACE_DEBUG( "real sending rate in this send is %f", srate );
        }

        if ( lastRemainNumberOfPackets == 0 ) {
            lastRemainNumberOfPackets =
                rbudpSender->rbudpBase.remainNumberOfPackets;
        }
        // send end of UDP signal
        if ( rbudpSender->rbudpBase.verbose > 1 )
            TRACE_DEBUG( "send to socket %d an end signal.",
                         rbudpSender->rbudpBase.tcpSockfd );
        if ( rbudpSender->rbudpBase.verbose > 1 ) {
            fprintf( stderr, "write %d bytes.\n", ( int ) sizeof( rbudpSender->rbudpBase.endOfUdp ) );
        }
        int error_code = writen( rbudpSender->rbudpBase.tcpSockfd, ( char * )&rbudpSender->rbudpBase.endOfUdp,
                                 sizeof( rbudpSender->rbudpBase.endOfUdp ) );
        if ( error_code < 0 ) {
            rodsLog( LOG_ERROR, "writen failed in sendBuf with error code %d", error_code );
        }
        rbudpSender->rbudpBase.endOfUdp.round ++;

        reportTime( &curTime );
        gettimeofday( &curTime, NULL );
        if ( rbudpSender->rbudpBase.verbose > 1 ) {
            TRACE_DEBUG( "Current time: %d %ld", curTime.tv_sec, curTime.tv_usec );
        }

        // receive error list
        if ( rbudpSender->rbudpBase.verbose > 1 ) {
            TRACE_DEBUG( "waiting for error bitmap" );
        }

        int n = readn( rbudpSender->rbudpBase.tcpSockfd,
                       rbudpSender->rbudpBase.errorBitmap,
                       rbudpSender->rbudpBase.sizeofErrorBitmap );
        if ( n < 0 ) {
            perror( "read" );
            return errno ? ( -1 * errno ) : -1;
        }

        if ( ( unsigned char )rbudpSender->rbudpBase.errorBitmap[0] == 1 ) {
            done = 1;
            rbudpSender->rbudpBase.remainNumberOfPackets = 0;
            if ( rbudpSender->rbudpBase.verbose > 1 ) {
                TRACE_DEBUG( "done." );
            }
        }
        else {
            rbudpSender->rbudpBase.remainNumberOfPackets =
                updateHashTable( &rbudpSender->rbudpBase );
            if ( rbudpSender->rbudpBase.remainNumberOfPackets >=
                    lastRemainNumberOfPackets ) {
                noProgressCnt++;
                if ( noProgressCnt >= MAX_NO_PROGRESS_CNT ) {
                    return SYS_UDP_TRANSFER_ERR - errno;
                }
            }
            else {
                lastRemainNumberOfPackets =
                    rbudpSender->rbudpBase.remainNumberOfPackets;
                noProgressCnt = 0;
            }
        }

        if ( rbudpSender->rbudpBase.isFirstBlast ) {
            rbudpSender->rbudpBase.isFirstBlast = 0;
            double lossRate =
                ( double )rbudpSender->rbudpBase.remainNumberOfPackets /
                ( double )rbudpSender->rbudpBase.totalNumberOfPackets;
            //	if (rbudpSender->rbudpBase.remainNumberOfPackets > 0)
            //	    usecsPerPacket = (int) ((double)usecsPerPacket / (1.0 - lossRate - 0.05));
            if ( rbudpSender->rbudpBase.verbose > 0 ) {
                float dt = ( curTime.tv_sec - startTime.tv_sec )
                           + 1e-6 * ( curTime.tv_usec - startTime.tv_usec );
                float mbps = 1e-6 * 8 * bufSize / ( dt == 0 ? .01 : dt );
                TRACE_DEBUG( "loss rate: %f  on %dK in %.3f seconds (%.2f Mbits/s)",
                             lossRate, ( int )bufSize >> 10, dt, mbps );
                if ( rbudpSender->rbudpBase.verbose > 1 )
                    TRACE_DEBUG( "usecsPerPacket updated to %d",
                                 rbudpSender->rbudpBase.usecsPerPacket );
            }
        }
Ejemplo n.º 8
0
int
Main::mainLoop()
{
  Prof_update(1);
  
  Timer* timer = rPlatform()->createTimer();
  isRunning = true;
  timer->start();

  double delaySleepTrigger = 0.005;
  double latentDelay = 0;
  const double MAGIC_MINIMUM_UPDATE_TIME = 0.005;
  const double MAGIC_UPDATE_TIME_PRIMING = 0.1;
  double updateTime = MAGIC_UPDATE_TIME_PRIMING;
  int focusLostDelay = MAGIC_FOCUS_LOST_DELAY;

  // Fix better lighting ..
  rRenderSystem()->enableSunLight(true);

  // DEBUG
  rGamePlay()->setMission(new Mission());
  setMode(MODE_GAMEPLAY);
//    setMode(MODE_LOCATION_EDITOR);

  render();

  reportTime(timer, "ShortHike startup: ");
  
// #pragma warning(disable: 4127)
//   if(true)
//     return 0;

  //------------------------------------------------------------
  // The delay stuff essentially throttles the update loop to a
  // max of 200FPS. It's a solution to Case 19
  Prof_update(1);
  timer->start();
  setProfiling(true);
  while(isRunning) {
    if(latentDelay >= delaySleepTrigger) {
      Sleep(static_cast<int>(latentDelay * 1000.0));
      latentDelay = 0.0f;
    }
    // fixed updating
    Prof_update(mProfiling);
    
    unsigned long currentTimeMicroS = timer->check(1000000);
    timer->start();
    double timeStep = static_cast<double>(currentTimeMicroS) * 0.000001;
    if(timeStep < MAGIC_MINIMUM_UPDATE_TIME) {
      latentDelay += (MAGIC_MINIMUM_UPDATE_TIME - timeStep);
    }
    
    mFrameTime = timeStep;
    
    rPlatform()->pumpMessages();
    
    if(mIsActive || focusLostDelay > 0) {
      // Only filter the updateTime when we are running
      updateTime = updateTime * 0.90f + timeStep * 0.10f;
      dispatchTime(updateTime);

      focusLostDelay--;

      render();
    }
    if(mIsActive)
      focusLostDelay = MAGIC_FOCUS_LOST_DELAY;

//     if(renderWindow->isClosed())
//       isRunning = false;

    // Forced abort for testing
//    isRunning = false;
  }  

  return 0;
}