LouisJenkinsCS / Persistent-Memory-Analysis-Tool

Persistent Memory Analysis Tool (PMAT) - Valgrind Plugin that provides an online sampling approach towards performing verification on persistent memory.
GNU General Public License v2.0
1 stars 0 forks source link

Idea for Unit Test - Assertion in Failed Branch #51

Open LouisJenkinsCS opened 4 years ago

LouisJenkinsCS commented 4 years ago

Since prior to the enhancement, it was possible to create scenarios where the false branch was never taken due to the atomic load falling inside the same superblock as the CAS that depends on it, I should have a simple unit test that asserts that after X minutes it ends up failing.

atomic_int x = ATOMIC_VAR_INIT(0);
atomic_bool running = ATOMIC_VAR_INIT(true);
#pragma omp parallel
while (running) {
   int y = atomic_load(&x);
   assert(atomic_compare_exchange_strong(&x, &y, y + 1));
}

The above should not fail with the old translation but should fail with the new.

LouisJenkinsCS commented 4 years ago

Should SIGALRM and have asynchronous signal handler just set the running flag to false.

LouisJenkinsCS commented 4 years ago

When running it, I found that with super-small granularities --scheduling-quantum={1,2,3,4,5,6,7,8} etc. it works, but perhaps it has to do with RNG, sometimes it never finds it no matter how long it runs for. I believe I need to make some revisions w.r.t RNG, such as replacing the seed every now and then.