/** @brief Create a CUDPP plan * * A plan is a data structure containing state and intermediate storage space * that CUDPP uses to execute algorithms on data. A plan is created by * passing to cudppPlan() a CUDPPConfiguration that specifies the algorithm, * operator, datatype, and options. The size of the data must also be passed * to cudppPlan(), in the \a numElements, \a numRows, and \a rowPitch * arguments. These sizes are used to allocate internal storage space at the * time the plan is created. The CUDPP planner may use the sizes, options, * and information about the present hardware to choose optimal settings. * * Note that \a numElements is the maximum size of the array to be processed * with this plan. That means that a plan may be re-used to process (for * example, to sort or scan) smaller arrays. * * @param[out] planHandle A pointer to an opaque handle to the internal plan * @param[in] config The configuration struct specifying algorithm and options * @param[in] numElements The maximum number of elements to be processed * @param[in] numRows The number of rows (for 2D operations) to be processed * @param[in] rowPitch The pitch of the rows of input data, in elements */ CUDPP_DLL CUDPPResult cudppPlan(CUDPPHandle *planHandle, CUDPPConfiguration config, size_t numElements, size_t numRows, size_t rowPitch) { CUDPPResult result = CUDPP_SUCCESS; CUDPPPlan *plan; result = validateOptions(config, numElements, numRows, rowPitch); if (result != CUDPP_SUCCESS) { *planHandle = CUDPP_INVALID_HANDLE; return result; } switch (config.algorithm) { case CUDPP_SCAN: { plan = new CUDPPScanPlan(config, numElements, numRows, rowPitch); break; } // case CUDPP_COMPACT: // { // plan = new CUDPPCompactPlan(config, numElements, numRows, rowPitch); // break; // } case CUDPP_SORT_RADIX: //case CUDPP_SORT_RADIX_GLOBAL: { plan = new CUDPPRadixSortPlan(config, numElements); break; } /* case CUDPP_SEGMENTED_SCAN: { plan = new CUDPPSegmentedScanPlan(config, numElements); break; } //new rand plan case CUDPP_RAND_MD5: { plan = new CUDPPRandPlan(config, numElements); break; } case CUDPP_REDUCE:*/ default: //! @todo: implement cudppReduce() return CUDPP_ERROR_ILLEGAL_CONFIGURATION; break; } *planHandle = CUDPPPlanManager::AddPlan(plan); if (CUDPP_INVALID_HANDLE == *planHandle) return CUDPP_ERROR_UNKNOWN; else return CUDPP_SUCCESS; }
ExceptionOr<void> MutationObserver::observe(Node& node, const Init& init) { MutationObserverOptions options = 0; if (init.childList) options |= ChildList; if (init.subtree) options |= Subtree; if (init.attributeOldValue.value_or(false)) options |= AttributeOldValue; if (init.characterDataOldValue.value_or(false)) options |= CharacterDataOldValue; HashSet<AtomicString> attributeFilter; if (init.attributeFilter) { for (auto& value : init.attributeFilter.value()) attributeFilter.add(value); options |= AttributeFilter; } if (init.attributes ? init.attributes.value() : (options & (AttributeFilter | AttributeOldValue))) options |= Attributes; if (init.characterData ? init.characterData.value() : (options & CharacterDataOldValue)) options |= CharacterData; if (!validateOptions(options)) return Exception { TypeError }; node.registerMutationObserver(this, options, attributeFilter); return { }; }
void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter, ExceptionCode& ec) { if (!node) { ec = NOT_FOUND_ERR; return; } if (!validateOptions(options)) { // FIXME: Revisit this once the spec specifies the exception type; SYNTAX_ERR may not be appropriate. ec = SYNTAX_ERR; return; } MutationObserverRegistration* registration = node->registerMutationObserver(this); registration->resetObservation(options, attributeFilter); node->document()->addMutationObserverTypes(registration->mutationTypes()); }
void WebKitMutationObserver::observe(Node* node, const Dictionary& optionsDictionary, ExceptionCode& ec) { if (!node) { ec = NOT_FOUND_ERR; return; } if (optionsDictionary.isUndefinedOrNull()) { ec = TYPE_MISMATCH_ERR; return; } static const struct { const char* name; MutationObserverOptions value; } booleanOptions[] = { { "childList", WebKitMutationObserver::ChildList }, { "attributes", WebKitMutationObserver::Attributes }, { "characterData", WebKitMutationObserver::CharacterData }, { "subtree", WebKitMutationObserver::Subtree }, { "attributeOldValue", WebKitMutationObserver::AttributeOldValue }, { "characterDataOldValue", WebKitMutationObserver::CharacterDataOldValue } }; MutationObserverOptions options = 0; for (unsigned i = 0; i < sizeof(booleanOptions) / sizeof(booleanOptions[0]); ++i) { bool value = false; if (optionsDictionary.get(booleanOptions[i].name, value) && value) options |= booleanOptions[i].value; } HashSet<AtomicString> attributeFilter; if (optionsDictionary.get("attributeFilter", attributeFilter)) options |= WebKitMutationObserver::AttributeFilter; if (!validateOptions(options)) { ec = SYNTAX_ERR; return; } MutationObserverRegistration* registration = node->registerMutationObserver(this); registration->resetObservation(options, attributeFilter); node->document()->addMutationObserverTypes(registration->mutationTypes()); }
void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary, ExceptionCode& ec) { if (!node) { ec = NOT_FOUND_ERR; return; } static const struct { const char* name; MutationObserverOptions value; } booleanOptions[] = { { "childList", ChildList }, { "attributes", Attributes }, { "characterData", CharacterData }, { "subtree", Subtree }, { "attributeOldValue", AttributeOldValue }, { "characterDataOldValue", CharacterDataOldValue } }; MutationObserverOptions options = 0; for (unsigned i = 0; i < sizeof(booleanOptions) / sizeof(booleanOptions[0]); ++i) { bool value = false; if (optionsDictionary.get(booleanOptions[i].name, value) && value) options |= booleanOptions[i].value; } HashSet<AtomicString> attributeFilter; if (optionsDictionary.get("attributeFilter", attributeFilter)) options |= AttributeFilter; if (!validateOptions(options)) { ec = SYNTAX_ERR; return; } node->registerMutationObserver(this, options, attributeFilter); }
QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* parent, const QString& format, QgsRasterFormatSaveOptionsWidget::Type type, const QString& provider ) : QWidget( parent ) , mFormat( format ) , mProvider( provider ) , mRasterLayer( nullptr ) , mRasterFileName( QString() ) , mPyramids( false ) , mPyramidsFormat( QgsRaster::PyramidsGTiff ) { setupUi( this ); setType( type ); if ( mBuiltinProfiles.isEmpty() ) { // key=profileKey values=format,profileName,options mBuiltinProfiles[ "z_adefault" ] = ( QStringList() << "" << tr( "Default" ) << "" ); // these GTiff profiles are based on Tim's benchmarks at // http://linfiniti.com/2011/05/gdal-efficiency-of-various-compression-algorithms/ // big: no compression | medium: reasonable size/speed tradeoff | small: smallest size mBuiltinProfiles[ "z_gtiff_1big" ] = ( QStringList() << "GTiff" << tr( "No compression" ) << "COMPRESS=NONE BIGTIFF=IF_NEEDED" ); mBuiltinProfiles[ "z_gtiff_2medium" ] = ( QStringList() << "GTiff" << tr( "Low compression" ) << "COMPRESS=PACKBITS" ); mBuiltinProfiles[ "z_gtiff_3small" ] = ( QStringList() << "GTiff" << tr( "High compression" ) << "COMPRESS=DEFLATE PREDICTOR=2 ZLEVEL=9" ); mBuiltinProfiles[ "z_gtiff_4jpeg" ] = ( QStringList() << "GTiff" << tr( "JPEG compression" ) << "COMPRESS=JPEG JPEG_QUALITY=75" ); // overview compression schemes for GTiff format, see // http://www.gdal.org/gdaladdo.html and http://www.gdal.org/frmt_gtiff.html // TODO - should we offer GDAL_TIFF_OVR_BLOCKSIZE option here or in QgsRasterPyramidsOptionsWidget ? mBuiltinProfiles[ "z__pyramids_gtiff_1big" ] = ( QStringList() << "_pyramids" << tr( "No compression" ) << "COMPRESS_OVERVIEW=NONE BIGTIFF_OVERVIEW=IF_NEEDED" ); mBuiltinProfiles[ "z__pyramids_gtiff_2medium" ] = ( QStringList() << "_pyramids" << tr( "Low compression" ) << "COMPRESS_OVERVIEW=PACKBITS" ); mBuiltinProfiles[ "z__pyramids_gtiff_3small" ] = ( QStringList() << "_pyramids" << tr( "High compression" ) << "COMPRESS_OVERVIEW=DEFLATE PREDICTOR_OVERVIEW=2 ZLEVEL=9" ); // how to set zlevel? mBuiltinProfiles[ "z__pyramids_gtiff_4jpeg" ] = ( QStringList() << "_pyramids" << tr( "JPEG compression" ) << "JPEG_QUALITY_OVERVIEW=75 COMPRESS_OVERVIEW=JPEG PHOTOMETRIC_OVERVIEW=YCBCR INTERLEAVE_OVERVIEW=PIXEL" ); } connect( mProfileComboBox, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( updateOptions() ) ); connect( mOptionsTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( optionsTableChanged() ) ); connect( mOptionsHelpButton, SIGNAL( clicked() ), this, SLOT( helpOptions() ) ); connect( mOptionsValidateButton, SIGNAL( clicked() ), this, SLOT( validateOptions() ) ); // create eventFilter to map right click to swapOptionsUI() // mOptionsLabel->installEventFilter( this ); mOptionsLineEdit->installEventFilter( this ); mOptionsStackedWidget->installEventFilter( this ); updateControls(); updateProfiles(); QgsDebugMsg( "done" ); }
/** @brief Create a CUDPP plan * * A plan is a data structure containing state and intermediate storage space * that CUDPP uses to execute algorithms on data. A plan is created by * passing to cudppPlan() a CUDPPConfiguration that specifies the algorithm, * operator, datatype, and options. The size of the data must also be passed * to cudppPlan(), in the \a numElements, \a numRows, and \a rowPitch * arguments. These sizes are used to allocate internal storage space at the * time the plan is created. The CUDPP planner may use the sizes, options, * and information about the present hardware to choose optimal settings. * * Note that \a numElements is the maximum size of the array to be processed * with this plan. That means that a plan may be re-used to process (for * example, to sort or scan) smaller arrays. * * @param[out] planHandle A pointer to an opaque handle to the internal plan * @param[in] cudppHandle A handle to an instance of the CUDPP library used for resource management * @param[in] config The configuration struct specifying algorithm and options * @param[in] numElements The maximum number of elements to be processed * @param[in] numRows The number of rows (for 2D operations) to be processed * @param[in] rowPitch The pitch of the rows of input data, in elements * @returns CUDPPResult indicating success or error condition */ CUDPP_DLL CUDPPResult cudppPlan(const CUDPPHandle cudppHandle, CUDPPHandle *planHandle, CUDPPConfiguration config, size_t numElements, size_t numRows, size_t rowPitch) { CUDPPResult result = CUDPP_SUCCESS; CUDPPPlan *plan; CUDPPManager *mgr = CUDPPManager::getManagerFromHandle(cudppHandle); result = validateOptions(config, numElements, numRows, rowPitch); if (result != CUDPP_SUCCESS) { *planHandle = CUDPP_INVALID_HANDLE; return result; } switch (config.algorithm) { case CUDPP_SCAN: { plan = new CUDPPScanPlan(mgr, config, numElements, numRows, rowPitch); break; } case CUDPP_COMPACT: { plan = new CUDPPCompactPlan(mgr, config, numElements, numRows, rowPitch); break; } case CUDPP_SORT_RADIX: { plan = new CUDPPRadixSortPlan(mgr, config, numElements); break; } case CUDPP_SORT_MERGE: { plan = new CUDPPMergeSortPlan(mgr, config, numElements); break; } case CUDPP_SORT_STRING: { plan = new CUDPPStringSortPlan(mgr, config, numElements, rowPitch); break; } case CUDPP_SEGMENTED_SCAN: { plan = new CUDPPSegmentedScanPlan(mgr, config, numElements); break; } case CUDPP_RAND_MD5: { plan = new CUDPPRandPlan(mgr, config, numElements); break; } case (CUDPP_TRIDIAGONAL): { plan = new CUDPPTridiagonalPlan(mgr, config); break; } case CUDPP_REDUCE: { plan = new CUDPPReducePlan(mgr, config, numElements); break; } case CUDPP_COMPRESS: { plan = new CUDPPCompressPlan(mgr, config, numElements); break; } case CUDPP_BWT: { plan = new CUDPPBwtPlan(mgr, config, numElements); break; } case CUDPP_MTF: { plan = new CUDPPMtfPlan(mgr, config, numElements); break; } case CUDPP_LISTRANK: { plan = new CUDPPListRankPlan(mgr, config, numElements); break; } case CUDPP_SA: { plan = new CUDPPSaPlan(mgr, config, numElements); break; } case CUDPP_MULTISPLIT: { plan = new CUDPPMultiSplitPlan(mgr, config, numElements, numRows); break; } default: return CUDPP_ERROR_ILLEGAL_CONFIGURATION; break; } if (!plan) return CUDPP_ERROR_UNKNOWN; else { *planHandle = plan->getHandle(); return CUDPP_SUCCESS; } }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * MAIN */ int main(int argc, char ** argv) { FILE* outFp; optionProcess(&getdefsOptions, argc, argv); validateOptions(); outFp = startAutogen(); doPreamble(outFp); /* * Process each input file */ { int ct = STACKCT_OPT(INPUT); char const ** ppz = STACKLST_OPT(INPUT); do { processFile(*ppz++); } while (--ct > 0); } /* * IF we don't have an ordering file, but we do have a "first index", * THEN alphabetize by definition name. */ if ((pzIndexText == NULL) && HAVE_OPT(FIRST_INDEX)) { qsort((void*)papzBlocks, blkUseCt, sizeof(char*), compar_defname); set_first_idx(); } else if (ENABLED_OPT(ORDERING) && (blkUseCt > 1)) qsort((void*)papzBlocks, blkUseCt, sizeof(char*), &compar_text); printEntries(outFp); fclose(outFp); /* * IF output is to a file * THEN set the permissions and modification times */ if ( (WHICH_IDX_AUTOGEN == INDEX_OPT_OUTPUT) && (outFp != stdout) ) { struct utimbuf tbuf; tbuf.actime = time((time_t*)NULL); tbuf.modtime = modtime + 1; utime(OPT_ARG(OUTPUT), &tbuf); chmod(OPT_ARG(OUTPUT), S_IRUSR|S_IRGRP|S_IROTH); } /* * IF we are keeping a database of indexes * AND we have augmented the contents, * THEN append the new entries to the file. */ if ((pzIndexText != NULL) && (pzEndIndex != pzIndexEOF)) updateDatabase(); if (agPid != -1) return awaitAutogen(); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { struct myoptions Opt = initOptions(); static struct option longOptions[] = { {"uppertriangular", no_argument, &Opt.uppertriangular, 1}, {"bidirectional", no_argument, &Opt.bidirectional, 1}, {"selfloops", required_argument, 0, 's'}, {"duplicatededges", required_argument, 0, 'd'}, {"inputformat", required_argument, 0, 'i'}, {"outputformat", required_argument, 0, 'o'}, {"inputheader", required_argument, 0, 'n'}, {"outputheader", required_argument, 0, 'u'}, {"inputedgeweights", required_argument, 0, 'e'}, {"outputedgeweights", required_argument, 0, 'w'}, {"edgeweighttype", required_argument, 0, 't'}, {"r", required_argument, 0, 'r'}, {"nvertices", required_argument, 0, 'v'}, {"split", required_argument, 0, 'p'}, {"help", no_argument, 0, 'h'} }; while (1) { int optionIndex = 0; int currentOption = getopt_long(argc, (char *const*)argv, "h:s:d:i:o:n:u:e:w:t:v:r:p", longOptions, &optionIndex); if (currentOption == -1) { break; } int method = 3; switch (currentOption) { case 0: break; case 'h': printHelp(argv[0]); return(0); case 's': sscanf(optarg, "%i", &Opt.selfloops); break; case 'd': sscanf(optarg, "%i", &Opt.duplicatededges); break; case 'i': sscanf(optarg, "%i", &Opt.inputformat); break; case 'o': sscanf(optarg, "%i", &Opt.outputformat); break; case 'n': sscanf(optarg, "%i", &Opt.inputheader); break; case 'u': sscanf(optarg, "%i", &Opt.outputheader); break; case 'e': sscanf(optarg, "%i", &Opt.inputedgeweights); break; case 'w': sscanf(optarg, "%i", &Opt.outputedgeweights); break; case 't': sscanf(optarg, "%i", &Opt.edgeweighttype); break; case 'v': sscanf(optarg, "%i", &Opt.nvertices); break; case 'r': sscanf(optarg, "%i", &Opt.random_range); break; case 'p': sscanf(optarg, "%i", &Opt.nsplits); break; case '?': break; default: abort(); break; } } if (optind != argc - 2) { printHelp(argv[0]); return(0); } int check = validateOptions(Opt); assert(check != 0); printOptions(Opt); const char* ifilename = argv[optind]; const char* ofilename = argv[optind+1]; switch(Opt.edgeweighttype) { case 0: process_graph<unsigned int>(ifilename, ofilename, Opt); break; case 1: process_graph<double>(ifilename, ofilename, Opt); break; default: printf("Invalid edge type: %d\n", Opt.edgeweighttype); exit(-1); break; } return 0; }
VOID ctrSetOption(PDEVICE_EXTENSION pde, daqIOTP p) { ADC_CHAN_OPT_PT ctrOpt = (ADC_CHAN_OPT_PT) p; WORD i; startCh = (WORD) ctrOpt->startChan; endCh = (WORD) ctrOpt->endChan; if (!pde->usingCounterTimers) { ctrOpt->errorCode = DerrNotCapable; return ; } if (! validateOptions(pde, ctrOpt)) { return; } switch (ctrOpt->operation) { case 0: switch (ctrOpt->chanOptType) { case DcotCounterCascade: ctrOpt->optValue = pde->counter[startCh].cascade; break; case DcotCounterMode: ctrOpt->optValue = pde->counter[startCh].clearOnRead; break; case DcotCounterControl: case DmotCounterControl: ctrOpt->optValue = pde->counter[startCh].enable; break; case DcotTimerDivisor: ctrOpt->optValue = pde->timer[startCh].timerDivisor; break; case DcotTimerControl: case DmotTimerControl: ctrOpt->optValue = pde->timer[startCh].enable; break; default: ctrOpt->errorCode = DerrInvOptionType; } break; case 1: switch (ctrOpt->chanOptType) { case DcotCounterCascade: for (i = startCh; i <= endCh; i++) { switch (i) { case 0: case 2: pde->counter[0].cascade = (WORD) ctrOpt->optValue; pde->counter[2].cascade = (WORD) ctrOpt->optValue; configureCtr(pde, 0, 0); configureCtr(pde, 2, 0); break; case 1: case 3: pde->counter[1].cascade = (WORD) ctrOpt->optValue; pde->counter[3].cascade = (WORD) ctrOpt->optValue; configureCtr(pde, 1, 0); configureCtr(pde, 3, 0); } } break; case DcotCounterMode: for (i = startCh; i <= endCh; i++) { pde->counter[i].clearOnRead = (WORD) ctrOpt->optValue; configureCtr(pde, i, 0); } break; case DcotCounterEdge: for (i = startCh; i <= endCh; i++) { pde->counter[i].edge = (WORD) ctrOpt->optValue; configureCtr(pde, i, 0); } break; case DcotCounterControl: for (i = startCh; i <= endCh; i++) { if (ctrOpt->optValue == DcovCounterManualClear) { configureCtr(pde, i, CounterClear); } else { pde->counter[i].enable = (WORD) ctrOpt->optValue; configureCtr(pde, i, 0); pde->counter[4].enable = DcovCounterOff; } } break; case DmotCounterControl: if (ctrOpt->optValue == DcovCounterManualClear) { configureCtr(pde, 4, CounterClear); } else { for (i = 0; i < 5; i++) { pde->counter[i].enable = (WORD) ctrOpt->optValue; } configureCtr(pde, 4, 0); } break; case DcotTimerDivisor: for (i = startCh; i <= endCh; i++) { pde->timer[i].timerDivisor = (WORD) ctrOpt->optValue; writeTmrDivisor(pde, i, pde->timer[i].timerDivisor); } break; case DcotTimerControl: for (i = startCh; i <= endCh; i++) { pde->timer[i].enable = (WORD) ctrOpt->optValue; configureTmr(pde, i); } pde->timer[2].enable = DcovTimerOff; break; case DmotTimerControl: for (i = 0; i < 3; i++) { pde->timer[i].enable = (WORD) ctrOpt->optValue; } configureTmr(pde, 2); break; default: ctrOpt->errorCode = DerrInvOptionType; } break; default: ctrOpt->errorCode = DerrInvCtrCmd; } return ; }