Ejemplo n.º 1
0
//===========================================================================
int CEyeTrack::ParseBuffer( int nFrames,
                             void * pvSrcBuffer,
                             double * pdTimeStamps, 
                             double * pdCoord ){

  IScanFrameStruct * pFrame;
  int i;
  double dRawX, dRawY, dX, dY;

  pFrame = (IScanFrameStruct *) pvSrcBuffer;
  for( i = 0; i < nFrames; i++ ) {

    CalcTime( pFrame->iFrame, pdTimeStamps);
    pdTimeStamps++;

    dRawX = pFrame->iRawX;;
    dRawY = pFrame->iRawY;
    TransformCoordinates( dRawX, dRawY, &dX, &dY );
    *pdCoord++ = dX;
    *pdCoord++ = dY;

    pFrame++;
  }

  return 0;
}
Ejemplo n.º 2
0
/*      returns 1 for automatic mode, gearswitch position 0                  */
bit ModeCheck(void) {
    NOP();
    time_gear = CalcTime();
    if(time_gear < GEAR_TIME){
        /* Manual Mode */
        LED = 0;
        ManNAut = 1;
        set_ret = 0;
    }else if(time_gear >= GEAR_TIME) {
        LED = 1;
        ManNAut = 0;
        set_ret = 1;
    }
    NOP();
    return set_ret;
}
Ejemplo n.º 3
0
EMMediaDataBuffer* EMVideoClipMixer::ProcessBufferE(list<EMMediaDataBuffer*>* p_opBufferList)
{
	int i;
	unsigned char *pPtrSrc1;
	unsigned char *pPtrSrc2;
	unsigned char *pPtrDst;
	float vScale;
	float vScale2;

	if(p_opBufferList -> size() != 2)
		return NULL;

	EMMediaDataBuffer* opSource = p_opBufferList -> front();
	p_opBufferList -> pop_front();

	EMMediaDataBuffer* opTarget = p_opBufferList -> front();
	p_opBufferList -> pop_front();

	if(m_vSwap)
	{
		swap(opTarget, opSource);
	}

	uint64 vMax = opTarget -> m_vSizeUsed;

	pPtrSrc1 = static_cast<unsigned char *>(opSource->Data());
	pPtrSrc2 = static_cast<unsigned char *>(opTarget->Data());

	pPtrDst  = static_cast<unsigned char *>(opSource->BackBuffer());

	vScale2 = CalcTime(opSource); // -> GetRelativeTimeToStart());
	vScale = 1.0f - vScale2;

	for (i = 0; i < vMax; ++i, ++pPtrSrc1, ++pPtrSrc2, ++pPtrDst)
	{
		*pPtrDst = vScale * static_cast<float>(*pPtrSrc1) + vScale2 * static_cast<float>(*pPtrSrc2);
	}

	opTarget -> Recycle();

	opSource -> m_opDestination = EMBufferDestination::GetDestination();

	opSource -> SwapBuffer();

	return opSource;
}
Ejemplo n.º 4
0
int
main(int argc, char* argv[])
{

  bool LongFlag=false;
  bool HierFlag=true;
  int ResetUsage=0;
  int DeleteUser=0;
  int SetFactor=0;
  int SetPrio=0;
  int SetAccum=0;
  int SetBegin=0;
  int SetLast=0;
  bool ResetAll=false;
  int GetResList=0;
  std::string pool;
  bool GroupRollup = false;

  myDistro->Init( argc, argv );
  config();

  MinLastUsageTime=time(0)-60*60*24;  // Default to show only users active in the last day

  for (int i=1; i<argc; i++) {
    if (IsArg(argv[i],"setprio")) {
      if (i+2>=argc) usage(argv[0]);
      SetPrio=i;
      i+=2;
    }
    else if (IsArg(argv[i],"setfactor")) {
      if (i+2>=argc) usage(argv[0]);
      SetFactor=i;
      i+=2;
    }
    else if (IsArg(argv[i],"setbegin")) {
      if (i+2>=argc) usage(argv[0]);
      SetBegin=i;
      i+=2;
    }
    else if (IsArg(argv[i],"setaccum")) {
      if (i+2>=argc) usage(argv[0]);
      SetAccum=i;
      i+=2;
    }
    else if (IsArg(argv[i],"setlast")) {
      if (i+2>=argc) usage(argv[0]);
      SetLast=i;
      i+=2;
    }
    else if (IsArg(argv[i],"resetusage")) {
      if (i+1>=argc) usage(argv[0]);
      ResetUsage=i;
      i+=1;
    }
    else if (IsArg(argv[i],"delete",3)) {
      if (i+1>=argc) usage(argv[0]);
      DeleteUser=i;
      i+=1;
    }
    else if (IsArg(argv[i],"resetall")) {
      ResetAll=true;
    }
    else if (IsArg(argv[i],"long",1)) {
      LongFlag=true;
    }
    else if (IsArg(argv[i],"hierarchical",2) || IsArg(argv[i],"heir")) {
      HierFlag=true;
      DashHier=true;
    }
    else if (IsArg(argv[i],"flat",2)) {
      HierFlag=false;
      DashHier=true;
    }
    else if (IsArg(argv[i],"grouprollup")) {
      GroupRollup=true;
    }
    else if (IsArg(argv[i],"grouporder")) {
      GroupOrder=true;
      HierFlag = false;
      DashHier = true;
    }
    else if (IsArg(argv[i],"quotas",1)) {
      DetailFlag |= DetailQuotas;
      DashQuota = true;
    }
    else if (IsArg(argv[i],"surplus")) {
      DetailFlag |= DetailSurplus;
      DashQuota = true;
    }
    else if (IsArg(argv[i],"sortkey",2)) {
      DetailFlag |= DetailSortKey;
      DashSortKey = true;
    }
    else if (IsArg(argv[i],"all")) {
      DetailFlag |= DetailAll;
      DashAll = true;
    }
    else if (IsArg(argv[i],"most",2)) {
      DetailFlag |= DetailMost;
#ifdef DEBUG
      DetailFlag |= DetailGroup;
#endif
      DashAll = true;
    }
    else if (IsArg(argv[i],"groupid")) {
      DetailFlag |= DetailGroup;
    }
    else if (IsArg(argv[i],"order")) {
      DetailFlag |= DetailOrder;
    }
    else if (IsArg(argv[i],"activefrom")) {
      if (argc-i<=3) usage(argv[0]);
      int month=atoi(argv[i+1]);
      int day=atoi(argv[i+2]);
      int year=atoi(argv[i+3]);
      MinLastUsageTime=CalcTime(month,day,year);
      // printf("Date translation: %d/%d/%d = %d\n",month,day,year,FromDate);
      i+=3;
    }
    else if (IsArg(argv[i],"allusers")) {
      MinLastUsageTime=-1;
    }
    else if (IsArg(argv[i],"usage",2)) {
      DetailFlag |= DetailUsage | DetailUseTime1 | DetailUseTime2;
    }
    else if (IsArg(argv[i],"priority",4)) {
      DetailFlag |= DetailPrios;
    }
    else if (IsArg(argv[i],"getreslist",6)) {
      if (argc-i<=1) usage(argv[0]);
      GetResList=i;
      i+=1;
    }
    else if (IsArg(argv[i],"pool",1)) {
      if (argc-i<=1) usage(argv[0]);
      pool = argv[i+1];
      i++;
	}
    else {
      usage(argv[0]);
    }
  }
      
  //----------------------------------------------------------

	  // Get info on our negotiator
  Daemon negotiator(DT_NEGOTIATOR, NULL, (pool != "") ? pool.c_str() : NULL);
  if (!negotiator.locate()) {
	  fprintf(stderr, "%s: Can't locate negotiator in %s\n", 
              argv[0], (pool != "") ? pool.c_str() : "local pool");
	  exit(1);
  }

  if (SetPrio) { // set priority

    char* tmp;
	if( ! (tmp = strchr(argv[SetPrio+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the priority of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}
    float Priority=atof(argv[SetPrio+2]);

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(SET_PRIORITY,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[SetPrio+1]) ||
        !sock->put(Priority) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send SET_PRIORITY command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The priority of %s was set to %f\n",argv[SetPrio+1],Priority);

  }

  else if (SetFactor) { // set priority

    char* tmp;
	if( ! (tmp = strchr(argv[SetFactor+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the priority of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}
    float Factor=atof(argv[SetFactor+2]);
	if (Factor<1) {
		fprintf( stderr, "Priority factors must be greater than or equal to "
				 "1.\n");
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(SET_PRIORITYFACTOR,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[SetFactor+1]) ||
        !sock->put(Factor) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send SET_PRIORITYFACTOR command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The priority factor of %s was set to %f\n",argv[SetFactor+1],Factor);

  }

  else if (SetAccum) { // set accumulated usage

    char* tmp;
	if( ! (tmp = strchr(argv[SetAccum+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the Accumulated usage of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}
    float accumUsage=atof(argv[SetAccum+2]);
	if (accumUsage<0.0) {
		fprintf( stderr, "Usage must be greater than 0 seconds\n");
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(SET_ACCUMUSAGE,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[SetAccum+1]) ||
        !sock->put(accumUsage) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send SET_ACCUMUSAGE command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The Accumulated Usage of %s was set to %f\n",argv[SetAccum+1],accumUsage);

  }
  else if (SetBegin) { // set begin usage time

    char* tmp;
	if( ! (tmp = strchr(argv[SetBegin+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the begin usage time of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}
    int beginTime=atoi(argv[SetBegin+2]);
	if (beginTime<0) {
		fprintf( stderr, "Time must be greater than 0 seconds\n");
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(SET_BEGINTIME,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[SetBegin+1]) ||
        !sock->put(beginTime) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send SET_BEGINTIME command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The Begin Usage Time of %s was set to %d\n",
			argv[SetBegin+1],beginTime);

  }
  else if (SetLast) { // set last usage time

    char* tmp;
	if( ! (tmp = strchr(argv[SetLast+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the last usage time of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}
    int lastTime=atoi(argv[SetLast+2]);
	if (lastTime<0) {
		fprintf( stderr, "Time must be greater than 0 seconds\n");
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(SET_LASTTIME,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[SetLast+1]) ||
        !sock->put(lastTime) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send SET_LASTTIME command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The Last Usage Time of %s was set to %d\n",
			argv[SetLast+1],lastTime);

  }
  else if (ResetUsage) { // set priority

    char* tmp;
	if( ! (tmp = strchr(argv[ResetUsage+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the priority of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(RESET_USAGE,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[ResetUsage+1]) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send RESET_USAGE command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The accumulated usage of %s was reset\n",argv[ResetUsage+1]);

  }

  else if (DeleteUser) { // remove a user record from the accountant

    char* tmp;
	if( ! (tmp = strchr(argv[DeleteUser+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the record you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto delete (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(DELETE_USER,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[DeleteUser+1]) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send DELETE_USER command to negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    printf("The accountant record named %s was deleted\n",argv[DeleteUser+1]);

  }

  else if (ResetAll) {

    // send request
    if( ! negotiator.sendCommand(RESET_ALL_USAGE, Stream::reli_sock, 0) ) {
		fprintf( stderr, 
				 "failed to send RESET_ALL_USAGE command to negotiator\n" );
		exit(1);
    }

    printf("The accumulated usage was reset for all users\n");

  }

  else if (GetResList) { // get resource list

    char* tmp;
	if( ! (tmp = strchr(argv[GetResList+1], '@')) ) {
		fprintf( stderr, 
				 "%s: You must specify the full name of the submittor you wish\n",
				 argv[0] );
		fprintf( stderr, "\tto update the priority of (%s or %s)\n", 
				 "*****@*****.**", "*****@*****.**" );
		exit(1);
	}

    // send request
    Sock* sock;
    if( !(sock = negotiator.startCommand(GET_RESLIST,
										 Stream::reli_sock, 0) ) ||
        !sock->put(argv[GetResList+1]) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to send GET_RESLIST command to negotiator\n" );
      exit(1);
    }

    // get reply
    sock->decode();
    AttrList* ad=new AttrList();
    if (!ad->initAttrListFromStream(*sock) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to get classad from negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    if (LongFlag) ad->fPrint(stdout);
    else PrintResList(ad);
  }

  else {  // list priorities

    Sock* sock;
    if (!(sock = negotiator.startCommand((GroupRollup) ? GET_PRIORITY_ROLLUP : GET_PRIORITY, Stream::reli_sock, 0)) ||
        !sock->end_of_message()) {
        fprintf(stderr, "failed to send %s command to negotiator\n", (GroupRollup) ? "GET_PRIORITY_ROLLUP" : "GET_PRIORITY");
        exit(1);
    }

    // get reply
    sock->decode();
    AttrList* ad=new AttrList();
    if (!ad->initAttrListFromStream(*sock) ||
        !sock->end_of_message()) {
      fprintf( stderr, "failed to get classad from negotiator\n" );
      exit(1);
    }

    sock->close();
    delete sock;

    // if no details specified, show priorities
    if ( ! DetailFlag) {
       DetailFlag = DetailDefault;
#ifdef DEBUG
       DetailFlag |= DetailGroup;
#endif
    }
    // if showing only prio, don't bother showing groups 
    if ( ! (DetailFlag & ~DetailPrios) && GroupPrioIsMeaningless) {
       if ( ! DashHier ) HierFlag = false;
       HideGroups = !HierFlag;
    }

    if (LongFlag) ad->fPrint(stdout);
    else ProcessInfo(ad,GroupRollup,HierFlag);
  }

  exit(0);
  return 0;
}
Ejemplo n.º 5
0
//calculates C = alpha * AB + beta * C
void testsize(int M, int K, int N) {

    float * A = (float*) malloc(sizeof(float) * M * K);
    float * B = (float*) malloc(sizeof(float) * K * N);
    float * C = (float*) malloc(sizeof(float) * M * N);
    float * C2 = (float*) malloc(sizeof(float) * M * N);
    float * C3 = (float*) malloc(sizeof(float) * M * N);


    for(int m = 0; m < M; m++) {
        for(int k = 0; k < K; k++) {
            A[m*K + k] = rand() % 10;
        }
    }
    int i = 0;
    for(int k = 0; k < K; k++) {
        for(int n = 0; n < N; n++) {
            B[k*N + n] = rand() % 10;
        }
    }

    for(int i = 0; i < M *N; i++)
        C[i] = C2[i] = C3[i] = 0;


    int times = 0;
    double blastime;
    while(CalcTime(&times,&blastime))
        cblas_sgemm(CblasRowMajor, CblasNoTrans,CblasNoTrans, M,N,K,1.f,A,K,B,N,0.f,C,N);
    //naive_dgemm(M,N,K,1.f,A,K,B,N,0.f,C,N);
    //float begin2 = CurrentTimeInSeconds();
    //naive_dgemm(CblasRowMajor, CblasNoTrans,CblasNoTrans, M,N,K,1.f,A,K,B,N,0.f,C2,N);

    double mytime;
    times = 0;
    while(CalcTime(&times,&mytime)) {
        my_sgemm(CurrentTimeInSeconds,M,N,K,1.f,A,K,B,N,0.f,C3,N);
        //for(int i = 0; i < M*N; i++)
        //	C3[i] = 0;
        //sgemm_terra_32x32(A,B,C3);
    }
    /*
    for(int m = 0; m < M; m++) {
    	for(int n = 0; n < N; n++) {
    		printf("%f ",C[m*N + n]);
    	}
    	printf("\n");
    }
    printf("\n\n");

    for(int m = 0; m < M; m++) {
    	for(int n = 0; n < N; n++) {
    		printf("%f ",C3[m*N + n]);
    	}
    	printf("\n");
    }*/

    //asserteq(C,C2,M,N);
    asserteq(C,C3,M,N);

    free(C);
    free(C2);
    free(C3);
    free(A);
    free(B);
    double logblastime = log(M) + log(N) + log(K) + log(2) + log(1e-9) - log(blastime);
    double logmytime = log(M) + log(N) + log(K) + log(2) + log(1e-9) - log(mytime);
    printf("%d %d %d %f %f %f\n",M,K,N,exp(logblastime),exp(logmytime), mytime/ blastime);
}