vector<vector<string> > solveNQueens(int n) { vector<vector<string> > rlts; if (n<=0) return rlts; vector<int> cur (n, 0); vector<bool> flags(n + 2*n-1 + 2*n-1, false); generateResults(rlts,n,0,cur,flags); return rlts; }
void GContactClient::receiveSyncFinished(Sync::SyncStatus aState) { FUNCTION_CALL_TRACE; #ifndef QT_NO_DEBUG //LOG_DEBUG("*********** Sync has finished with:" << toText(aState) // << "****************"); #endif // QT_NO_DEBUG switch(aState) { case Sync::SYNC_ERROR: case Sync::SYNC_AUTHENTICATION_FAILURE: case Sync::SYNC_DATABASE_FAILURE: case Sync::SYNC_CONNECTION_ERROR: case Sync::SYNC_NOTPOSSIBLE: { generateResults( false ); emit error( getProfileName(), "", aState); break; } case Sync::SYNC_ABORTED: case Sync::SYNC_DONE: { generateResults( true ); emit success( getProfileName(), QString::number(aState)); break; } case Sync::SYNC_QUEUED: case Sync::SYNC_STARTED: case Sync::SYNC_PROGRESS: default: { generateResults( false ); emit error( getProfileName(), "", aState); break; } } }
DRINK::DRINK(int _numBits, bool _color, int _ringSize, int _numRings, int _pairs, bool _allPairs) { numBits = _numBits; ringSize = _ringSize; numRings = _numRings; numPairs = _pairs; allPairs = _allPairs; color = _color; radiusStep = BIGGEST_RADIUS / numRings; firstRadius = radiusStep; int raw_pairs[] = { 1553, 1595, 1596, 344, 372, 627, 375, 467, 331, 47, 303, 415, 10, 666, 289, 373, 414, 247, 89, 5, 422, 426, 215, 665, 465, 258, 299, 582, 585, 623, 667, 718, 501, 677, 657, 90, 514, 593, 551, 133, 587, 333, 877, 82, 1085, 1715, 1128, 11, 1169, 846, 550, 43, 291, 762, 719, 835, 1013, 509, 1589, 1381, 1018, 1138, 1716, 1181 }; for (unsigned i = 0; i<sizeof (raw_pairs) / sizeof (int); ++i) { bestPairs.push_back(raw_pairs[i]); } geometryData.resize(ringSize * numRings); for (int i = 0; i < ringSize * numRings; ++i) geometryData[i].resize(SCALE_SAMPLES); for (int i = 0; i < ringSize * numRings; ++i) for (int j = 0; j < SCALE_SAMPLES; ++j) geometryData[i][j].resize(ROTATION_SAMPLES); generateGeometry(); generateAllPairs(); if (_allPairs) { pairs = allPairsVec; } else { for (int i = 0; i < numPairs; ++i) { pairs.push_back(allPairsVec[bestPairs[i]]); } } generateResults(); }
void generateResults(vector<vector<string> > &rlts, int n, int index, vector<int>&cur, vector<bool>& flags){ for (int i=0; i<n; i++){ int j = n + index + i; int k = n + 2*n-1 + index-i + n-1; if (flags[i] || flags[j] || flags[k]) continue; flags[i] = flags[j] = flags[k] = true; cur[index] = i; if (index==n-1){ vector<string> rlt; for (int p=0; p<n; p++){ string s=""; for (int q=0; q<n; q++){ if (cur[p]==q) s+='Q'; else s+='.'; } rlt.push_back(s); } rlts.push_back(rlt); } else generateResults(rlts, n, index+1, cur, flags); flags[i] = flags[j] = flags[k] = false; } }
void runTest ( TESTPARAMS * testParams ) { int procIdx, procs, messIdx; MPI_Comm activeComm = MPI_COMM_NULL; int *messList, messListSize; int testCount, iters; unsigned int i; char buf[256]; int width; double result; STATSTRUCT dp, sum; prestaRankPrint ( 0, "\n\n%s Test Results \n(tasks, size, ops/sample, samples) : min/mean/max \n", testParams->name ); if ( argStruct.verbose ) { if ( testParams->id == LATEN ) { if ( argStruct.sumLocalBW == 1 ) { sprintf ( buf, outputCharLBWFormat, "Test", "Processes", "Op Size (bytes)", "Ops", "Latency (us)" ); } else { sprintf ( buf, outputCharFormat, "Test", "Processes", "Op Size (bytes)", "Ops", "BW (MB)", "Latency (us)" ); } } else { if ( argStruct.sumLocalBW == 1 ) { sprintf ( buf, outputCharLBWFormat, "Test", "Processes", "Op Size (bytes)", "Ops", "BW (MB)" ); } else { sprintf ( buf, outputCharFormat, "Test", "Processes", "Op Size (bytes)", "Ops", "BW (MB)", "Op time (us)" ); } } prestaRankPrint ( 0, "%s", buf ); width = strlen ( buf ); } else width = 80; for ( i = 0; i < width; i++ ) buf[i] = '-'; buf[i] = '\0'; prestaRankPrint ( 0, "%s\n", buf ); messList = testParams->messList; messListSize = testParams->messListSize; testParams->maxBW = 0.0; testParams->maxBWMessSize = 0; init_stats ( &sum, 0, 0, 0, 0 ); for ( procIdx = 0; procIdx < argStruct.procListSize; procIdx++ ) { procs = argStruct.procList[procIdx]; if ( procs > wsize ) procs = wsize; /* Create Communicator of all active processes */ procs = createActiveComm ( procs, argStruct.procsPerNode, argStruct.allocPattern, argStruct.useNearestRank, &activeComm ); prestaDebug ( "rank %d returned from createActiveCom\n", rank ); prestaDebug ( "messListSize is %d \n", messListSize ); for ( messIdx = 0; messIdx < messListSize; messIdx++ ) { if ( argStruct.iterList != NULL && argStruct.iterList[messIdx] != 0 ) iters = argStruct.iterList[messIdx]; else iters = argStruct.iters; if ( argStruct.testCountList != NULL ) { fprintf ( stderr, "Before init_stats! messIdx is %d, procIdx is %d, testCountList is %p\n", messIdx, procIdx, argStruct.testCountList ); init_stats ( &dp, procs, messList[messIdx], iters, argStruct.testCountList[procIdx] ); } else { init_stats ( &dp, procs, messList[messIdx], iters, argStruct.samples ); } for ( testCount = 0; testCount < dp.samples; testCount++ ) { /* Run test and save current result */ testParams->rankResult = testParams->testFunc ( dp.msize, iters, &activeComm ); /* TODO : Remove this if unnecessary */ if ( testParams->rankResult < minTime ) minTime = testParams->rankResult; if ( !generateResults ( testParams, procs, dp.msize, iters, &result ) ) prestaAbort ( "Failed to generate test results." ); update_stats ( &dp, result ); update_stats ( &sum, result ); } if ( testParams->id == LATEN ) { prestaRankPrint ( 0, "(%6d, %9d, %6d, %6d): %6.3f / %6.3f / %6.3f\n", dp.tasks, dp.msize, dp.iters, dp.samples, dp.min, dp.mean, dp.max ); } else { prestaRankPrint ( 0, "(%6d, %7d, %5d, %5d): %12.3f / %12.3f / %12.3f\n", dp.tasks, dp.msize, dp.iters, dp.samples, dp.min, dp.mean, dp.max ); } } } if ( testParams->id == LATEN ) { prestaRankPrint ( 0, "\nSummary : min/mean/max = %6.3f / %6.3f / %6.3f\n", sum.min, sum.mean, sum.max ); } else { prestaRankPrint ( 0, "\nSummary : min/mean/max = %12.3f / %12.3f / %12.3f\n", sum.min, sum.mean, sum.max ); } if ( rank == 0 && argStruct.printPairs ) { printActivePairs ( procs, argStruct.procsPerNode, argStruct.allocPattern, argStruct.useNearestRank ); } if ( activeComm != MPI_COMM_NULL ) MPI_Comm_free ( &activeComm ); }