void *test(void *data) { int rand_max; thread_data_t *d = (thread_data_t *)data; uint64_t res; phys_id= the_cores[d->id]; set_cpu(phys_id); seeds = seed_rand(); rand_max = num_entries - 1; /* Init of local data if necessary */ /* Wait on barrier */ barrier_cross(d->barrier); int entry; while (stop == 0) { if (num_entries==1) { entry=0; } else { entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max; } // entry = (int)(erand48(seed) * rand_max) + rand_min; #ifdef TEST_CAS do { res = CAS_U8(&(the_data[entry].data),0,1); } while(res!=0); #elif defined(TEST_TAS) do { res = TAS_U8(&(the_data[entry].data)); } while (res!=0); #elif defined(TEST_FAI) FAI_U8(&(the_data[entry].data)); #else perror("No test primitive specified"); #endif MEM_BARRIER; the_data[entry].data = 0; d->num_operations++; if (op_pause>0) { cpause(op_pause); } } /* Free any local data if necessary */ return NULL; }
void *test(void *data) { fprintf(stderr, "Starting test\n"); //get the per-thread data thread_data_t *d = (thread_data_t *)data; //place the thread on the apropriate cpu set_cpu(d->id); int op_count = 10000; ssalloc_init(); /* Wait on barrier */ barrier_cross(d->barrier); int i; bst_value_t* val = (bst_value_t*)malloc(sizeof(bst_value_t)); bst_value_t* added; for ( i = 1; i <= op_count; i++){ *val = d->id*op_count+i; // bst_value_t val = d->id*op_count+i; // fprintf(stderr, "[%d] before add\n", pthread_self()); added = bst_put(i, val, root); // fprintf(stderr, "[%d] Added %d\n", pthread_self(), i); // fprintf(stderr, "[%d] Added %d? %d\n", d->id, i, added==TRUE); if (added == NULL) { d->num_insert++; FAI_U8(&v[i]); } } // printf("Root right node: %d", root->right->key); for (i = 1; i <= op_count; i++){ bool_t found = (bst_get(i, root) != NULL); // printf("Contains %d? %d\n", i, found==FOUND); if (found) { d->num_search ++; } } // fprintf(stderr, "After insertions, found %d\n", d->num_search); // d->num_search = 0; for ( i = 1; i <= op_count; i++){ bool_t removed = (bst_remove(i, root) != NULL); // printf("Removed %d? %d\n", i, removed==TRUE); if (removed == TRUE) { d->num_remove ++; FAI_U8(&v[i]); } } // for ( i = 1; i <= op_count; i++){ // bool_t found = (bst_get(i) != NULL); // // printf("Contains %d? %d\n", i, found==FOUND); // if (found) { // d->num_search ++; // } // } // fprintf(stderr, "After deletions, found %d\n", d->num_search); return NULL; }
void *test_latency(void *data) { thread_data_t *d = (thread_data_t *)data; #ifndef NO_SET_CPU int phys_id = the_cores[d->id]; set_cpu(phys_id); #endif int rand_max; #if defined(TEST_CTR) data_type old_data; data_type new_data; #endif volatile uint64_t res; seeds = seed_rand(); rand_max = num_entries - 1; unsigned long do_not_measure=0; int entry=0; ticks t1 = 0, t2 = 0; barrier_cross(d->barrier); while (stop == 0) { if (num_entries>1) { entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max; } do_not_measure=(d->num_operations) & 0x1f; #ifdef TEST_CAS if ((d->num_operations)&1) { res = CAS_U8(&(the_data[entry].data),1,0); } else { if (!do_not_measure) { t1=getticks(); # ifdef __tile__ MEM_BARRIER; # endif res = CAS_U8(&(the_data[entry].data),0,1); # ifdef __tile__ MEM_BARRIER; # endif t2=getticks(); } else { res = CAS_U8(&(the_data[entry].data),0,1); } } #elif defined(TEST_SWAP) if ((d->num_operations)&1) { res = SWAP_U8(&(the_data[entry].data),0); } else { if (do_not_measure) { res = SWAP_U8(&(the_data[entry].data),1); } else { t1=getticks(); # ifdef __tile__ MEM_BARRIER; # endif res = SWAP_U8(&(the_data[entry].data),1); # ifdef __tile__ MEM_BARRIER; # endif t2=getticks(); } } #elif defined(TEST_CTR) if (do_not_measure) { do { old_data=the_data[entry].data; new_data=old_data+1; } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data); } else { t1=getticks(); # ifdef __tile__ MEM_BARRIER; # endif do { old_data=the_data[entry].data; new_data=old_data+1; } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data); # ifdef __tile__ MEM_BARRIER; # endif t2=getticks(); } #elif defined(TEST_TAS) if (do_not_measure) { res = TAS_U8(&(the_data[entry].data)); } else { t1=getticks(); # ifdef __tile__ MEM_BARRIER; # endif res = TAS_U8(&(the_data[entry].data)); # ifdef __tile__ MEM_BARRIER; # endif t2=getticks(); } if (res==0) { the_data[entry].data = 0; } #elif defined(TEST_FAI) if (do_not_measure) { FAI_U8(&(the_data[entry].data)); } else { t1=getticks(); # ifdef __tile__ MEM_BARRIER; # endif FAI_U8(&(the_data[entry].data)); # ifdef __tile__ MEM_BARRIER; # endif t2=getticks(); } #else perror("No test primitive specified"); #endif if (!do_not_measure) { d->num_measured++; d->total_time+=t2-t1-correction; } d->num_operations++; if (op_pause>0) { cpause(op_pause); } } /* avoid warning of unused var*/ if (res == 12345654) { printf("%d", (int) res); } return NULL; }
void *test_throughput(void *data) { thread_data_t *d = (thread_data_t *)data; #ifndef NO_SET_CPU int phys_id = the_cores[d->id]; set_cpu(phys_id); #endif int rand_max; #if defined(TEST_CTR) data_type old_data; data_type new_data; #endif volatile uint64_t res; seeds = seed_rand(); rand_max = num_entries - 1; barrier_cross(d->barrier); int entry=0; while (stop == 0) { if (num_entries>1) { entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max; } #ifdef TEST_CAS if ((d->num_operations)&1) { res = CAS_U8(&(the_data[entry].data),1,0); } else { res = CAS_U8(&(the_data[entry].data),0,1); } #elif defined(TEST_SWAP) # ifdef __sparc__ if ((d->num_operations)&1) { res = SWAP_U32(&(the_data[entry].data),0); } else { res = SWAP_U32(&(the_data[entry].data),1); } # else if ((d->num_operations)&1) { res = SWAP_U8(&(the_data[entry].data),0); } else { res = SWAP_U8(&(the_data[entry].data),1); } # endif #elif defined(TEST_CTR) do { old_data=the_data[entry].data; new_data=old_data+1; } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data); #elif defined(TEST_TAS) res = TAS_U8(&(the_data[entry].data)); if (res==0) { the_data[entry].data = 0; } #elif defined(TEST_FAI) FAI_U8(&(the_data[entry].data)); #else perror("No test primitive specified"); #endif d->num_operations++; if (op_pause>0) { cpause(op_pause); } } /* avoid warning of unused var*/ if (res == 12345654) { printf("%d", (int) res); } return NULL; }
void *test(void *data) { thread_data_t *d = (thread_data_t *)data; phys_id = the_cores[d->id]; set_cpu(phys_id); int rand_max; data_type old_data; data_type new_data; uint64_t res; seeds = seed_rand(); rand_max = num_entries - 1; /* Init of local data if necessary */ unsigned long do_not_measure=0; int entry; ticks t1,t2; /* Wait on barrier */ barrier_cross(d->barrier); while (stop == 0) { if (num_entries==1) { entry=0; } else { entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max; } do_not_measure=(d->num_operations) & 0x1f; // entry = (int)(erand48(seed) * rand_max) + rand_min; #ifdef TEST_CAS // do { if ((d->num_operations)&1) { res = CAS_U8(&(the_data[entry].data),1,0); } else { if (!do_not_measure) { t1=getticks(); res = CAS_U8(&(the_data[entry].data),0,1); t2=getticks(); } else { res = CAS_U8(&(the_data[entry].data),0,1); } } // MEM_BARRIER; // } while(res!=0); #elif defined(TEST_SWAP) // do { if ((d->num_operations)&1) { res = SWAP_U8(&(the_data[entry].data),0); } else { if (do_not_measure) { res = SWAP_U8(&(the_data[entry].data),1); } else { t1=getticks(); res = SWAP_U8(&(the_data[entry].data),1); t2=getticks(); } } //MEM_BARRIER; // } while(res!=0); #elif defined(TEST_CTR) if (do_not_measure) { do { old_data=the_data[entry].data; new_data=old_data+1; } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data); } else { t1=getticks(); do { old_data=the_data[entry].data; new_data=old_data+1; } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data); t2=getticks(); } // MEM_BARRIER; #elif defined(TEST_TAS) // do { if (do_not_measure) { res = TAS_U8(&(the_data[entry].data)); } else { t1=getticks(); res = TAS_U8(&(the_data[entry].data)); t2=getticks(); } if (res==0) { // MEM_BARRIER; the_data[entry].data = 0; } // } while (res!=0); #elif defined(TEST_FAI) if (do_not_measure) { FAI_U8(&(the_data[entry].data)); } else { t1=getticks(); FAI_U8(&(the_data[entry].data)); t2=getticks(); } // MEM_BARRIER; #else perror("No test primitive specified"); #endif //#ifdef XEON //MEM_BARRIER; //__sync_synchronize(); //#endif if (!do_not_measure) { d->num_measured++; d->total_time+=t2-t1-correction; } d->num_operations++; if (op_pause>0) { cpause(op_pause); //cdelay(op_pause); } } /* Free any local data if necessary */ return NULL; }