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; }
int main(int argc, const char **argv) { ReadTestRequestProxy *device = new ReadTestRequestProxy(IfcNames_ReadTestRequestS2H); ReadTestIndication deviceIndication(IfcNames_ReadTestIndicationH2S); 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; }