int main(int argc, char *argv[]) { long i; graph G; double runtime; inputCheck(argc, argv); if(N == 1){ generateTestGraph(&G); } else { generateGraph(N, randInit, &G, 0); } tick(); dijkstra(&G, 0, 0); runtime = tack(); // char *b; b = malloc(G.N * 5); if(b == NULL) {perror("malloc"); exit(EXIT_FAILURE); } sprintf(b,"\nLowest distances!\nD=["); for(i = 0; i<G.N; i++){ sprintf(&b[strlen(b)], "%d,", G.D[i]); } printf("%s]\n", b); printf("Was working for [%f] sec.\n",runtime); return EXIT_SUCCESS; }
int main(int argc, char** argv) { point* points; distance solution; double elapsedTime; points = NULL; inputCheck(argc, argv); printf("Generating [%d] points\n", np); if( generatePoints(np, &points) != EXIT_SUCCESS ){ printf("Generating Points failed!\n"); exit(EXIT_FAILURE); } tick(); mpiInit(argc, argv); if( prepareMPIComm() ) { if(mpi_id == 0) { printf("Starting search ..."); } multiSearch(np, points, &solution); elapsedTime = tack(); //printf("Found Solution a[%f,%f] , b[%f,%f] distance [%0.10f]\n", solution.a.x, solution.a.y, solution.b.x, solution.b.y, solution.d); if(mpi_id == 0){ printf("Completed Search and found closest points at [%g, %g] , [%g, %g] with a distance of [%g]\n", mpi_id\ , solution.a.x ,solution.a.y, solution.b.x, solution.b.y , solution.d); printf("Operation took %f seconds \n", elapsedTime); free(points); } } else { } mpiFinish(); exit(EXIT_SUCCESS); }
int main(int argc, char * argv[]) { //checks to make sure that there are 2 arguments - one for input and output inputCheck(argv); //Get the input file name... char *inputFileName = *(argv + 1); char *outputFileName = *(argv + 2); //Find out how many students are on the input file... int numberOfStudents = getRecordCount(inputFileName); //Create the number of students depending on the record count... Student listOfStudents[numberOfStudents]; createStudents(listOfStudents, numberOfStudents); //Read the data of the input file... FILE *myFile = openFile(inputFileName); //Fill out all the student's info... fillStudentRecord(myFile, listOfStudents, numberOfStudents); //sortStudents using the array of student struct sortStudents(listOfStudents, numberOfStudents); //Calculate each student's GPA and recorded in the structure... getGPA(listOfStudents, numberOfStudents); //Calculate each student's Letter Grade and record in the structure... getGrade(listOfStudents, numberOfStudents); //Create ClassGrade structure pointer... ClassGrade *classGrade; classGrade = (ClassGrade *)malloc((sizeof classGrade) * 20); //Call functions to calculate the scores... getScoreAverage(listOfStudents, classGrade, numberOfStudents); getMinScore(listOfStudents, classGrade, numberOfStudents); getMaxScore(listOfStudents, classGrade, numberOfStudents); //Generate and output file with the student grade information generateOutputFile(outputFileName, inputFileName, listOfStudents, numberOfStudents); //Print out student's info... printAllStudents(listOfStudents, classGrade, numberOfStudents, inputFileName, outputFileName); return 0; }
int main(int argc, char **argv){ char operator; int incheck; struct node *number1; struct node *number2; struct node *result; char outputBase; if(argc == 1){ fprintf(stderr, "ERROR: Too few inputs\n"); return 0; } incheck = inputCheck(argv); if (incheck == -1) return 0; outputBase = argv[4][0]; if (strcmp(argv[1], "-h") == 0){ printhelp(); return 0; } operator = argv[1][0]; number1 = convert(argv[2]); number2 = convert(argv[3]); if(outputBase == 'd'){ if(operator == '+') result = quicksum(number1, number2); else if (operator == '-') result = quicksub(number1, number2); else{ fprintf(stderr, "ERROR: Bad operator!\n"); return 0; } printf("d"); printint(number1->num+number2->num); return 0; } if (operator == '+') result = add(number1, number2); else if (operator == '-') result = subtract(number1, number2); else{ fprintf(stderr, "ERROR: Bad operator!\n"); return 0; } print(result, outputBase); printf("\n"); return 0; }
void GenericOCIO::changedParam(const OFX::InstanceChangedArgs &args, const std::string ¶mName) { assert(_created); #ifdef OFX_IO_USING_OCIO if (paramName == kOCIOParamConfigFile) { // compute canonical inputSpace and outputSpace before changing the config, // if different from inputSpace and outputSpace they must be set to the canonical value after changing ocio config std::string inputSpace; getInputColorspaceAtTime(args.time, inputSpace); std::string inputSpaceCanonical = canonicalizeColorSpace(_config, inputSpace); if (inputSpaceCanonical != inputSpace) { _inputSpace->setValue(inputSpaceCanonical); } std::string outputSpace; getOutputColorspaceAtTime(args.time, outputSpace); std::string outputSpaceCanonical = canonicalizeColorSpace(_config, outputSpace); if (outputSpaceCanonical != outputSpace) { _outputSpace->setValue(outputSpaceCanonical); } loadConfig(); // re-load the new OCIO config //if inputspace or outputspace are not valid in the new config, reset them to "default" if (_config) { std::string inputSpaceName; getInputColorspaceAtTime(args.time, inputSpaceName); int inputSpaceIndex = _config->getIndexForColorSpace(inputSpaceName.c_str()); if (inputSpaceIndex < 0) { _inputSpace->setValue(OCIO_NAMESPACE::ROLE_DEFAULT); } } inputCheck(args.time); if (_config) { std::string outputSpaceName; getOutputColorspaceAtTime(args.time, outputSpaceName); int outputSpaceIndex = _config->getIndexForColorSpace(outputSpaceName.c_str()); if (outputSpaceIndex < 0) { _outputSpace->setValue(OCIO_NAMESPACE::ROLE_DEFAULT); } } outputCheck(args.time); if (!_config && args.reason == OFX::eChangeUserEdit) { std::string filename; _ocioConfigFile->getValue(filename); _parent->sendMessage(OFX::Message::eMessageError, "", std::string("Cannot load OCIO config file \"") + filename + '"'); } } else if (paramName == kOCIOHelpButton || paramName == kOCIOHelpLooksButton || paramName == kOCIOHelpDisplaysButton) { std::string msg = "OpenColorIO Help\n" "The OCIO configuration file can be set using the \"OCIO\" environment variable, which should contain the full path to the .ocio file.\n" "OpenColorIO version (compiled with / running with): " OCIO_VERSION "/"; msg += OCIO_NAMESPACE::GetVersion(); msg += '\n'; if (_config) { std::string configdesc = _config->getDescription(); configdesc = whitespacify(trim(configdesc)); if ( configdesc.size() > 0 ) { msg += "\nThis OCIO configuration is "; msg += configdesc; msg += '\n'; } msg += '\n'; if (paramName == kOCIOHelpLooksButton) { msg += (_config->getNumLooks() <= 0 ? "No look available in this OCIO configuration.\n" : "Available looks in this OCIO Configuration (applied in the given colorspace):\n"); for (int i = 0; i < _config->getNumLooks(); ++i) { const char* lkname = _config->getLookNameByIndex(i); OCIO_NAMESPACE::ConstLookRcPtr lk = _config->getLook(lkname); msg += "- "; msg += lkname; std::string lkspace = lk->getProcessSpace(); msg += " (" + lkspace + ")\n"; } msg += '\n'; } if (paramName == kOCIOHelpDisplaysButton) { if (_config->getNumDisplays() <= 0) { msg += "No display available in this OCIO configuration.\n"; } else { msg += "Available displays and views in this OCIO Configuration:\n"; std::string defaultdisplay = _config->getDefaultDisplay(); for (int i = 0; i < _config->getNumDisplays(); ++i) { const char* display = _config->getDisplay(i); msg += "- "; msg += display; if (display == defaultdisplay) { msg += " (default)"; } int numViews = _config->getNumViews(display); if (numViews <= 0) { msg += ", no view available.\n"; } else { msg += ", views: "; std::string defaultview = _config->getDefaultView(display); for (int j = 0; j < numViews; ++j) { const char* view = _config->getView(display, j); msg += view; if (view == defaultview) { msg += " (default)"; } if (j < numViews-1) { msg += ", "; } } msg += '\n'; } } } msg += '\n'; } msg += "Available colorspaces in this OCIO Configuration:\n"; int defaultcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_DEFAULT); int referencecs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_REFERENCE); int datacs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_DATA); int colorpickingcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_COLOR_PICKING); int scenelinearcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_SCENE_LINEAR); int compositinglogcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_COMPOSITING_LOG); int colortimingcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_COLOR_TIMING); int texturepaintcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_TEXTURE_PAINT); int mattepaintcs = _config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_MATTE_PAINT); for (int i = 0; i < _config->getNumColorSpaces(); ++i) { const char* csname = _config->getColorSpaceNameByIndex(i);; OCIO_NAMESPACE::ConstColorSpaceRcPtr cs = _config->getColorSpace(csname); msg += "- "; msg += csname; bool first = true; //int roles = 0; if (i == defaultcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_DEFAULT; first = false; //++roles; } if (i == referencecs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_REFERENCE; first = false; //++roles; } if (i == datacs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_DATA; first = false; //++roles; } if (i == colorpickingcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_COLOR_PICKING; first = false; //++roles; } if (i == scenelinearcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_SCENE_LINEAR; first = false; //++roles; } if (i == compositinglogcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_COMPOSITING_LOG; first = false; //++roles; } if (i == colortimingcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_COLOR_TIMING; first = false; //++roles; } if (i == texturepaintcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_TEXTURE_PAINT; first = false; //++roles; } if (i == mattepaintcs) { msg += first ? " (" : ", "; msg += OCIO_NAMESPACE::ROLE_MATTE_PAINT; first = false; //++roles; } if (!first /*&& roles > 0*/) { msg += ')'; } std::string csdesc = cs ? cs->getDescription() : "(no colorspace)"; csdesc = whitespacify(trim(csdesc)); if ( !csdesc.empty() ) { msg += ": "; msg += csdesc; msg += '\n'; } else { msg += '\n'; } } } _parent->sendMessage(OFX::Message::eMessageMessage, "", msg); } else if (!_config) { // the other parameters assume there is a valid config return; } else if (paramName == kOCIOParamInputSpace) { assert(_inputSpace); if (args.reason == OFX::eChangeUserEdit) { // if the inputspace doesn't correspond to a valid one, reset to default. // first, canonicalize. std::string inputSpace; getInputColorspaceAtTime(args.time, inputSpace); std::string inputSpaceCanonical = canonicalizeColorSpace(_config, inputSpace); if (inputSpaceCanonical != inputSpace) { _inputSpace->setValue(inputSpaceCanonical); inputSpace = inputSpaceCanonical; } int inputSpaceIndex = _config->getIndexForColorSpace(inputSpace.c_str()); if (inputSpaceIndex < 0) { if (args.reason == OFX::eChangeUserEdit) { _parent->sendMessage(OFX::Message::eMessageWarning, "", std::string("Unknown OCIO colorspace \"")+inputSpace+"\""); } OCIO::ConstColorSpaceRcPtr colorspace = _config->getColorSpace(OCIO_NAMESPACE::ROLE_DEFAULT); if (colorspace) { inputSpace = colorspace->getName(); _inputSpace->setValue(inputSpace); } } } inputCheck(args.time); } #ifdef OFX_OCIO_CHOICE else if ( paramName == kOCIOParamInputSpaceChoice && args.reason == OFX::eChangeUserEdit) { assert(_inputSpace); int inputSpaceIndex; _inputSpaceChoice->getValueAtTime(args.time, inputSpaceIndex); std::string inputSpaceOld; getInputColorspaceAtTime(args.time, inputSpaceOld); std::string inputSpace = canonicalizeColorSpace(_config, _config->getColorSpaceNameByIndex(inputSpaceIndex)); // avoid an infinite loop on bad hosts (for examples those which don't set args.reason correctly) if (inputSpace != inputSpaceOld) { _inputSpace->setValue(inputSpace); } } #endif else if (paramName == kOCIOParamOutputSpace) { assert(_outputSpace); if (args.reason == OFX::eChangeUserEdit) { // if the outputspace doesn't correspond to a valid one, reset to default. // first, canonicalize. std::string outputSpace; getOutputColorspaceAtTime(args.time, outputSpace); std::string outputSpaceCanonical = canonicalizeColorSpace(_config, outputSpace); if (outputSpaceCanonical != outputSpace) { _outputSpace->setValue(outputSpaceCanonical); outputSpace = outputSpaceCanonical; } int outputSpaceIndex = _config->getIndexForColorSpace(outputSpace.c_str()); if (outputSpaceIndex < 0) { if (args.reason == OFX::eChangeUserEdit) { _parent->sendMessage(OFX::Message::eMessageWarning, "", std::string("Unknown OCIO colorspace \"")+outputSpace+"\""); } outputSpace = _config->getColorSpace(OCIO_NAMESPACE::ROLE_DEFAULT)->getName(); _outputSpace->setValue(outputSpace); outputSpaceIndex = _config->getIndexForColorSpace(outputSpace.c_str()); assert(outputSpaceIndex >= 0); } } outputCheck(args.time); } #ifdef OFX_OCIO_CHOICE else if ( paramName == kOCIOParamOutputSpaceChoice && args.reason == OFX::eChangeUserEdit) { assert(_outputSpace); int outputSpaceIndex; _outputSpaceChoice->getValueAtTime(args.time, outputSpaceIndex); std::string outputSpaceOld; getOutputColorspaceAtTime(args.time, outputSpaceOld); std::string outputSpace = canonicalizeColorSpace(_config, _config->getColorSpaceNameByIndex(outputSpaceIndex)); // avoid an infinite loop on bad hosts (for examples those which don't set args.reason correctly) if (outputSpace != outputSpaceOld) { _outputSpace->setValue(outputSpace); } } #endif // OFX_OCIO_CHOICE #endif }
GenericOCIO::GenericOCIO(OFX::ImageEffect* parent) : _parent(parent) , _created(false) #ifdef OFX_IO_USING_OCIO , _ocioConfigFileName() , _ocioConfigFile(0) , _inputSpace(0) , _outputSpace(0) #ifdef OFX_OCIO_CHOICE , _choiceIsOk(true) , _choiceFileName() , _inputSpaceChoice(0) , _outputSpaceChoice(0) #endif , _contextKey1(0) , _contextValue1(0) , _contextKey2(0) , _contextValue2(0) , _contextKey3(0) , _contextValue3(0) , _contextKey4(0) , _contextValue4(0) , _config() #endif { #ifdef OFX_IO_USING_OCIO _ocioConfigFile = _parent->fetchStringParam(kOCIOParamConfigFile); if (_parent->paramExists(kOCIOParamInputSpace)) { _inputSpace = _parent->fetchStringParam(kOCIOParamInputSpace); } if (_parent->paramExists(kOCIOParamOutputSpace)) { _outputSpace = _parent->fetchStringParam(kOCIOParamOutputSpace); } #ifdef OFX_OCIO_CHOICE _ocioConfigFile->getDefault(_choiceFileName); if (_inputSpace) { _inputSpaceChoice = _parent->fetchChoiceParam(kOCIOParamInputSpaceChoice); } if (_outputSpace) { _outputSpaceChoice = _parent->fetchChoiceParam(kOCIOParamOutputSpaceChoice); } #endif loadConfig(); #ifdef OFX_OCIO_CHOICE if (!_config) { # ifndef OFX_OCIO_NOSECRET if (_inputSpace) { _inputSpaceChoice->setIsSecret(true); } if (_outputSpace) { _outputSpaceChoice->setIsSecret(true); } # endif } #endif if (_parent->paramExists(kOCIOParamContextKey1)) { _contextKey1 = _parent->fetchStringParam(kOCIOParamContextKey1); _contextValue1 = _parent->fetchStringParam(kOCIOParamContextValue1); _contextKey2 = _parent->fetchStringParam(kOCIOParamContextKey2); _contextValue2 = _parent->fetchStringParam(kOCIOParamContextValue2); _contextKey3 = _parent->fetchStringParam(kOCIOParamContextKey3); _contextValue3 = _parent->fetchStringParam(kOCIOParamContextValue3); _contextKey4 = _parent->fetchStringParam(kOCIOParamContextKey4); _contextValue4 = _parent->fetchStringParam(kOCIOParamContextValue4); assert(_contextKey1 && _contextKey2 && _contextKey3 && _contextKey4); assert(_contextValue1 && _contextValue2 && _contextValue3 && _contextValue4); } #endif // setup the GUI // setValue() may be called from createInstance, according to // http://openfx.sourceforge.net/Documentation/1.3/ofxProgrammingReference.html#SettingParams inputCheck(0.); outputCheck(0.); _created = true; }
int main(int argc, char **argv) { long i; graph G; char debugFlag = 0; debugFlag=0; MPI_Init(&argc, &argv); MPI_Comm_rank (MPI_COMM_WORLD, &mpi_id); /* get current process id */ MPI_Comm_size (MPI_COMM_WORLD, &mpi_size); /* get number of processes */ inputCheck(argc, argv); if(mpi_id == 0) { if(N == 1){ generateTestGraph(&G); } else { generateGraph(N, randInit, &G, debugFlag); } } else { if(N == 1) N = 6; generateEmptyGraph(N, &G); } N = G.N; if(debugFlag){ enableDebug(N); } if((debugFlag == 1) && (mpi_id == 0) ){ printf("Using graph\n"); printGraph(&G); } if(mpi_id == 0) printf("\nTesting with max 2 Threads\n"); testScheduler(2,&G, debugFlag); if(mpi_id == 0) printf("\nTesting with max 4 Threads\n"); testScheduler(4,&G, debugFlag); if(mpi_id == 0) printf("\nTesting with max 8 Threads\n"); testScheduler(8,&G, debugFlag); // omp_set_num_threads(4); // omp_set_schedule(omp_sched_static, 2); // dijkstra(&G, 0, 0); // char *b; // b = malloc(G.N * 5); // if(b == NULL) {perror("malloc"); exit(EXIT_FAILURE); } // sprintf(b,"\nLowest distances!\nD=["); // for(i = 0; i<G.N; i++){ // sprintf(&b[strlen(b)], "%d,", G.D[i]); // } // printf("%s]\n", b); MPI_Finalize(); return EXIT_SUCCESS; }