int main() { PrintResults("einstein_desitter", 1, 0); PrintResults("planck", 0.31, 0.69); PrintResults("hoyle", 0, 1); return 0; }
int main(void) { NN::FileManager f_manager; NN::NearestNeighbour nn; NN::Vector_2D<> test_set; NN::Vector_2D<> training_set; NN::Vector_2D<> neighbour_set; try { std::ifstream infile("data_base.txt"); if (!infile) throw MyException("\nCould not open file.\n\n"); f_manager.LoadDataSet(infile, test_set, training_set, 66); } catch (const MyException& err) { std::cout << err.what(); Wait(); return 1; } neighbour_set.push_back(nn.FindNeighbours(test_set, training_set)); std::cout << "Simple Nearest Neighbour Algorithm.\n"; std::cout << "\nStart Node : "; PrintResults(test_set, 0); std::cout << "\nNearest Neighbours: "; PrintResults(neighbour_set, 0); std::cout << "\nDistance : " << nn.GetShortestDistnace() << std::endl; Wait(); return 0; }
TVerdict CSettingsManagerInitialisationStep::doTestStepL() /** * @return - TVerdict code * * This test step look for the existence of P&S keys. * It also start the location server and load the Bluetooth PSY, as it update automatically the P&S keys. * At the end, the test control the value of each P&S keys. * If some keys are missing or some keys value are outside their expected range, the test will fail. * */ { if (TestStepResult()==EPass) { TBool areAvailableKeys = ETrue; TBool isBTPSYLoaded = ETrue; TBool areValidKeys = ETrue; iPNSChecker->CheckPNSKeys(areAvailableKeys, isBTPSYLoaded, areValidKeys); PrintResults(areAvailableKeys, isBTPSYLoaded, areValidKeys); TInt err = iLBSCustomer->ConnectToPositionServer(); _LIT(KConnectInfo, "Connect to position server: %d"); INFO_PRINTF2(KConnectInfo, err); if(KErrNone == err || KErrAlreadyExists == err) { if(KErrNone == err) { err = iLBSCustomer->OpenBTPSYPositioner(); _LIT(KOpenModule, "Open BT module: %d"); INFO_PRINTF2(KOpenModule, err); } } if(KErrNone == err || KErrAlreadyExists == err) { iPNSChecker->CheckPNSKeys(areAvailableKeys, isBTPSYLoaded, areValidKeys); PrintResults(areAvailableKeys, isBTPSYLoaded, areValidKeys); } else { _LIT(KUnexpectedError, "Failed to Connect to the Bt module = %d"); ERR_PRINTF2(KUnexpectedError, err); SetTestStepResult(EFail); } delete iLBSCustomer; iLBSCustomer = NULL; // If some keys are missing or some keys value are outside their expected range, // the test will fail. if ((!areAvailableKeys)||(!areValidKeys)) { SetTestStepResult(EFail); } } return TestStepResult(); }
int main(int argc, char *argv[]) { WORD Input[MAXCHANNELS], Output[MAXCHANNELS], PCSLab[MAXCHANNELS], PCSxyz[MAXCHANNELS]; fprintf(stderr, "little cms ColorSpace conversion calculator - v1.8\n\n"); if (argc == 1) Help(); HandleSwitches(argc, argv); cmsSetErrorHandler(MyErrorHandler); OpenTransforms(); for(;;) { if (xisatty(stdin)) printf("\nEnter values, 'q' to quit\n"); if (feof(stdin)) break; TakeValues(Input); cmsDoTransform(hTrans, Input, Output, 1); if (Verbose) { if (hTransXYZ) cmsDoTransform(hTransXYZ, Input, PCSxyz, 1); if (hTransLab) cmsDoTransform(hTransLab, Input, PCSLab, 1); } if (xisatty(stdin)) printf("\n"); PrintResults(Output, OutputColorSpace); printf("\n"); if (Verbose && hTransXYZ && hTransLab) { PrintResults(PCSxyz, icSigXYZData); printf("\n"); PrintResults(PCSLab, icSigLabData); printf("\n"); } } return 0; }
void CCodeProcessor::Process( const char *gamespecific, const char *root, const char *dsp, const char *config ) { strcpy( m_szDSP, dsp ); strcpy( m_szConfig, config ); m_nBytesProcessed = 0; m_nFilesProcessed = 0; m_nHeadersProcessed = 0; m_nLinesOfCode = 0; linesprocessed = 0; m_nOffset = strlen( root ) + 1; m_nModuleCount = 0; m_nHeaderCount = 0; m_flStart = UTIL_FloatTime(); vprint( 0, "--- Processing %s\n\n", root ); ConstructModuleList_R( 0, gamespecific, root ); m_flEnd = UTIL_FloatTime(); PrintResults(); }
/**********************************************************************//** *************************************************************************/ int main(int argc, char** argv) { // If no arguments have been passed, print the help text and quit if (argc==1) { Print_Help() ; return 0 ; } // Define the optional arguments struct option longopts[5] ; getoptions(longopts) ; // Parse the options std::map<std::string, double> options = parseoptions(argc, argv, longopts) ; // If no valid options were given, quit if (options.empty()) return 0 ; // Create a map to store the results std::map<std::string, double> results ; results["ra"] = 0.0 ; results["dec"] = 0.0 ; // Convert the coordinates CECoordinates::Galactic2CIRS(options["glon"]*DD2R, options["glat"]*DD2R, &results["ra"], &results["dec"], CEDate(options["juliandate"])) ; // Print the results PrintResults(options, results) ; return 0 ; }
int main(int argc, char **argv) { char tvalue = '\0', *key = calloc(ARGLENGTH, sizeof(char)), *parse = calloc(10, sizeof(char)), *fileName = calloc(ARGLENGTH, sizeof(char)), **wordList; tvalue = ParseArgs(argc, argv); key = argv[optind]; fileName = argv[optind + 1]; if (optind == argc || argc < 2) { fprintf(stderr, "usage: look [-dfa] [-t char] string [file]\n"); exit(EXIT_FAILURE); } else if (optind + 1 == argc) { fileName = "/usr/share/dict/words"; argFlags[0] = 1; argFlags[1] = 1; } key = CheckFlags(key, tvalue); ParseFile(argv, &parse, fileName); wordList = MakeList(parse); PrintResults(wordList, key, tvalue); return EXIT_SUCCESS; }
/**********************************************************************//** *************************************************************************/ int main(int argc, char** argv) { // Parse the command line options CLOptions opts = DefineOpts() ; if (opts.ParseCommandLine(argc, argv)) return 0 ; // Create a map to store the results std::map<std::string, double> results ; results["ra"] = 0.0 ; results["dec"] = 0.0 ; // Convert the coordinates int errcode = CECoordinates::Observed2CIRS(opts.AsDouble("azimuth")*DD2R, opts.AsDouble("zenith")*DD2R, &results["ra"], &results["dec"], opts.AsDouble("juliandate"), opts.AsDouble("longitude")*DD2R, opts.AsDouble("latitude")*DD2R, opts.AsDouble("elevation"), opts.AsDouble("pressure"), opts.AsDouble("temperature"), opts.AsDouble("humidity"), opts.AsDouble("dut1"), opts.AsDouble("xpolar"), opts.AsDouble("ypolar"), opts.AsDouble("wavelength")) ; // Print the results PrintResults(opts, results) ; return errcode ; }
void CCodeProcessor::Process( const char *baseentityclass, const char *gamespecific, const char *sourcetreebase, const char *subdir, const char *pFileName ) { SetupIncludePath( sourcetreebase, subdir, gamespecific ); strcpy( m_szBaseEntityClass, baseentityclass ); m_nBytesProcessed = 0; m_nFilesProcessed = 0; m_nHeadersProcessed = 0; m_nClassesParsed = 0; m_nLinesOfCode = 0; linesprocessed = 0; m_Modules.RemoveAll(); m_Headers.RemoveAll(); m_flStart = UTIL_FloatTime(); char rootdirectory[ 256 ]; sprintf( rootdirectory, "%s\\%s", sourcetreebase, subdir ); vprint( 0, "--- Processing %s\n\n", rootdirectory ); m_nOffset = strlen( rootdirectory ) + 1; ProcessModules( sourcetreebase, rootdirectory, pFileName ); m_flEnd = UTIL_FloatTime(); PrintResults( baseentityclass ); }
void InTransitAnalysis::Finalize() { if (ParallelDescriptor::IOProcessor()) { std::cout << "InTransitAnalysis class is finalizing ..." << std::endl; PrintResults(); } };
int main(int Argc, char ** Argv) { GetArgs(Argc,Argv); ProcessData(); PrintResults(); }
void do_libtm_work(void) { int tstep, i; for ( tstep=0; tstep< NUMBER_TIMESTEPS; tstep++) { //printf("\n1");PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); PARALLEL_EXECUTE( NTHREADS, UpdateCoordinates, NULL ); //printf("\n2");PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); vir = 0.0; epot = 0.0; ekin = 0.0; vel = 0.0; count = 0.0; if ( tstep % neighUpdate == 0) { ninter = 0; PARALLEL_EXECUTE( NTHREADS, BuildNeigh, NULL ); //printf("\n3");PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); # ifdef PRINT_COORDINATES PrintCoordinates(numMoles); # endif # ifdef PRINT_INTERACTION_LIST PrintInteractionList(INPARAMS ninter); # endif # ifdef MEASURE PrintConnectivity(); # endif } /* for (i = 0; i < numMoles; ++i) { f[IND(0, i)] = 0; f[IND(0, i)] = 0; f[IND(0, i)] = 0; } */ PARALLEL_EXECUTE( NTHREADS, ComputeForces, NULL ); //printf("\n4");PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); PARALLEL_EXECUTE( NTHREADS, UpdateVelocities, NULL ); //printf("\n5");PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); PARALLEL_EXECUTE( NTHREADS, ComputeKE, NULL ); //printf("\n6");PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); PARALLEL_EXECUTE( NTHREADS, ComputeAvgVel, NULL ); //printf("\n7"); PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); } TM_END(); return; }
int main(int argc, char** argv) { cuInit(0); DevicePtr device; CreateCuDevice(0, &device); ContextPtr context; CreateCuContext(device, 0, &context); searchEngine_t engine = 0; searchStatus_t status = searchCreate("../../src/cubin/search.cubin", &engine); double mgpuThroughputs[2][NumArraySizes][NumQuerySizes]; double thrustThroughputs[2][NumArraySizes][NumQuerySizes]; for(int s(0); s < NumArraySizes; ++s) { // 32-bit printf("32-bit key search:\n"); BenchmarkLoop<int>(context, engine, ArraySizes[s][0], ArraySizes[s][1], mgpuThroughputs[0][s], thrustThroughputs[0][s]); // 64-bit printf("64-bit key search:\n"); BenchmarkLoop<int64>(context, engine, ArraySizes[s][0], ArraySizes[s][1], mgpuThroughputs[1][s], thrustThroughputs[1][s]); } printf("\nTIMINGS SUMMARY\n\n"); printf("MGPU Search 32-bit:\n"); PrintResults(mgpuThroughputs[0]); printf("MGPU Search 64-bit:\n"); PrintResults(mgpuThroughputs[1]); printf("thrust 32-bit:\n"); PrintResults(thrustThroughputs[0]); printf("thrust 64-bit:\n"); PrintResults(thrustThroughputs[1]); searchDestroy(engine); }
/** * @brief Main function * @return 0 */ int _tmain(int argc, _TCHAR* argv[]) { long *plInputVector; UC ucItemConut = 0; ucItemConut = InputData(plInputVector); PrintResults(plInputVector, ucItemConut); _getch(); return 0; }
int main(int argc, char **argv) { Initialize(argc, argv); ReadLog(); PrintResults(); Terminate(); return(1); }
int main(int argc, char **argv) { int status = 0; ofp = stdout; /* Where the output will go */ Initialize(argc, argv); Compare(); if (globals.files_are_different) { PrintResults(); } Terminate(); return status; }
void Tester::Disable() { switch (testMode) { case TestMode::autonomous: tests->Interrupted(); PrintResults(); break; case TestMode::manual: manualTester->StopTesting(); break; default: break; } testMode = TestMode::disabled; }
/** * @brief Get the list of events. */ void EventLogReader::ReadEvents() { DWORD status = ERROR_SUCCESS; std::wstring buf = base::string_to_wstring(_query); EVT_HANDLE results = EvtQuery(nullptr, nullptr, buf.c_str(), EvtQueryChannelPath | EvtQueryTolerateQueryErrors); if (results == nullptr) return; if (!EvtSeek(results, _position, nullptr, 0, EvtSeekRelativeToFirst)) return; if (PrintQueryStatuses(results) == ERROR_SUCCESS) PrintResults(results); if (results) EvtClose(results); }
int main(int argc, char** argv) { if (argc != 5) { fprintf(stderr, "Usage: %s <lower> <upper> <max-length> <bucket-size>\n", argv[0]); return -1; } size_t lower = atoll(argv[1]); size_t upper = atoll(argv[2]); size_t maxLength = atoll(argv[3]); size_t bucketSize = atoll(argv[4]); // Start timing. tbb::tick_count startTime = tbb::tick_count::now(); // Fill in the lookup table for sequence lengths of numbers up to kNumStoredSequences. gSequenceLength[0] = 0; HailstoneFiller filler(maxLength); tbb::parallel_for(tbb::blocked_range<size_t>(1, kNumStoredSequences), filler); // Calculate the sequence lengths for the input range, using the lookup tables // where possible. HailstoneGathererFull gatherFull(maxLength, lower, upper); tbb::parallel_reduce(tbb::blocked_range<size_t>(lower, upper + 1), gatherFull); // Combine the length counts into their buckets. size_t numBuckets = maxLength / bucketSize; if (maxLength % bucketSize != 0) ++numBuckets; size_t buckets[kMaxPossibleLength]; size_t overflow; FillBuckets(gatherFull._buckets, maxLength, bucketSize, numBuckets, buckets, overflow); // Stop timing. tbb::tick_count endTime = tbb::tick_count::now(); // Print the results. PrintResults(startTime, endTime, lower, upper, maxLength, bucketSize, numBuckets, buckets, overflow); return 0; }
int main(int argc, char *argv[]) { int nDataVals, nStoredDataVals, nSavedRows; int nPixels_psf; int startDataRow, endDataRow; int nParamsTot, nFreeParams; int nDegFreedom; double *xVals, *yVals, *yWeights, *maskVals; double *xVals_psf, *yVals_psf; int weightMode = WEIGHTS_ARE_SIGMAS; FILE *outputFile_ptr; ModelObject *theModel; double *paramsVect; double *paramErrs; vector<mp_par> paramLimits; vector<int> FunctionBlockIndices; bool maskAllocated = false; bool paramLimitsExist = false; vector<mp_par> parameterInfo; int status, fitStatus; vector<string> functionList; vector<double> parameterList; commandOptions options; configOptions userConfigOptions; SolverResults resultsFromSolver; string nloptSolverName; vector<string> programHeader; string progNameVersion = "profilefit "; /* PROCESS COMMAND-LINE: */ /* First, set up the options structure: */ options.configFileName = DEFAULT_CONFIG_FILE; options.dataFileName = ""; options.modelOutputFileName = DEFAULT_MODEL_OUTPUT_FILE; options.noDataFile = true; options.noConfigFile = true; options.psfPresent = false; options.dataAreMagnitudes = true; // default: assumes we usually fit mu(R) profiles options.zeroPoint = 0.0; options.startDataRow = 0; options.endDataRow = -1; // default value indicating "last row in data file" options.noErrors = true; options.noMask = true; options.maskFormat = MASK_ZERO_IS_GOOD; options.ftol = DEFAULT_FTOL; options.ftolSet = false; options.printChiSquaredOnly = false; options.solver = MPFIT_SOLVER; options.nloptSolverName = "NM"; // default value = Nelder-Mead Simplex options.doBootstrap = false; options.bootstrapIterations = 0; options.subsamplingFlag = false; options.saveBestProfile = false; options.saveBestFitParams = true; options.outputParameterFileName = DEFAULT_1D_OUTPUT_PARAMETER_FILE; options.verbose = 1; options.nloptSolverName = ""; options.rngSeed = 0; progNameVersion += VERSION_STRING; MakeOutputHeader(&programHeader, progNameVersion, argc, argv); ProcessInput(argc, argv, &options); if (options.noDataFile) { printf("*** WARNING: No data to fit!\n\n"); return -1; } /* Read configuration file */ if (! FileExists(options.configFileName.c_str())) { printf("\n*** WARNING: Unable to find or open configuration file \"%s\"!\n\n", options.configFileName.c_str()); return -1; } status = ReadConfigFile(options.configFileName, false, functionList, parameterList, paramLimits, FunctionBlockIndices, paramLimitsExist, userConfigOptions); if (status < 0) { printf("\n*** WARNING: Problem in processing config file!\n\n"); return -1; } /* GET THE DATA: */ nDataVals = CountDataLines(options.dataFileName); if ((nDataVals < 1) || (nDataVals > MAX_N_DATA_VALS)) { /* file has no data *or* too much data (or an integer overflow occured in CountDataLines) */ printf("Something wrong: input file %s has too few or too many data points\n", options.dataFileName.c_str()); printf("(nDataVals = %d)\n", nDataVals); exit(1); } printf("Data file \"%s\": %d data points\n", options.dataFileName.c_str(), nDataVals); /* Set default end data row (if not specified) and check for reasonable values: */ startDataRow = options.startDataRow; endDataRow = options.endDataRow; if (endDataRow == -1) endDataRow = nDataVals - 1; if ( (startDataRow < 0) || (startDataRow >= nDataVals) ) { printf("Starting data row (\"--x1\") must be >= 1 and <= number of rows in data file (%d)!\n", nDataVals); exit(-1); } if ( (endDataRow <= startDataRow) || (endDataRow >= nDataVals) ) { printf("Ending data row (\"--x2\") must be >= starting data row and <= number of rows in data file (%d)!\n", nDataVals); exit(-1); } /* Allocate data vectors: */ nStoredDataVals = endDataRow - startDataRow + 1; xVals = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); yVals = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); if ( (xVals == NULL) || (yVals == NULL) ) { fprintf(stderr, "\nFailure to allocate memory for input data!\n"); exit(-1); } if (options.noErrors) yWeights = NULL; else yWeights = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); if (options.noMask) maskVals = NULL; else { maskVals = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); maskAllocated = true; } /* Read in data */ nSavedRows = ReadDataFile(options.dataFileName, startDataRow, endDataRow, xVals, yVals, yWeights, maskVals); if (nSavedRows > nStoredDataVals) { fprintf(stderr, "\nMore data rows saved (%d) than we allocated space for (%d)!\n", nSavedRows, nStoredDataVals); exit(-1); } if (options.noErrors) { // OK, we previously had yWeights = NULL to tell ReadDataFile() to skip // the third column (if any); now we need to have a yWeights vector with // all weights = 1.0 yWeights = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); for (int i = 0; i < nStoredDataVals; i++) yWeights[i] = 1.0; } /* Read in PSF profile, if supplied */ if (options.psfPresent) { nPixels_psf = CountDataLines(options.psfFileName); if ((nPixels_psf < 1) || (nPixels_psf > MAX_N_DATA_VALS)) { /* file has no data *or* too much data (or an integer overflow occured in CountDataLines) */ printf("Something wrong: input PSF file %s has too few or too many data points\n", options.psfFileName.c_str()); printf("(nPixels_psf (# of PSF points) = %d)\n", nPixels_psf); exit(1); } printf("PSF file \"%s\": %d data points\n", options.psfFileName.c_str(), nPixels_psf); /* Set default end data row (if not specified) and check for reasonable values: */ startDataRow = 0; endDataRow = nPixels_psf - 1; xVals_psf = (double *)calloc( (size_t)nPixels_psf, sizeof(double) ); yVals_psf = (double *)calloc( (size_t)nPixels_psf, sizeof(double) ); if ( (xVals_psf == NULL) || (yVals_psf == NULL) ) { fprintf(stderr, "\nFailure to allocate memory for PSF data!\n"); exit(-1); } nSavedRows = ReadDataFile(options.psfFileName, startDataRow, endDataRow, xVals_psf, yVals_psf, NULL, NULL); if (nSavedRows > nStoredDataVals) { fprintf(stderr, "\nMore PSF rows saved (%d) than we allocated space for (%d)!\n", nSavedRows, nPixels_psf); exit(-1); } } /* Set up the model object */ theModel = new ModelObject1d(); /* Add functions to the model object */ printf("Adding functions to model object...\n"); status = AddFunctions1d(theModel, functionList, FunctionBlockIndices); if (status < 0) { printf("*** WARNING: Failure in AddFunctions!\n\n"); exit(-1); } theModel->SetZeroPoint(options.zeroPoint); // Set up parameter vector(s), now that we know how many total parameters // there will be nParamsTot = nFreeParams = theModel->GetNParams(); printf("\t%d total parameters\n", nParamsTot); paramsVect = (double *) malloc(nParamsTot * sizeof(double)); for (int i = 0; i < nParamsTot; i++) paramsVect[i] = parameterList[i]; paramErrs = (double *) malloc(nParamsTot * sizeof(double)); /* Add image data, errors, and mask to the model object */ // "true" = input yVals data are magnitudes, not intensities theModel->AddDataVectors(nStoredDataVals, xVals, yVals, options.dataAreMagnitudes); theModel->AddErrorVector1D(nStoredDataVals, yWeights, WEIGHTS_ARE_SIGMAS); if (maskAllocated) { status = theModel->AddMaskVector1D(nStoredDataVals, maskVals, options.maskFormat); if (status < 0) { fprintf(stderr, "*** ERROR: Failure in ModelObject::AddMaskVector1D!\n\n"); exit(-1); } } // Add PSF vector, if present, and thereby enable convolution if (options.psfPresent) { status = theModel->AddPSFVector1D(nPixels_psf, xVals_psf, yVals_psf); if (status < 0) { fprintf(stderr, "*** ERROR: Failure in ModelObject::AddPSFVector1D!\n\n"); exit(-1); } } theModel->FinalSetupForFitting(); // calls ApplyMask(), VetDataVector() theModel->PrintDescription(); // Parameter limits and other info: printf("Setting up parameter information vector ...\n"); mp_par newParamLimit; for (int i = 0; i < nParamsTot; i++) { memset(&newParamLimit, 0, sizeof(mp_par)); newParamLimit.fixed = paramLimits[i].fixed; if (paramLimits[i].fixed == 1) { printf("Fixed parameter detected (i = %d)\n", i); nFreeParams--; } newParamLimit.limited[0] = paramLimits[i].limited[0]; newParamLimit.limited[1] = paramLimits[i].limited[1]; newParamLimit.limits[0] = paramLimits[i].limits[0]; newParamLimit.limits[1] = paramLimits[i].limits[1]; parameterInfo.push_back(newParamLimit); } nDegFreedom = theModel->GetNValidPixels() - nFreeParams; printf("%d free parameters (%d degrees of freedom)\n", nFreeParams, nDegFreedom); // tell ModelObject about parameterInfo (mainly useful for printing-related methods) theModel->AddParameterInfo(parameterInfo); // OK, now we either print chi^2 value for the input parameters and quit, or // else call one of the solvers! if (options.printChiSquaredOnly) { printf("\n"); fitStatus = 1; PrintFitStatistic(paramsVect, theModel, nFreeParams); printf("\n"); // turn off saveing of parameter file options.saveBestFitParams = false; } else { // DO THE FIT! fitStatus = DispatchToSolver(options.solver, nParamsTot, nFreeParams, nStoredDataVals, paramsVect, parameterInfo, theModel, options.ftol, paramLimitsExist, options.verbose, &resultsFromSolver, options.nloptSolverName, options.rngSeed); PrintResults(paramsVect, theModel, nFreeParams, fitStatus, resultsFromSolver); } // OPTIONAL HANDLING OF BOOTSTRAP RESAMPLING HERE if ((options.doBootstrap) && (options.bootstrapIterations > 0)) { printf("\nNow doing bootstrap resampling (%d iterations) to estimate errors...\n", options.bootstrapIterations); printf("[NOT YET PROPERLY IMPLEMENTED!]\n"); BootstrapErrors(paramsVect, parameterInfo, paramLimitsExist, theModel, options.ftol, options.bootstrapIterations, nFreeParams); } if (options.saveBestFitParams) { printf("Saving best-fit parameters in file \"%s\"\n", options.outputParameterFileName.c_str()); string progNameVer = "profilefit "; progNameVer += VERSION_STRING; SaveParameters(paramsVect, theModel, options.outputParameterFileName, programHeader, nFreeParams, options.solver, fitStatus, resultsFromSolver); } if (options.saveBestProfile) { theModel->CreateModelImage(paramsVect); double *modelProfile = (double *) calloc((size_t)nStoredDataVals, sizeof(double)); int nPts = theModel->GetModelVector(modelProfile); if (nPts == nStoredDataVals) { printf("Saving model profile to %s...\n", options.modelOutputFileName.c_str()); outputFile_ptr = fopen(options.modelOutputFileName.c_str(), "w"); for (int i = 0; i < nPts; i++) { fprintf(outputFile_ptr, "\t%f\t%f\n", xVals[i], modelProfile[i]); } fclose(outputFile_ptr); printf("Done.\n"); } else { printf("WARNING -- MISMATCH BETWEEN nStoredDataVals (main) and nDataVals (ModelObject1d)!\n"); printf("NO PROFILE SAVED!\n"); } free(modelProfile); } // Free up memory free(xVals); free(yVals); free(yWeights); if (maskAllocated) free(maskVals); if (options.psfPresent) { free(xVals_psf); free(yVals_psf); } free(paramsVect); free(paramErrs); delete theModel; printf("All done!\n\n"); return 0; }
//main work function for each thread void * do_thread_work (void * _id) { int id = (int) _id; int tstep, i; cpu_set_t mask; CPU_ZERO( &mask ); #ifdef WITH_SMT CPU_SET( id*2, &mask ); #else CPU_SET( id, &mask ); #endif sched_setaffinity(0, sizeof(mask), &mask); for ( tstep=0; tstep< NUMBER_TIMESTEPS; tstep++) { barrier_wait (&barrier); //need to reset these global vars in the beginning of every timestep //global vars, need to be protected if (id == 0) { vir = 0.0; epot = 0.0; ekin = 0.0; vel = 0.0; count = 0.0; } //because we have this barrier here, we don't need one at the end of //each timestep; this barrier effectively acts as if it was at the end; //we need it here because we need to perform the initializations above //at the _beginning_ of each timestep. //No, you need a barrier at the end, as well, because if you only have one //here but not at the end, you may reset some of the above global vars //while a slower thread is still computing stuff in the previous timestep... //I'm not sure, but we may be able to replace this barrier with just //asm volatile("mfence" ::: "memory"); barrier_wait (&barrier); //UpdateCoordinates (NULL, id); //PARALLEL_EXECUTE( NTHREADS, UpdateCoordinates, NULL ); //barrier_wait (&barrier); if ( tstep % neighUpdate == 0) { //this barrier needed because of the single-threaded code below barrier_wait (&barrier); if (id == 0) { #ifdef PRINT_COORDINATES PrintCoordinates(numMoles); #endif //global var, needs to be protected ninter = 0; } //this barrier needed because of the single-threaded code above barrier_wait (&barrier); BuildNeigh (NULL, id); //PARALLEL_EXECUTE( NTHREADS, BuildNeigh, NULL ); //this barrier needed because of the single-threaded code below barrier_wait (&barrier); if (id == 0) { #ifdef PRINT_INTERACTION_LIST PrintInteractionList(INPARAMS ninter); #endif #ifdef MEASURE PrintConnectivity(); #endif } //we need this here because otherwise fast threads might start //changing the data that thread 0 is reading above while running //PrintInteractionList() and PrintConnectivity(). barrier_wait (&barrier); } ComputeForces (NULL, id); //PARALLEL_EXECUTE( NTHREADS, ComputeForces, NULL ); //this barrier disappears with relaxed predicated commits barrier_wait (&barrier); //UpdateVelocities (NULL, id); //PARALLEL_EXECUTE( NTHREADS, UpdateVelocities, NULL ); //this barrier disappears with relaxed predicated commits //barrier_wait (&barrier); //ComputeKEVel (NULL, id); //PARALLEL_EXECUTE( NTHREADS, ComputeKEVel, NULL ); //Mike: consolidated all update functions into 1 Update(NULL, id); //need a barrier at the end of each timestep barrier_wait (&barrier); if (id == 0) { PrintResults (INPARAMS tstep, (double)ekin, (double)epot, (double)vir,(double)vel,(double)count,numMoles,(int)ninter); } barrier_wait (&barrier); } return NULL; }
int main(int argc, char *argv[]) { MIDASmodule module; MIDASmodulePlayHandle playHandle; MIDASstartup(); #ifdef _WIN32_ SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS); #endif puts("MIDAS playback profiler\n"); if ( argc != 3 ) { puts("Usage: mode filename\n mode = (f)loat/(i)nteger\n"); return EXIT_FAILURE; } MIDASconfig(); switch ( argv[1][0] ) { case 'i': mPreferredMixingMode = M_MIX_INTEGER; break; case 'f': mPreferredMixingMode = M_MIX_FLOAT; break; } if ( !MIDASinit() ) MIDASerror(); if ( !MIDASstartBackgroundPlay(0) ) MIDASerror(); if ( (module = MIDASloadModule(argv[2])) == NULL ) MIDASerror(); if ( (playHandle = MIDASplayModule(module, TRUE)) == 0 ) MIDASerror(); printf("Playing - press any\n"); getch(); if ( !MIDASstopModule(playHandle) ) MIDASerror(); if ( !MIDASfreeModule(module) ) MIDASerror(); if ( !MIDASstopBackgroundPlay() ) MIDASerror(); PrintResults(); if ( !MIDASclose() ) MIDASerror(); return 0; }
int // sm: silence warning main(int argc, char **argv) { unsigned long p, iMax; float gMax, lastGMax; ModuleRecPtr mr; ; /* parse argument */ if (argc != 2) { fprintf(stderr, "Usage: KL <input_file>\n"); ; exit(1); } /* prepare the data structures */ ReadNetList(argv[1]); NetsToModules(); ComputeNetCosts(); assert((numModules % 2) == 0); /* initial partition */ InitLists(); lastGMax = 0; /* do until we don't make any progress */ do { #ifndef KS_MODE /* compute the swap costs */ ComputeDs(&(groupA), GroupA, SwappedToA); ComputeDs(&(groupB), GroupB, SwappedToB); #endif /* !KS_MODE */ /* for all pairs of nodes in A,B */ for (p = 0; p<numModules/2; p++) { #ifdef KS_MODE /* compute the swap costs */ ComputeDs(&(groupA), GroupA, SwappedToA); ComputeDs(&(groupB), GroupB, SwappedToB); #endif /* KS_MODE */ /* find the max swap opportunity, and swap */ GP[p] = FindMaxGpAndSwap(); } /* lists should both be empty now */ assert(groupA.head == NULL && groupA.tail == NULL); assert(groupB.head == NULL && groupB.tail == NULL); gMax = FindGMax(&iMax); /* debug/statistics */ if (lastGMax == gMax) fprintf(stdout, "No progress: gMax = %f\n", gMax); lastGMax = gMax; fprintf(stdout, "gMax = %f, iMax = %lu\n", gMax, iMax); if (gMax > 0.0) SwapSubsetAndReset(iMax); PrintResults(0); } while (gMax > 0.0); /* progress made? */ /* all swaps rejected */ groupA = swapToB; for (mr = groupA.head; mr != NULL; mr = (*mr).next) moduleToGroup[(*mr).module] = GroupA; groupB = swapToA; for (mr = groupB.head; mr != NULL; mr = (*mr).next) moduleToGroup[(*mr).module] = GroupB; ; /* all done, show results */ PrintResults(1); #ifdef PLUS_STATS PrintDerefStats(stderr); PrintHeapSize(stderr); #endif /* PLUS_STATS */ exit(0); return 0; // sm: silence warning }
//---------------------------------------------------------------------- // This is the Main routine for thermodl. // int main() //short argc, char **argv) { int Fahrenheit=FALSE,filenum,num,i,j; char return_msg[128]; FILE *fp; ThermoStateType ThermoState; uchar ThermoSN[MAXDEVICES][8]; //the serial numbers for the devices int portnum=0; // check arguments to see if request instruction with '?' or too many if ((argc < 2) || (argc > 4) || ((argc > 1) && (argv[1][0] == '?' || argv[1][1] == '?'))) ExitProg("\nusage: thermodl 1wire_net_name <output_filename> </Fahrenheit>\n" " - Thermochron download on the 1-Wire Net port\n" " - 1wire_net_port required port name\n" " example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" \n" " (Linux DS2480),\"1\" (Win32 TMEX)\n" " - <output_filename> optional output filename\n" " - </Fahrenheit> optional Fahrenheit mode (default Celsius)\n" " - version 2.00\n",1); // attempt to acquire the 1-Wire Net if (!owAcquire(portnum,argv[1],return_msg)) ExitProg(return_msg,1); // success printf("%s",return_msg); //---------------------------------------- // Introduction printf("\n/----------------------------------------------\n"); printf(" Find and download DS1921 Thermochron iButton(s)\n" " Version 2.00\n\n"); // check arguments for temperature conversion and filename Fahrenheit = FALSE; filenum = 0; if (argc >= 3) { if (argv[2][0] != '/') filenum = 2; else if ((argv[2][1] == 'F') || (argv[2][1] == 'f')) Fahrenheit = TRUE; if (argc == 4) { if (argv[3][0] != '/') filenum = 3; else if ((argv[3][1] == 'F') || (argv[3][1] == 'f')) Fahrenheit = TRUE; } } // open the output file fp = NULL; if (filenum > 0) { fp = fopen(argv[filenum],"w+"); if(fp == NULL) { printf("ERROR, Could not open output file!\n"); exit(1); } else printf("File '%s' opened to write mission results.\n", argv[filenum]); } // get list of Thermochron's num = FindDevices(portnum, &ThermoSN[0],THERMO_FAM, MAXDEVICES); // check if not present or more then 1 present if (num == 0) ExitProg("Thermochron not present on 1-Wire\n",1); // loop to download each Thermochron for (i = 0; i < num; i++) { // set the serial number portion in the thermo state printf("\nDownloading: "); for (j = 7; j >= 0; j--) { ThermoState.MissStat.serial_num[j] = ThermoSN[i][j]; printf("%02X",ThermoSN[i][j]); } printf("\n"); // download the Thermochron found if (DownloadThermo(portnum,&ThermoSN[i][0],&ThermoState,stdout)) { // interpret the results of the download InterpretStatus(&ThermoState.MissStat); InterpretAlarms(&ThermoState.AlarmData, &ThermoState.MissStat); InterpretHistogram(&ThermoState.HistData); InterpretLog(&ThermoState.LogData, &ThermoState.MissStat); // print the output PrintResults(&ThermoState,fp,Fahrenheit); } else { fprintf(fp,"\nError downloading device: "); for (j = 0; j < 8; j++) fprintf(fp,"%02X",ThermoSN[i][j]); fprintf(fp,"\n"); } } // close opened file if (fp != NULL) { printf("File '%s' closed.\n", argv[filenum]); fclose(fp); } // release the 1-Wire Net //owRelease(portnum,return_msg); printf("\n%s",return_msg); ExitProg("End program normally\n",0); return 0; }
void ProcessLineTestEvent( VpEventType *pEvent) { VpStatusType status = VP_STATUS_SUCCESS; LtTestStatusType ltStatus = LT_STATUS_RUNNING; VpResultsType vpResults; LtEventType ltEvent; /* create LT-API event struct */ ltEvent.pVpEvent = pEvent; /* get vp-api result if available */ if (pEvent->hasResults) { status = VpGetResults(pEvent, &vpResults); if (status != VP_STATUS_SUCCESS) { QS_DEBUG("VpGetResult() failed: %i\n", status); return; } ltEvent.pResult = &vpResults; } else { ltEvent.pResult = NULL; } /* process the event */ ltStatus = LtEventHandler(&gTestCtx, <Event); switch (ltStatus) { case LT_STATUS_DONE: /* Test has completed - parse the results */ PrintResults(ltStatus, &gTestResults); /* we are done with the current test*/ plineCtxUnderTest = NULL; /* run another test */ switch (gTestResults.testId) { case LT_TID_LINE_V: StartLineTest(0, LT_TID_ROH); break; case LT_TID_ROH: StartLineTest(0, LT_TID_RINGERS); break; default: exit(1); } break; case LT_STATUS_RUNNING: case LT_STATUS_ABORTED: /* * If the line test is running or aborting the application must * continue to call the LT-API event handler on subsequent events. */ break; default: /* All other status indications are errors */ break; } return; }