#ifdef CPU_STRESS_TEST #define PRIME_LIMIT 100000 static uint8_t sieve[PRIME_LIMIT]; memset(sieve, 1, sizeof(sieve)); sieve[0] = sieve[1] = 0; for (int i = 2; i * i < PRIME_LIMIT; i++) { #ifdef CPU_STRESS_TEST_WITH_MEMCPY memcpy(&gDdrBufA[i], &i, sizeof(i)); #endif if (sieve[i]) { for (int j = i * i; j < PRIME_LIMIT; j += i) sieve[j] = 0; } } volatile int prime_count = 0; for (int i = 0; i < PRIME_LIMIT; i++) prime_count += sieve[i]; #endif #ifdef DDR_STRESS_TEST // 20 iterations x 128KB each way = ~5MB of DDR traffic. #define DDR_COPY_ITERS 20 { // Seed bufA so the compiler can't optimize away the copies for (int j = 0; j < (int)DDR_STRESS_SIZE; j++) gDdrBufA[j] = (uint8_t)(j * 0x5A + 0x12); CacheP_wb(gDdrBufA, DDR_STRESS_SIZE, CacheP_TYPE_ALLD); CacheP_inv(gDdrBufA, DDR_STRESS_SIZE, CacheP_TYPE_ALLD); CacheP_inv(gDdrBufB, DDR_STRESS_SIZE, CacheP_TYPE_ALLD); for (int i = 0; i < DDR_COPY_ITERS; i++) { memcpy(gDdrBufB, gDdrBufA, DDR_STRESS_SIZE); memcpy(gDdrBufA, gDdrBufB, DDR_STRESS_SIZE); } CacheP_wb(gDdrBufA, DDR_STRESS_SIZE, CacheP_TYPE_ALLD); CacheP_wb(gDdrBufB, DDR_STRESS_SIZE, CacheP_TYPE_ALLD); } #endif