/** * @brief Sets up the threads for a single object (this object). * * Calls ThreadSingleMessageKeepLastUser::SetupThreads. * * @param classIndex Each class that extends this class must have a unique index * which is used to ensure that one class does not attempt to use another classes threads. * @param numThreads Number of threads to setup. * @param function Entry point for thread. A pointer to this object will be passed as a parameter. * @param parameter Parameter to be passed to thread. */ void ThreadSingleMessageKeepLastUser::SetupThreadsLocal(size_t classIndex, size_t numThreads, LPTHREAD_START_ROUTINE function, void * parameter) { this->usingThreads.Enter(); if(this->usingThreads == false) { this->classIndex = classIndex; SetupThreads(classIndex, numThreads,function,parameter); this->usingThreads = true; // One message per thread. lastMessage.Resize(numThreads); } this->usingThreads.Leave(); }
void IS::RunBenchMark() { cout << " Size: " << TOTAL_KEYS << " Iterations: " << MAX_ITERATIONS << endl; //Initialize timer timer = new Timer(); timer->ResetTimer(0); //Generate random number sequence and subsequent keys on all procs InitKeys(amult); // Random number gen seed // Random number gen mult /* Do one iteration for free (i.e., "untimed") to guarantee initialization of all data and code pages and respective tables */ if(isSerial) { Rank(1); } else { SetupThreads(this); RankThread::iteration = 1; doSort(); for(int i=0; i<MAX_KEY; i++ ) master_hist[i] = 0; doSort(); Partial_Verify(1); } /*Start verification counter */ passed_verification = 0; if( execClass != 'S' ) cout << "\n iteration#" << endl; timer->Start(0); /*This is the main iteration */ for(int it=1; it<=MAX_ITERATIONS; it++ ) { if( execClass != 'S' ) cout << " " << it << endl; if(isSerial) { Rank(it); } else { RankThread::iteration = it; doSort(); for(int i=0; i<MAX_KEY; i++ ) master_hist[i] = 0; doSort(); Partial_Verify(it); } } timer->Stop(0); /*This tests that keys are in sequence: sorting of last ranked key seq occurs here, but is an untimed operation */ Full_Verify(); int verified = 0; if( passed_verification == 5*MAX_ITERATIONS + 1 ) verified = 1; std::chrono::duration<double> tm = timer->ReadTimer(0); BMResults * results = new BMResults(BMName, execClass, TOTAL_KEYS, 0, 0, MAX_ITERATIONS, tm, GetMOPS(tm, MAX_ITERATIONS, TOTAL_KEYS), "keys ranked", verified, isSerial, numThreads, bid); results->PrintVerificationStatus(execClass, verified, BMName); results->Print(); }