本文整理汇总了C++中QNode::Reuse方法的典型用法代码示例。如果您正苦于以下问题:C++ QNode::Reuse方法的具体用法?C++ QNode::Reuse怎么用?C++ QNode::Reuse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNode
的用法示例。
在下文中一共展示了QNode::Reuse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]){
int numThreads = atoi(argv[1]);
threshold = atoi(argv[2]);
int levels = atoi(argv[3]);
int * participantsAtLevel = (int * ) malloc(levels);
for (int i = 0; i < levels; i++) {
participantsAtLevel[i] = atoi(argv[4 + i]);
}
omp_set_num_threads(numThreads);
int numIter = 144 * (0x4ffff) / numThreads;
//int levels = 4;
//int participantsAtLevel[] = {2, 4, 8, 16};
//omp_set_num_threads(16);
//int levels = 2;
//int participantsAtLevel[] = {12, 36};
//omp_set_num_threads(36);
//int levels = 2;
//int participantsAtLevel[] = {2, 4};
//omp_set_num_threads(4);
struct timeval start;
struct timeval end;
uint64_t elapsed;
#pragma omp parallel
{
int tid = omp_get_thread_num();
int size = omp_get_num_threads();
HMCS * hmcs = LockInit(tid, size, levels, participantsAtLevel);
if(tid == 0)
gettimeofday(&start, 0);
QNode me;
for(int i = 0; i < numIter; i++) {
me.Reuse();
Acquire(hmcs, &me);
//printf("Acquired %d!\n", tid);
//#define VALIDATE
#ifdef VALIDATE
int lvar = var;
var ++;
assert(var == lvar + 1);
#endif
Release(hmcs, &me);
}
}
gettimeofday(&end, 0);
elapsed = TIME_SPENT(start, end);
double throughPut = (numIter * numThreads * 144 * 0x4ffffL) * 100000.0 / elapsed;
std::cout<<"\n Throughput = " << throughPut;
return 0;
}