Exemplo n.º 1
0
int main(int argc, const char **argv)
{
    int test_result = 0;
    int srcAlloc;
    unsigned int *srcBuffer = 0;

    fprintf(stderr, "Main::%s %s\n", __DATE__, __TIME__);
    DmaManager *dma = platformInit();
    ReadTestRequestProxy *device = new ReadTestRequestProxy(IfcNames_ReadTestRequestS2H,TILE_NUMBER);
    ReadTestIndication memReadIndication(IfcNames_ReadTestIndicationH2S,TILE_NUMBER);

    fprintf(stderr, "Main::allocating memory...\n");
    srcAlloc = portalAlloc(alloc_sz, 0);
    srcBuffer = (unsigned int *)portalMmap(srcAlloc, alloc_sz);
    for (int i = 0; i < numWords; i++)
        srcBuffer[i] = i;
    portalCacheFlush(srcAlloc, srcBuffer, alloc_sz, 1);
    fprintf(stderr, "Main::flush and invalidate complete\n");

    /* Test 1: check that match is ok */
    unsigned int ref_srcAlloc = dma->reference(srcAlloc);
    fprintf(stderr, "ref_srcAlloc=%d\n", ref_srcAlloc);
    fprintf(stderr, "Main::orig_test read numWords=%d burstLen=%d iterCnt=%d\n", numWords, burstLen, iterCnt);
    portalTimerStart(0);
    device->startRead(ref_srcAlloc, numWords * 4, burstLen * 4, iterCnt);
    sem_wait(&test_sem);
    if (mismatchCount) {
        fprintf(stderr, "Main::first test failed to match %d.\n", mismatchCount);
        test_result++;     // failed
    }
    platformStatistics();

    /* Test 2: check that mismatch is detected */
    srcBuffer[0] = -1;
    srcBuffer[numWords/2] = -1;
    srcBuffer[numWords-1] = -1;
    portalCacheFlush(srcAlloc, srcBuffer, alloc_sz, 1);

    fprintf(stderr, "Starting second read, mismatches expected\n");
    mismatchCount = 0;
    device->startRead(ref_srcAlloc, numWords * 4, burstLen * 4, iterCnt);
    sem_wait(&test_sem);
    if (mismatchCount != 3/*number of errors introduced above*/ * iterCnt) {
        fprintf(stderr, "Main::second test failed to match mismatchCount=%d (expected %d) iterCnt=%d numWords=%d.\n",
            mismatchCount, 3*iterCnt,
            iterCnt, numWords);
        test_result++;     // failed
    }
#if 0
    MonkitFile pmf("perf.monkit");
    pmf.setHwCycles(cycles)
        .setReadBwUtil(read_util)
        .writeFile();
#endif
    return test_result;
}
Exemplo n.º 2
0
int main(int argc, const char **argv)
{
    int mismatch = 0;
    uint32_t sg = 0;
    int max_error = 10;

    if (sem_init(&test_sem, 1, 0)) {
        fprintf(stderr, "error: failed to init test_sem\n");
        exit(1);
    }
    fprintf(stderr, "testmemwrite: start %s %s\n", __DATE__, __TIME__);
    DmaManager *dma = platformInit();
    MemwriteRequestProxy *device = new MemwriteRequestProxy(IfcNames_MemwriteRequestS2H);
    MemwriteIndication deviceIndication(IfcNames_MemwriteIndicationH2S);

    fprintf(stderr, "main::allocating memory...\n");
    int dstAlloc = portalAlloc(alloc_sz, 0);
    unsigned int *dstBuffer = (unsigned int *)portalMmap(dstAlloc, alloc_sz);
#ifdef FPGA0_CLOCK_FREQ
    long req_freq = FPGA0_CLOCK_FREQ, freq = 0;
    setClockFrequency(0, req_freq, &freq);
    fprintf(stderr, "Requested FCLK[0]=%ld actually %ld\n", req_freq, freq);
#endif
    unsigned int ref_dstAlloc = dma->reference(dstAlloc);
    for (int i = 0; i < numWords; i++)
        dstBuffer[i] = 0xDEADBEEF;
    portalCacheFlush(dstAlloc, dstBuffer, alloc_sz, 1);
    fprintf(stderr, "testmemwrite: flush and invalidate complete\n");
    fprintf(stderr, "testmemwrite: starting write %08x\n", numWords);
    portalTimerStart(0);
    device->startWrite(ref_dstAlloc, 0, numWords, burstLen, iterCnt);
    sem_wait(&test_sem);
    for (int i = 0; i < numWords; i++) {
        if (dstBuffer[i] != sg) {
            mismatch++;
            if (max_error-- > 0)
                fprintf(stderr, "testmemwrite: [%d] actual %08x expected %08x\n", i, dstBuffer[i], sg);
        }
        sg++;
    }
    platformStatistics();
    fprintf(stderr, "testmemwrite: mismatch count %d.\n", mismatch);
    exit(mismatch);
}
Exemplo n.º 3
0
int main(int argc, const char **argv)
{
    if(sem_init(&done_sem, 1, 0)) {
        fprintf(stderr, "failed to init done_sem\n");
        exit(1);
    }
    if(sem_init(&memcmp_sem, 1, 0)) {
        fprintf(stderr, "failed to init memcmp_sem\n");
        exit(1);
    }

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

    MemcpyRequestProxy *device = new MemcpyRequestProxy(IfcNames_MemcpyRequestS2H);
    deviceIndication = new MemcpyIndication(IfcNames_MemcpyIndicationH2S);
    DmaManager *dma = platformInit();

    fprintf(stderr, "Main::allocating memory...\n");

    srcAlloc = portalAlloc(alloc_sz, 0);
    dstAlloc = portalAlloc(alloc_sz, 0);

    // for(int i = 0; i < srcAlloc->header.numEntries; i++)
    //   fprintf(stderr, "%lx %lx\n", srcAlloc->entries[i].dma_address, srcAlloc->entries[i].length);
    // for(int i = 0; i < dstAlloc->header.numEntries; i++)
    //   fprintf(stderr, "%lx %lx\n", dstAlloc->entries[i].dma_address, dstAlloc->entries[i].length);

    srcBuffer = (unsigned int *)portalMmap(srcAlloc, alloc_sz);
    dstBuffer = (unsigned int *)portalMmap(dstAlloc, alloc_sz);

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

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

    unsigned int ref_srcAlloc = dma->reference(srcAlloc);
    unsigned int ref_dstAlloc = dma->reference(dstAlloc);

    fprintf(stderr, "ref_srcAlloc=%d\n", ref_srcAlloc);
    fprintf(stderr, "ref_dstAlloc=%d\n", ref_dstAlloc);


    // unsigned int refs[2] = {ref_srcAlloc, ref_dstAlloc};
    // for(int j = 0; j < 2; j++){
    //   unsigned int ref = refs[j];
    //   for(int i = 0; i < numWords; i = i+(numWords/4)){
    //     dmap->addrRequest(ref, i*sizeof(unsigned int));
    //     sleep(1);
    //   }
    //   dmap->addrRequest(ref, (1<<16)*sizeof(unsigned int));
    //   sleep(1);
    // }

    fprintf(stderr, "Main::starting memcpy numWords:%d\n", numWords);
    int burstLen = 32;
#ifndef SIMULATION
    int iterCnt = 128;
#else
    int iterCnt = 2;
#endif
    portalTimerStart(0);
    device->startCopy(ref_dstAlloc, ref_srcAlloc, numWords, burstLen, iterCnt);
    sem_wait(&done_sem);
    platformStatistics();
    //float read_util = (float)read_beats/(float)cycles;
    //float write_util = (float)write_beats/(float)cycles;
    //fprintf(stderr, "   iters: %d\n", iterCnt);
    //fprintf(stderr, "wr_beats: %"PRIx64" %08lx\n", write_beats, (long)write_beats);
    //fprintf(stderr, "rd_beats: %"PRIx64" %08lx\n", read_beats, (long)read_beats);
    //fprintf(stderr, "numWords: %x\n", numWords);
    //fprintf(stderr, "  wr_est: %"PRIx64"\n", (write_beats*2)/iterCnt);
    //fprintf(stderr, "  rd_est: %"PRIx64"\n", (read_beats*2)/iterCnt);
    //fprintf(stderr, "memory read utilization (beats/cycle): %f\n", read_util);
    //fprintf(stderr, "memory write utilization (beats/cycle): %f\n", write_util);

#if 0
    MonkitFile pmf("perf.monkit");
    pmf.setHwCycles(cycles)
    .setReadBwUtil(read_util)
    .setWriteBwUtil(write_util)
    .writeFile();
    fprintf(stderr, "After updating perf.monkit\n");
#endif
    sem_wait(&memcmp_sem);
    fprintf(stderr, "after memcmp_sem memcmp_fail=%d\n", memcmp_fail);
    return memcmp_fail;
}