int main(int argc, char *argv[]) { struct timeval tv_start; struct timeval tv_end; gettimeofday(&tv_start, NULL); if (argc != 4) { fprintf(stderr, "usage: a.out numInts numBlanks numFAItems\n"); exit(0); } int N = atoi(argv[1]); int K = atoi(argv[2]); int X = atoi(argv[3]); fprintf(stderr, "N = %d K = %d X = %d\n", N, K, X); assert(!(N%2) && "N is not even"); assert(X > 0); #ifdef _FORCE_FAIL srand(time(NULL)); randval = rand() % N; #endif // Initialize Atlas NVM_Initialize(); // Create an Atlas persistent region sll_rgn_id = NVM_FindOrCreateRegion("sll_ll", O_RDWR, NULL); int i; for (i = 1; i < N/2+1; ++i) insertPass1(i, K, X); InsertAfter = SLL; for (i=N/2+1; i < N; i += X) insertPass2(i, K, X); int total_inserted = i - 1; insertPass2(i, K, N - total_inserted); fprintf(stderr, "Sum of elements is %ld\n", printSLL()); // Close the Atlas persistent region NVM_CloseRegion(sll_rgn_id); // Optionally print Atlas stats #ifdef NVM_STATS NVM_PrintStats(); #endif // Atlas bookkeeping NVM_Finalize(); gettimeofday(&tv_end, NULL); fprintf(stderr, "time elapsed %ld us\n", tv_end.tv_usec - tv_start.tv_usec + (tv_end.tv_sec - tv_start.tv_sec) * 1000000); return 0; }
int main() { pthread_t thread; struct timeval tv_start; struct timeval tv_end; gettimeofday(&tv_start, NULL); NVM_Initialize(); queue_rgn_id = NVM_FindOrCreateRegion("queue", O_RDWR, NULL); initialize(); pthread_create(&thread, 0, (void *(*)(void *))do_work, 0); // wait for the child to be ready int t = 0; while (!t) { NVM_LOCK(ready_lock); t = ready; NVM_UNLOCK(ready_lock); } int i; for (i = 0; i < NUM_ITEMS; ++i) enqueue(i); NVM_LOCK(done_lock); done = 1; NVM_UNLOCK(done_lock); pthread_join(thread, NULL); NVM_CloseRegion(queue_rgn_id); #ifdef NVM_STATS NVM_PrintStats(); #endif NVM_Finalize(); fprintf(stderr, "Total # items enqueued is %d\n", NUM_ITEMS); gettimeofday(&tv_end, NULL); fprintf(stderr, "time elapsed %ld us\n", tv_end.tv_usec - tv_start.tv_usec + (tv_end.tv_sec - tv_start.tv_sec) * 1000000); return 0; }
int main() { // WORK and ITERATIONS are macros defined in compilation NVM_Initialize(); rgn_id = NVM_CreateRegion("createclosefindclose", O_RDWR); test(rgn_id); NVM_CloseRegion(rgn_id); rgn_id = NVM_FindRegion("createclosefindclose", O_RDWR); test(rgn_id); NVM_CloseRegion(rgn_id); NVM_Finalize(); return 0; }