示例#1
0
int main(int argc, char *argv[]) {
    struct timeval start, stop;
    string file = argv[1];

    char *l_returnflag = new char[Q1_LINEITEM];
    char *l_linestatus = new char[Q1_LINEITEM];
    float *l_quantity = new float[Q1_LINEITEM];
    float *l_extendedprice = new float[Q1_LINEITEM];
    float *l_discount = new float[Q1_LINEITEM];
    float *l_tax = new float[Q1_LINEITEM];
    long *l_shipdate = new long[Q1_LINEITEM];
    init(file, l_returnflag, l_linestatus, l_quantity, l_extendedprice,
            l_discount, l_tax, l_shipdate);
    unordered_map<short,char *> *vals = new unordered_map<short,char *>();

    test(vals);
    gettimeofday(&start, NULL);
    for (int i = 0; i < Q1_LINEITEM; i++)
        if (pred1(l_shipdate[i])) {
            short key = getKey(l_returnflag[i], l_linestatus[i]);
            char *val = getVal(vals, key, l_returnflag[i], l_linestatus[i]);
            *((int *) (val + 2)) += 1;
            *((float *) (val + 6)) += l_quantity[i];
            *((float *) (val + 10)) += l_extendedprice[i];
            *((float *) (val + 14)) += getPrice(l_extendedprice[i], l_discount[i]);
            *((float *) (val + 18)) += getTax(l_extendedprice[i], l_discount[i], l_tax[i]);
            *((float *) (val + 22)) += l_discount[i];
        }
    gettimeofday(&stop, NULL);
    test(vals);
    printTime("tpch_q1", start, stop);

    delete[] l_returnflag;
    delete[] l_linestatus;
    delete[] l_quantity;
    delete[] l_extendedprice;
    delete[] l_discount;
    delete[] l_tax;
    delete[] l_shipdate;
    delete vals;

    return 0;
}
示例#2
0
int main(int argc, char *argv[]) {
    struct timeval start, stop;
    string file = argv[1];

    float *d = new float[DATA * ATTR];
    float *l = new float[DATA];
    float *w = new float[ATTR];
    float *g = new float[ATTR];
    init(file, d, w, g, l);
    float s[TILE];
    float dots[TILE];

    test(g);
    gettimeofday(&start, NULL);
    for (int i = 0; i < DATA; i += TILE) {
        for (int j = 0; j < TILE; j++) {
            int dOff = (i + j) * ATTR;
            dots[j] = 0.0f;
            for (int k = 0; k < ATTR; k++)
                dots[j] += d[dOff + k] * w[k];
        }
        for (int j = 0; j < TILE; j++) {
            int label = l[i + j];
            s[j] = (1.0f / (1.0f + exp(-label * dots[j])) - 1.0f) * label;
        }
        for (int j = 0; j < TILE; j++) {
            for (int k = 0; k < ATTR; k++) {
                g[k] += s[j] * d[(i + j) * ATTR + k];
            }
        }
    }
    gettimeofday(&stop, NULL);
    test(g);
    printTime("logreg", start, stop);

    delete[] d;
    delete[] l;
    delete[] w;
    delete[] g;

    return 0;
}
int main(int argc, char** argv) {
	Matrix *m1 = NULL, *m2 = NULL, *resultSequential = NULL, *resultParallel = NULL;
	int numParallelTasks = 1;
	struct timeval diff;

	checkArgsSize(argc);
	
	m1 = readMatrixFromFile(M1);
	m2 = readMatrixFromFile(M2);
	 
	checkInputMatrices(m1, m2);
	checkNumTasks(argv, &numParallelTasks, m1);
		
	diff = measureBalanceWork(m1, m2, numParallelTasks, &resultParallel, balanceWork);
	writeMatrixInFile(OUT, resultParallel);
		 	
	printTime("Tempo levado para executar a multiplicação com %d threads: ", numParallelTasks, diff);

	pthread_exit(NULL);
}
示例#4
0
void main( void )
{
// Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  initDisplay();
  clearDisplay();
  printString("Hello Masters");

  while(1) 
  {
  {    
  // insert code here to periodically update the display and update global
  // variables that count seconds, minutes and hours.
  // Suggestion: update the display each time the number of seconds changes.
  // You will need to 'calibrate' the delay loop.
    for (k=0; k<60; k++)
{
	for (j=0;j<60;j++)
	{
		for (i=0;i<60;i++)
		{
			clearDisplay();
                        delay(65535);
			seconds = i;
			
		}
		minutes=j;
	}
	hours=k;
}

  
    
    delay(65535); //this controls rate of counter, 65535 is maximum value of 16bit counter
    counter++;
    printTime(hours, minutes, seconds);
    clearDisplay();
    printDecimal(counter);
  }
  }
}
示例#5
0
文件: FileSpec.cpp 项目: JC5005/GPSTk
   std::string FileSpec::toString(const gpstk::CommonTime& dt,
                                  const FSTStringMap& fstsMap) const
   {
      string toReturn;

         // Go through the list and insert all the non-date elements
         // into the string.  In other words, fill in the string with data
         // from the FSTSMap first.. For date elements, put the FileSpec string
         // directly into the file name (i.e. '%3j').  Then use CommonTime::printf
         // to fill in all the date elements at the end.
      vector<FileSpecElement>::const_iterator fslItr = fileSpecList.begin();
      while (fslItr != fileSpecList.end())
      {
         FSTStringMap::const_iterator fstsItr = fstsMap.find((*fslItr).type);
            // once again, it its found in the map, replace that part of
            // the file spec. otherwise, just put the fixed field in.
         if (fstsItr != fstsMap.end())
         {
               // special case for 'text': just print it
            if ((*fstsItr).first == text)
            {
               toReturn += (*fstsItr).second;
            }
            else
            {
               toReturn += 
                  rightJustify((*fstsItr).second, (*fslItr).numCh, '0');
            }
         }
         else
         {
            toReturn += (*fslItr).field;
         }

         fslItr++;
      }

      toReturn = printTime(dt,toReturn);

      return toReturn;
   }
示例#6
0
int main(int argc, char *argv[]) {
    int *data1 = new int[DATA];
    int *data2 = new int[DATA];
    initData(data1, DATA);
    initData(data2, DATA);

    struct timeval start, stop;
    gettimeofday(&start, NULL);
    vector<int *> res1;
    vector<int *> res2;
    res1.push_back(new int[DATA]);
    res2.push_back(new int[DATA]);
    int pos = 0;
    int *tile1 = data1;
    int *tile2 = data2;
    int bitmap[TILE];
    for (int i = 0; i < TILES; i++) {
        for (int j = 0; j < TILE; j++)
            bitmap[j] = (tile1[j] < PVAR)
                      & (tile2[j] < PMAX);
        for (int j = 0; j < TILE; j++)
            if (bitmap[j]) {
                res1.back()[pos] = tile1[j];
                res2.back()[pos++] = tile2[j];
            }
        tile1 += TILE;
        tile2 += TILE;
    }
    gettimeofday(&stop, NULL);

    printAlgo(__FILE__, PVAR, res1.size());
    printTime(start, stop);

    delete[] data1;
    delete[] data2;
    for (int i = 0; i < res1.size(); i++) {
        delete[] res1[i];
        delete[] res2[i];
    }
    return 0;
}
示例#7
0
int main(void) {
  int snake[300][2],
      len_snake=10,
      pommes[20][2],
      len_pommes=5,
      i;
  unsigned long int temps = Microsecondes();
  initSnake(snake);
  initPommes(pommes);
  
  srand(time(NULL));
  InitialiserGraphique();
  CreerFenetre(BORD,BORD,600+2*BORD,400+BORD+40);

  printTerrain(snake, len_snake, pommes, len_pommes);
  printTime(temps);
    
  Touche();
  FermerGraphique();
  return EXIT_SUCCESS;
}
void MatrixGenerator::parallelOpenMP_CRS(CRS* crs) {
  cout << "Computing CRS... " << flush;
  initializeTime();

  int ckey = 0, 
	  j = 0,
	  chunk = 1000;

  #pragma omp for private(ckey,j) schedule(static,chunk)
  //#pragma omp parallel for
  for (int i=0 ; i<m ; i++){
    for (ckey=crs->rowPtr[i] ; ckey<crs->rowPtr[i+1] ; ckey++) {
		j = crs->colId[ckey];
      resultVector[i] += crs->val[ckey] * multiVector[j];
    }
  }

  cout << "done parallel OpenMP" << endl;
  cout << "->Time elapsed [CRS]: " << endl; //setprecision(6) << elapsedTime << endl;
  printTime();
}
示例#9
0
void 
ClockerListener::printTest( int testIndex,
                            const std::string &indentString ) const
{
  std::string indent = indentString;
  const int indentLength = 3;

  printTestIndent( indentString, indentLength );
  printTime( m_model->testTimeFor( testIndex ) );

  CPPUNIT_NS::stdCOut()  <<  m_model->testPathFor( testIndex ).getChildTest()->getName();
  CPPUNIT_NS::stdCOut()  <<  "\n";

  if ( m_model->childCountFor( testIndex ) == 0 )
    indent+= std::string( indentLength, ' ' );
  else
    indent+= "|" + std::string( indentLength -1, ' ' );

  for ( int index =0; index < m_model->childCountFor( testIndex ); ++index )
    printTest( m_model->childAtFor( testIndex, index ), indent );
}
void MatrixGenerator::algorithmOneCCS(CCS *ccs) {
  cout << "Computing CCS... " << flush;
  // timeval start, stop;
  // gettimeofday(&start, 0);
  initializeTime();

  for (int i=0 ; i<m ; i++){
    for (int j=ccs->colPtr[i] ; j<ccs->colPtr[i+1] ; j++) {
      resultVector[ccs->rowId[j]] += ccs->val[j] * multiVector[i];
    }
  }
  
  // gettimeofday(&stop, 0);
  cout << "done ver. 1" << endl;
  // long seconds = stop.tv_sec - start.tv_sec;
  // long useconds = stop.tv_usec - start.tv_usec;
  // double elapsedTime = (seconds * 1000 + useconds/1000.0) + 0.5;
  cout << "->Time elapsed [CCS]: " << endl;// setprecision(6) << elapsedTime << endl;
  printTime();
  //printResultVector("CCS");
}
示例#11
0
int main(int argc, char *argv[])
{
	initializeDatabase();

	wiringPiSetup();

	printTime();
	printf(LANG_PROGRAM_TITLE);

	while (1) {
		int level = digitalRead(RECIEVE_PIN);

		int bitLength = findEncodedBitLength(level);
		decodeBitLength(bitLength);

		delayMicroseconds(50);

		globalLevelsCounter++;
	}
	return 0;
}
void MatrixGenerator::parallelPthreads_CRS(CRS* crs) {
  cout << "Computing CRS... " << flush;

  pthread_t * threads = new pthread_t[numThreads];
  
  PthreadData * data = new PthreadData();
  data->crs = crs;
  data->resultVector = resultVector;
  data->multiVector = multiVector;
  data->m = m;

  initializeTime();
  for (int i=0 ; i<numThreads ; i++) {
	  data->threadID = i;
	  pthread_create( &threads[i], NULL, algorithmForThread, &data);
  }

  cout << "done parallel Pthreads" << endl;
  cout << "->Time elapsed [CRS]: " << endl; //setprecision(6) << elapsedTime << endl;
  printTime();
}
示例#13
0
void event_clocktick_handle(event_t* event,
			    struct TOS_state* state) {

  event_queue_t* queue = &(state->queue);
  clock_tick_data_t* data = (clock_tick_data_t*)event->data;

  // Viptos: _PTII_NODEID is passed to the preprocessor as a macro definition.
  // Viptos: We assume that there is only one node per TOSSIM.
  //atomic TOS_LOCAL_ADDRESS = (short)(event->mote & 0xffff);
  atomic TOS_LOCAL_ADDRESS = (short)(_PTII_NODEID & 0xffff);

  /*
  if (TOS_LOCAL_ADDRESS != event->mote) {
    dbg(DBG_ERROR, "ERROR in clock tick event handler! Things are probably ver bad....\n");
  }
  */
    
  if (data->valid) {
    if (dbg_active(DBG_CLOCK)) {
      char buf[1024];
      printTime(buf, 1024);
      dbg(DBG_CLOCK, "CLOCK: event handled for mote %i at %s (%i ticks).\n", event->mote, buf, data->interval);
    }

    setTime[NODE_NUM] = tos_state.tos_time;
    event->time = event->time + data->interval;
    queue_insert_event(queue, event);
    if (!data->disabled) {
      TOS_ISSUE_INTERRUPT(SIG_OUTPUT_COMPARE2)();
    }
    else {
      interruptPending[NODE_NUM] = 1;
    }
  }
  else {
    //dbg(DBG_CLOCK, "CLOCK: invalid event discarded.\n");
    
    event_cleanup(event);
  }
}
示例#14
0
void Logger::pop(bool success)
{ 
    if (!parents_.empty())
    {
        Timer timer = timers_.top();
        const string parent = parents_.top();
        const bool interrupt = interrupts_.top();

        timers_.pop();
        parents_.pop();
        interrupts_.pop();

        if (active_)
        {
            if (maxLevel_ < 0 || getCurrentLevel() < maxLevel_)
            {
                if (interrupt) 
                {
                    indent();

                    if (parents_.size() > 0) {
                        cout << " `- ";
                    }

                    cout << parent << " ... ";
                    
                }

                if (success) {
                    cout << getConfirmation() << " ";
                } else {
                    cout << "FAILURE ";
                    exit(EXIT_FAILURE);
                }

                printTime(timer);
            }
        }
    }
}
示例#15
0
HRESULT avsTestDumpLog (void)
{
	uint32 i;
	AVS_LOG * pLog;
	
	cliPrintf ("Time           LO SE SS SO SU RP SL AG IT CG CI DB LP PA SA PHDR     CIP0     CIP1\n\r");
	
	for (i = 0; i < avsLogItems; i++)
	{
		pLog = &avsLog[i];
		printTime(pLog->time);
		cliPrintf ((pLog->avsInt0 & IRQ_ADO1_LOCKED) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt0 & IRQ_ADO1_STREAM_END) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt0 & IRQ_ADO1_STREAM_START) ? "1  " : "   ");
		
		cliPrintf ((pLog->avsInt1 & IRQ_ARXDO1_SYT_OVERFLOW) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt1 & IRQ_ARXDO1_SYT_UNDERFLOW) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt1 & IRQ_ADO1_REPEAT) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt1 & IRQ_ADO1_SLIP) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt1 & IRQ_ADO1_SYT_AGEOUT) ? "1  " : "   ");
		
		cliPrintf ((pLog->avsInt2 & IRQ_ITP_EP_TOO_BIG) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt2 &	IRQ_ARX1_CFG_FAIL) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt2 &	IRQ_ARX1_CIP_FAIL) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt2 &	IRQ_ARX1_DBC_FAIL) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt2 & IRQ_ARX1_LONG_PKT) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt2 & IRQ_ARX1_PKT_ABORT) ? "1  " : "   ");
		cliPrintf ((pLog->avsInt2 & IRQ_ARX1_STATUS_ERR) ? "1  " : "   ");
		
		cliPrintf ("%08X ",pLog->phdr);
		cliPrintf ("%08X ",pLog->cip0);
		cliPrintf ("%08X ",pLog->cip1);
//		if (i)
//		{
//			printTime(pLog->time - avsLog[i-1].time);
//		}
		cliPrintf ("\n\r");
	}
	return NO_ERROR;
}	
示例#16
0
int main(int argc, char *argv[]) {
    struct timeval start, stop;
    string file1 = argv[1];
    string file2 = argv[2];

    int *o_orderkey = new int[Q4_ORDERS];
    long *o_orderdate = new long[Q4_ORDERS];
    char *o_orderpriority = new char[Q4_ORDERS];
    int *l_orderkey = new int[Q4_LINEITEM];
    long *l_commitdate = new long[Q4_LINEITEM];
    long *l_receiptdate = new long[Q4_LINEITEM];
    init(file1, file2, o_orderkey, o_orderdate, o_orderpriority, l_orderkey,
            l_commitdate, l_receiptdate);
    unordered_set<int> *exists = new unordered_set<int>();
    unordered_map<char,int> *vals = new unordered_map<char,int>();

    test(vals);
    gettimeofday(&start, NULL);
    for (int i = 0; i < Q4_LINEITEM; i++)
        if (l_commitdate[i] < l_receiptdate[i])
            exists->insert(l_orderkey[i]);
    for (int i = 0; i < Q4_ORDERS; i++)
        if (o_orderdate[i] >= Q4_DATE1 && o_orderdate[i] < Q4_DATE2)
            if (exists->find(o_orderkey[i]) != exists->end())
                (*vals)[o_orderpriority[i]]++;
    gettimeofday(&stop, NULL);
    test(vals);
    printTime("tpch_q4", start, stop);

    delete[] o_orderkey;
    delete[] o_orderdate;
    delete[] o_orderpriority;
    delete[] l_orderkey;
    delete[] l_commitdate;
    delete[] l_receiptdate;
    delete exists;
    delete vals;

    return 0;
}
示例#17
0
void *binomialOption(void *n)
{
	gmactime_t s, t;
	ecl_error ret = eclSuccess;
	int offset = *(int *)n * numSamples;
	/*cl_float* output_thread = NULL;
	assert(eclMalloc((void **)&output_thread, numSamples * sizeof(cl_float4)) == eclSuccess);*/

	getTime(&s);
	ecl_kernel kernel;
	ret = eclGetKernel("binomial_options", &kernel);
	assert(ret == eclSuccess);	
	ret = eclSetKernelArg(kernel, 0, sizeof(numSteps), &numSteps);
	assert(ret == eclSuccess);	
	ret = eclSetKernelArgPtr(kernel, 1, randArray);
	assert(ret == eclSuccess);	
	ret = eclSetKernelArgPtr(kernel, 2, output);
	assert(ret == eclSuccess);	
	//assert(eclSetKernelArgPtr(kernel, 2, output_thread) == eclSuccess);
	ret = eclSetKernelArg(kernel, 3, (numSteps + 1) * sizeof(cl_float4), NULL);
	assert(ret == eclSuccess);	
	ret = eclSetKernelArg(kernel, 4, numSteps * sizeof(cl_float4), NULL);
	assert(ret == eclSuccess);	
	ret = eclSetKernelArg(kernel, 5, sizeof(offset), &offset);
	assert(ret == eclSuccess);

	size_t globalThreads[] = {numSamples * (numSteps + 1)};
	size_t localThreads[] = {numSteps + 1};
	ret = eclCallNDRange(kernel, 1, NULL, globalThreads, localThreads);
	assert(ret == eclSuccess);	
	getTime(&t);
	printTime(&s, &t, "Run: ", "\n");
	//eclMemcpy(&output[offset], output_thread, numSamples * sizeof(cl_float4));

	ret = eclReleaseKernel(kernel);
	assert(ret == eclSuccess);
	//assert(eclFree(output_thread) == eclSuccess);

	return NULL;
}
示例#18
0
int main(int argc, char *argv[]) {
    int *data1 = new int[DATA];
    initData(data1, DATA);

    struct timeval start, stop;
    gettimeofday(&start, NULL);
    vector<int *> res1;
    res1.push_back(new int[DATA]);
    int pos = 0;
    for (int i = 0; i < DATA; i++)
        if (data1[i] < PVAR)
            res1.back()[pos++] = data1[i];
    gettimeofday(&stop, NULL);

    printAlgo(__FILE__, PVAR, res1.size());
    printTime(start, stop);

    delete[] data1;
    for (int i = 0; i < res1.size(); i++)
        delete[] res1[i];
    return 0;
}
示例#19
0
/** outputs a new global upper bound to the visualization output file */
void SCIPvisualUpperbound(
   SCIP_VISUAL*          visual,             /**< visualization information */
   SCIP_SET*             set,                /**< global SCIP settings */
   SCIP_STAT*            stat,               /**< problem statistics */
   SCIP_Real             upperbound          /**< new upper bound */
   )
{
   assert( visual != NULL );

   /* check, if VBC output should be created */
   if( visual->vbcfile == NULL )
      return;

   /* determine external upper bound */
   if ( set->visual_objextern )
      upperbound = SCIPretransformObj(set->scip, upperbound);

   printTime(visual, stat, TRUE);
   SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "U %f\n", upperbound);

   /* do nothing for BAK */
}
void MatrixGenerator::parallelMPI_CRS(CRS* crs) {
  cout << "Computing CRS... " << flush;
  initializeTime();

  // int  numTasks, rank, rc;
  // MPI_Status status;
  // MPI_Request req, req1;
  // rc = MPI_Init(&argc,&argv);
  // int tab[2010];
  // int recvbuf[1005];
  // int messageToSent = 10;
  // int messageToRespond = 20;
  
  // MPI_Comm_size(MPI_COMM_WORLD,&numTasks);
  // MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  // printf ("Process count = %d Process ID = %d\n", numTasks,rank);

  // int index = n/numTasks;
  
  // // odpowiednie rozesłanie danych
  // MPI_Bcast(crs,index,MPI_INT,recvbuf,index,MPI_INT,0,MPI_COMM_WORLD);
  
  for (int i=0 ; i<m ; i++){
    for (int j=crs->rowPtr[i] ; j<crs->rowPtr[i+1] ; j++) {
      resultVector[i] += crs->val[j] * multiVector[crs->colId[j]];
    }
  }
  
  // MPI_Gather(&recvbuf[0],1,MPI_INT,tab,1,MPI_INT,0,MPI_COMM_WORLD);
  
  
  // MPI_Barrier(MPI_COMM_WORLD);
  // MPI_Finalize ( );

  cout << "done parallel MPI" << endl;
  cout << "->Time elapsed [CRS]: " << endl; //setprecision(6) << elapsedTime << endl;
  printTime();
}
示例#21
0
FileTransferDlg::FileTransferDlg(FileMessage *msg)
        : FileTransferBase(NULL, "filetransfer", false, WDestructiveClose)
{
    m_msg = msg;
    SET_WNDPROC("filetransfer")
    setIcon(Pict("file"));
    setButtonsPict(this);
    setCaption((msg->getFlags() & MESSAGE_RECEIVED) ? i18n("Receive file") : i18n("Send file"));
	if (msg->getFlags() & MESSAGE_RECEIVED)
		m_dir = m_msg->m_transfer->dir();
    disableWidget(edtTime);
    disableWidget(edtEstimated);
    disableWidget(edtSpeed);
	btnGo->hide();
	btnGo->setIconSet(*Icon("file"));
    msg->m_transfer->setNotify(new FileTransferDlgNotify(this));
    sldSpeed->setValue(m_msg->m_transfer->speed());
    connect(sldSpeed, SIGNAL(valueChanged(int)), this, SLOT(speedChanged(int)));
    m_time  = 0;
    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
    m_timer->start(1000);
    printTime();
    m_bTransfer = false;
    m_transferTime = 0;
    m_speed     = 0;
    m_nAverage  = 0;
    m_files		= 0;
    m_bytes		= 0;
    m_fileSize	= 0;
    m_totalBytes = 0;
    m_totalSize	= 0;
    m_state = FileTransfer::Unknown;
    connect(btnCancel, SIGNAL(clicked()), this, SLOT(close()));
    chkClose->setChecked(CorePlugin::m_plugin->getCloseTransfer());
    connect(chkClose, SIGNAL(toggled(bool)), this, SLOT(closeToggled(bool)));
	connect(btnGo, SIGNAL(clicked()), this, SLOT(goDir()));
}
示例#22
0
int main(int argc, char *argv[]) {
    struct timeval start, stop;
    string file = argv[1];

    float *l_quantity = new float[Q6_LINEITEM];
    float *l_extendedprice = new float[Q6_LINEITEM];
    float *l_discount = new float[Q6_LINEITEM];
    long *l_shipdate = new long[Q6_LINEITEM];
    init(file, l_quantity, l_extendedprice, l_discount, l_shipdate);
    float revenue = 0.0f;
    int bitmap[TILE];

    test(revenue);
    gettimeofday(&start, NULL);
    for (int i = 0; i < Q6_LINEITEM; i += TILE) {
        for (int j = 0; j < TILE; j++)
            bitmap[j] = l_shipdate[i + j] >= Q6_DATE1
                      * l_shipdate[i + j] < Q6_DATE2;
        for (int j = 0; j < TILE; j++)
            bitmap[j] *= l_discount[i + j] >= 0.05f
                       * l_discount[i + j] <= 0.07f;
        for (int j = 0; j < TILE; j++)
            bitmap[j] *= l_quantity[i + j] < 24.0f;
        for (int j = 0; j < TILE; j++)
            if (bitmap[j])
                revenue += l_extendedprice[i + j] * l_discount[i + j];
    }
    gettimeofday(&stop, NULL);
    test(revenue);
    printTime("tpch_q6_mk7", start, stop);

    delete[] l_quantity;
    delete[] l_extendedprice;
    delete[] l_discount;
    delete[] l_shipdate;

    return 0;
}
示例#23
0
void drawChooseMood(void){
	
	currentMenuLength = moodArrSize;
	uint8_t index = 0;
	uint8_t menuPage = 0;
	uint8_t totalPages = 0;
	
	char moodString[18];
	
	
	printTime();
	printStringOnLine(1,"   Choose Mood    ", 1,NONE);
	
	for (uint8_t i = 0; i < cellsPerFrame; i++){
		memset(moodString,0,sizeof(moodString));
		totalPages = ((currentMenuLength-1)/cellsPerFrame);
		menuPage = (selectionInMenu/cellsPerFrame);	
		index = ((menuPage)*cellsPerFrame)+i;
		
		if(index < currentMenuLength){
			snprintf(moodString, sizeof(moodString), "%s%s%s", " ", moodArray[index], "                  ");
			moodString[17] = ' ';
		}

		drawMenuBands(menuPage,totalPages,TOPBAND);			
				
		//Draw Menu Contents
		if (i == selectionInFrame)
			printStringOnLine(i+yOffset,moodString, 1,NOBOXMENU);
		else if (index < currentMenuLength)
			printStringOnLine(i+yOffset,moodString, 0,NOBOXMENU);
		else
			printStringOnLine(i+yOffset,"                  ", 0,NOBOXMENU);
			
		drawMenuBands(menuPage,totalPages,BOTTOMBAND);	
			
	}				
}
示例#24
0
void decodePluviometer()
{
	if (encodedBits[9] && encodedBits[10] && !encodedBits[11]
	    && encodedBits[12] && encodedBits[13] && !encodedBits[14]
	    && !encodedBits[15]) {
		unsigned int rain = 0;
		int i;
		for (i = 16; i < 32; i++) {
			rain |= encodedBits[i] << (i - 16);
		}

		printTime();
		float rainFinal = (float)rain / 4;
		printf(LANG_INFO_PLUVIOMETER, (float)rainFinal);
		savePluviometer(rainFinal);

		if (encodedBits[8]) {
			printf(LANG_BATTERY_REPLACE);
		} else {
			printf(LANG_BATTERY_OK);
		}
	}
}
示例#25
0
/** changes the color of the node to the given color */
static
void vbcSetColor(
   SCIP_VBC*             vbc,                /**< VBC information */
   SCIP_STAT*            stat,               /**< problem statistics */
   SCIP_NODE*            node,               /**< node to change color for */
   SCIP_VBCCOLOR         color               /**< new color of node, or SCIP_VBCCOLOR_NONE */
   )
{
   assert(vbc != NULL);
   assert(node != NULL);

   if( vbc->file != NULL && color != SCIP_VBCCOLOR_NONE && (node != vbc->lastnode || color != vbc->lastcolor) )
   {
      size_t nodenum;

      nodenum = (size_t)SCIPhashmapGetImage(vbc->nodenum, node);
      assert(nodenum > 0);
      printTime(vbc, stat);
      SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "P %d %d\n", (int)nodenum, color);
      vbc->lastnode = node;
      vbc->lastcolor = color;
   }
}
示例#26
0
void drawSettings(void){
	currentMenuLength = sizeof(settingsArray)/sizeof(settingsArray[0]);
	uint8_t index = 0;
	uint8_t menuPage = 0;
	uint8_t totalPages = 0;
	
	char settingsString[18];
	memset(settingsString,0,sizeof(settingsString));
	
	printTime();
	printStringOnLine(1,"    Main Menu     ", 1,NONE);
	
	for (uint8_t i = 0; i < cellsPerFrame; i++){
		totalPages = ((currentMenuLength-1)/cellsPerFrame);
		menuPage = (selectionInMenu/cellsPerFrame);	
		index = (menuPage*cellsPerFrame)+i;
		
		if (index < currentMenuLength){
 			snprintf(settingsString, sizeof(settingsString), "%s%s%s", " ", settingsArray[index], "                  ");
			settingsString[17] = ' ';
		}
		
		drawMenuBands(menuPage,totalPages,TOPBAND);
				
		//Draw Menu Contents
		if (i == selectionInFrame)
			printStringOnLine(i+yOffset,settingsString, 1,NOBOXMENU);
		else if (index < currentMenuLength)
			printStringOnLine(i+yOffset,settingsString, 0,NOBOXMENU);
		else
			printStringOnLine(i+yOffset,"                  ", 0,NOBOXMENU);
			
		drawMenuBands(menuPage,totalPages,BOTTOMBAND);	
			
	}		
}
示例#27
0
int main(int argc, char** argv) {
    char systime[SIZE];
    char icutime[SIZE];
    int year, month, day, hour, minute;
    int sysyear;
    int useCurrentTime;
    int64_t systemtime;
    
    sysyear = year = month = day = 0;
    
    if (argc <= 6) {
        fprintf(stderr, "Not enough arguments\n");
        return -1;
    }

    year = atoi(argv[1]);
    month = atoi(argv[2]);
    day = atoi(argv[3]);
    hour = atoi(argv[4]);
    minute = atoi(argv[5]);
    useCurrentTime = atoi(argv[6]);
    
    /* format year for system time */
    sysyear = year - 1900;
    
    systemtime = getSystemCurrentTime(systime, sysyear, month, day, hour, minute, useCurrentTime);
    getICUCurrentTime(icutime, systemtime * U_MILLIS_PER_SECOND);

    /* print out the times if failed */
    if (strcmp(systime, icutime) != 0) {
        printf("Failed\n");
        printTime(systime, icutime);
    }

    return 0;
}
示例#28
0
void debug(Stream &in, Print& out) {
  int command = in.read();
  switch(command) {
  
  case 'D':
    setDateFromStream(in, out);
  case 'd':
    printDate(out);
    break;
  case 'T':
    setTimeFromStream(in, out);
  case 't':
    printTime(out);
    break;
  case 'e':
    out.println("Exit");
    CLEAR_FLAG(mode, DEBUG_FLAG);
    break;
  default:
    if(command > ' ') {
      out.println("Invalid command"); 
    }
  }
}
void VerilatedVcd::dumpPrep (vluint64_t timeui) {
    printStr("#");
    printTime(timeui);
    printStr("\n");
}
示例#30
0
//----------------------------------------------------------------------------
// The main program function
//
void calcAndPrint(CalData& cd)
{
    // calc. start and end days
    //
    long jd_start = DateOps::dmyToDay( 1, cd.month, cd.year );
    long jd_end = ( cd.month < 12 ) ?
                  DateOps::dmyToDay( 1, cd.month + 1, cd.year ) :
                  DateOps::dmyToDay( 1, 1, cd.year + 1 );

    int end = int(jd_end - jd_start);

    // fill in data for month in question
    //
    TimePair sunRS[DAYS], moonRS[DAYS], astTwi[DAYS];
    double jd[DAYS];
    static const double hourFraction = 1./24.;

    double tzAdj = (double)cd.loc.timeZone() * hourFraction;
    long dstStart = DateOps::dstStart( cd.year );
    long dstEnd = DateOps::dstEnd( cd.year );

#if defined( PROGRESS_BAR )
    fprintf( stderr, "working" );
#endif

    for( int i=0; i<=end+1; i++ )
    {
        long day = jd_start + i;

        // automatically adjust for DST if enabled
        // This 'rough' method will be off by one on moon rise/set between
        //   midnight and 2:00 on "clock change" days. (sun & astTwi never
        //   occur at these times.)
        //
        double dstAdj =
            ( false == g_ignoreDst && day>=dstStart && day<dstEnd) ?
            hourFraction : 0.;

        jd[i] = (double)day - (tzAdj + dstAdj) - .5;

        // calculate rise/set times for the sun
        RiseSet::getTimes( sunRS[i], RiseSet::SUN, jd[i], cd.loc );

        // calculate rise/set times for Astronomical Twilight
        RiseSet::getTimes( astTwi[i], RiseSet::ASTRONOMICAL_TWI, jd[i], cd.loc );

        // calculate rise/set time for Luna )
        RiseSet::getTimes( moonRS[i], RiseSet::MOON, jd[i], cd.loc );

#if defined( PROGRESS_BAR )
        fputc( '.', stderr );
#endif
    }
    fputc( '\n', stderr );

    printHeading(cd);

    // print data for each day
    //
    char buf[256];
    for( int i=0; i<end; i++ ) {

        if (g_html) {
            if ( !(i&1) )
                fprintf( g_fp, "<TR CLASS=\"bar\">\n  <TD>" );
            else
                fprintf( g_fp, "<TR>\n  <TD>" );
        }

        // print day
        char* p = printDay( buf, jd_start, i, false );

        // print darkest hours
        p = printDarkness(p, i, astTwi, moonRS);

        // check for lunar & solar quarters and DST, print if found
        DST dstDay = DST_NONE;
        if ( dstStart == jd_start+i )
            dstDay = DST_START;
        else if ( dstEnd == jd_start+i )
            dstDay = DST_END;

        p = printEvents(p, i, jd, cd.loc, dstDay);

        // print rise/set times for Luna
        p = printTime( p, moonRS[i].TP_RISE );
        p = printTime( p, moonRS[i].TP_SET );

        // print set time for the sun
        p = printTime( p, sunRS[i].TP_SET );

        // print end of Astronomical Twilight */
        p = printTime( p, astTwi[i].TP_END );

        // next day
        p = printDay( p, jd_start, i+1, i == end-1 );
        if (!g_tabDelimited && !g_html)
            *p++ = ' ';

        // print start of Astronomical Twilight */
        p = printTime( p, astTwi[i+1].TP_START );

        // print rise time for the sun     (last column)
        p = printTime( p, sunRS[i+1].TP_RISE, false );

        if (g_html)
            strcpy( p, "</TD>\n</TR>\n" );
        else {
            *p++ = '\n';
            *p = 0;
        }

        fputs( buf, g_fp );
    }
    if (g_html)
        fputs( "</TABLE>\n</BODY>\n</HTML>\n", g_fp );
}