int bar7(Bar *pBar) { if (IsDebuggerPresent()) { return 30; } return bar0(pBar) + bar1(pBar) + 2; }
void TestReaderWriterLockOnNThreads(int nThreads) { // Stress-test all interfaces for (int pc=0; pc<=100; pc+=20) { REMARK("Testing with %d threads, percent of MAX_WORK=%d...", nThreads, pc); StressRWLBody myStressBody(nThreads, pc); NativeParallelFor(nThreads, myStressBody); REMARK(" OK.\n"); } int i; n_tested__sim_readers = 0; REMARK("Testing with %d threads, direct/unscoped locking mode...", nThreads); // TODO: choose direct or unscoped? // TODO: refactor the following two for loops into a shared function for( i=0; i<100; ++i ) { Harness::SpinBarrier bar0(nThreads); CorrectRWLBody myCorrectBody(nThreads,bar0); active_writers = active_readers = 0; sim_readers = false; NativeParallelFor(nThreads, myCorrectBody); if( sim_readers || nThreads==1 ) { if( ++n_tested__sim_readers>5 ) break; } } ASSERT(i<100, "There were no simultaneous readers."); REMARK(" OK.\n"); n_tested__sim_readers = 0; REMARK("Testing with %d threads, scoped locking mode...", nThreads); for( i=0; i<100; ++i ) { Harness::SpinBarrier bar0(nThreads); CorrectRWLScopedBody myCorrectScopedBody(nThreads, bar0); active_writers = active_readers = 0; sim_readers = false; NativeParallelFor(nThreads, myCorrectScopedBody); if( sim_readers || nThreads==1 ) { if( ++n_tested__sim_readers>5 ) break; } } ASSERT(i<100, "There were no simultaneous readers."); REMARK(" OK.\n"); }
void foo0 (long a, long b) { float c[0]; b = 0; for (; b < a; b++) c[b] = bar0 (c[b]); dummy0 (c); }
void foo (int a) { if (a < 100) return; if (200 < a) return; switch (a) { case 99: bar0 (); return; case 100: bar1 (); return; case 101: bar2 (); return; case 102: bar3 (); return; } }
int bar2(Bar *pBar) { return bar0(pBar) + bar1(pBar) + 2; }
void foobar() { bar0(); bar0(); bar0(); }