Exemple #1
0
int main(int argc, const char **argv)
{
  int srcAlloc;
  unsigned int *srcBuffer = 0;

  MemreadRequestProxy *device = 0;
  DmaConfigProxy *dmap = 0;
  
  MemreadIndication *deviceIndication = 0;
  DmaIndication *dmaIndication = 0;

  fprintf(stderr, "Main::%s %s\n", __DATE__, __TIME__);

  device = new MemreadRequestProxy(IfcNames_MemreadRequest);
  dmap = new DmaConfigProxy(IfcNames_DmaConfig);
  DmaManager *dma = new DmaManager(dmap);

  deviceIndication = new MemreadIndication(IfcNames_MemreadIndication);
  dmaIndication = new DmaIndication(dma, IfcNames_DmaIndication);

  fprintf(stderr, "Main::allocating memory...\n");
  srcAlloc = portalAlloc(alloc_sz);
  srcBuffer = (unsigned int *)portalMmap(srcAlloc, alloc_sz);

  portalExec_start();

  for (int i = 0; i < numWords; i++){
    srcBuffer[i] = i;
  }
    
  portalDCacheFlushInval(srcAlloc, alloc_sz, srcBuffer);
  fprintf(stderr, "Main::flush and invalidate complete\n");

  unsigned int ref_srcAlloc = dma->reference(srcAlloc);
  fprintf(stderr, "ref_srcAlloc=%d\n", ref_srcAlloc);

  fprintf(stderr, "Main::starting read %08x\n", numWords);
  portalTimerStart(0);
  int burstLen = 16;
#ifndef BSIM
  int iterCnt = 64;
#else
  int iterCnt = 2;
#endif
  device->startRead(ref_srcAlloc, numWords, burstLen, iterCnt);
  sem_wait(&test_sem);
  uint64_t cycles = portalTimerLap(0);
  uint64_t beats = dma->show_mem_stats(ChannelType_Read);
  float read_util = (float)beats/(float)cycles;
  fprintf(stderr, "memory read utilization (beats/cycle): %f\n", read_util);

  MonkitFile("perf.monkit")
    .setHwCycles(cycles)
    .setReadBwUtil(read_util)
    .writeFile();

  exit(mismatchCount ? 1 : 0);
}
Exemple #2
0
int main(int argc, const char **argv)
{
  MemreadRequestProxy *device = new MemreadRequestProxy(IfcNames_MemreadRequestS2H);
  MemreadIndication deviceIndication(IfcNames_MemreadIndicationH2S);
  DmaManager *dma = platformInit();

  int srcAlloc;
  srcAlloc = portalAlloc(test_sz, 0);
  unsigned int *srcBuffer = (unsigned int *)portalMmap(srcAlloc, test_sz);

  for (unsigned int i = 0; i < test_sz/sizeof(unsigned int); i++)
    srcBuffer[i] = i;
  portalCacheFlush(srcAlloc, srcBuffer, test_sz, 1);
  unsigned int ref_srcAlloc = dma->reference(srcAlloc);
  printf( "Main::starting read %lx\n", test_sz);
  device->startRead(ref_srcAlloc, test_sz, burstLen, 1);
  sem_wait(&test_sem);
  return 0;
}
Exemple #3
0
int runtest(int argc, const char ** argv)
{
  int test_result = 0;
  int srcAlloc;
  unsigned int *srcBuffer = 0;

  fprintf(stderr, "Main::%s %s\n", __DATE__, __TIME__);
  MemreadRequestProxy *device = new MemreadRequestProxy(IfcNames_MemreadRequestS2H);
  MemreadIndication deviceIndication(IfcNames_MemreadIndicationH2S);
  DmaManager *dma = platformInit();

  fprintf(stderr, "Main::allocating memory...\n");
  srcAlloc = portalAlloc(alloc_sz, 0);
  srcBuffer = (unsigned int *)portalMmap(srcAlloc, alloc_sz);

#ifdef FPGA0_CLOCK_FREQ
  long req_freq = FPGA0_CLOCK_FREQ;
  long freq = 0;
  setClockFrequency(0, req_freq, &freq);
  fprintf(stderr, "Requested FCLK[0]=%ld actually %ld\n", req_freq, freq);
#endif

  for (int i = 0; i < numWords; i++){
    srcBuffer[i] = i;
  }

  portalCacheFlush(srcAlloc, srcBuffer, alloc_sz, 1);
  fprintf(stderr, "Main::flush and invalidate complete\n");

  unsigned int ref_srcAlloc = dma->reference(srcAlloc);
  fprintf(stderr, "ref_srcAlloc=%d\n", ref_srcAlloc);

  if(true) {
    fprintf(stderr, "Main::test read %08x\n", numWords);
    // first attempt should get the right answer
    device->startRead(ref_srcAlloc, 0, numWords, burstLen);
    sem_wait(&test_sem);
    if (mismatchCount) {
      fprintf(stderr, "Main::first test failed to match %d.\n", mismatchCount);
      test_result++;     // failed
    }
  }

  int err = 5;
  switch (err){
  case 0:
    {
      fprintf(stderr, "Main: attempt to use a de-referenced sglist\n");
      dma->dereference(ref_srcAlloc);
      device->startRead(ref_srcAlloc, 0, numWords, burstLen);
      break;
    } 
  case 1:
    {
      fprintf(stderr, "Main: attempt to use an out-of-range sglist\n");
      device->startRead(ref_srcAlloc+32, 0, numWords, burstLen);
      break;
    }
  case 2:
    {
      fprintf(stderr, "Main: attempt to use an invalid sglist\n");
      device->startRead(ref_srcAlloc+1, 0, numWords, burstLen);
      break;
    }
  case 3:
    {
      fprintf(stderr, "Main: attempt to use an invalid mmusel\n");
      device->startRead(ref_srcAlloc | (1<<16), 0, numWords, burstLen);
      break;
    }
  case 4:
    {
      fprintf(stderr, "Main: attempt to read off the end of the region\n");
      device->startRead(ref_srcAlloc, numWords<<2, burstLen, burstLen);
      break;
    }
  default:
    {
      device->startRead(ref_srcAlloc, 0, numWords, burstLen);
    }
  }

  sem_wait(&test_sem);
  if (mismatchCount) {
    fprintf(stderr, "Main::first test failed to match %d.\n", mismatchCount);
    test_result++;     // failed
  }
  return test_result;
}