Ejemplo n.º 1
0
int hpx_main(boost::program_options::variables_map& vm)
{
    unsigned int seed = (unsigned int)std::time(nullptr);
    if (vm.count("seed"))
        seed = vm["seed"].as<unsigned int>();

    std::cout << "using seed: " << seed << std::endl;
    std::srand(seed);

    for_loop_strided_test();
    for_loop_strided_test_idx();

    return hpx::finalize();
}
Ejemplo n.º 2
0
int hpx_main(boost::program_options::variables_map& vm)
{
    unsigned int seed = (unsigned int)std::time(nullptr);
    if (vm.count("seed"))
        seed = vm["seed"].as<unsigned int>();

    std::cout << "using seed: " << seed << std::endl;
    std::srand(seed);

    rotate_test();
    rotate_exception_test();
    rotate_bad_alloc_test();
    return hpx::finalize();
}
Ejemplo n.º 3
0
	void do_matchFirstNumeric(const boost::program_options::variables_map &vm, const std::string key, std::string &target, const std::string var, const std::string bound, const std::string op) {
		if (vm.count(key)) {
			std::vector<std::string> bounds = vm[key].as<std::vector<std::string> >();
			if (bounds.size() > 1 || !target.empty())
				NSC_DEBUG_MSG("Multiple boundries of the same kind is not supported");
			if (bounds.size() > 0) {
				std::string value = bounds.front();
				if (value.size() > 3 && value[2] == ':')
					target = var + "=" + bound + " " + value.substr(0,2) + " " + value.substr(3);
				else
					target = var + "=" + bound + op + bounds.front();
			}
		}
	}
Ejemplo n.º 4
0
void SpinReader::loadTFMFromProgramOptions(const bpo::variables_map & vm)
{
  RobotModel model;
  if( vm.count("robot_description") )
    model.addFile(vm["robot_description"].as<std::string>());
  else if( ! ros::param::has("/driving/robot_description") )
    BOOST_THROW_EXCEPTION(stdr::ex::ExceptionBase() <<stdr::ex::MsgInfo(
                            "You must provide a model description, either on the command line, or as a rosparam."));
  model.addParam("/driving/robot_description");

  BOOST_FOREACH(const tf::StampedTransform& t, model.getStaticTransforms()) {
    tf_listener_.addStaticTransform(t);
  }
}
Ejemplo n.º 5
0
shared_ptr<mat> filtering(const mat& mrating, mpq& msim){
    cout<<"collaborative filtering..."<<endl;

    shared_ptr<mat> pm_predict(new mat(mrating));
    mat& m_predict = *pm_predict;


    int max_row_index = base ? nitem : nuser;

    for(mpq_i i=msim.begin(); i!=msim.end(); ++i){

        cout<<(i->first+1) * 100 / max_row_index<<"%\r"; cout.flush();

        // get current row
        row ri(m_predict, i->first);
        pq& q = i->second;

        // pop all sim rows
        for(;!q.empty(); q.pop()){

            int index = q.top().first;
            double sim   = q.top().second;

            crow rj(mrating, index);

            switch(sim_summing){
            case 0:
                ri += rj * sim;
                break;
            case 1:
                for(crow::const_iterator j=rj.begin(); j!=rj.end(); ++j){

                    int col = j.index();

                    double v = 1 - ( 1 - ri(col) ) * ( 1 - *j * sim );
                    if(v)   ri(col) = v;
                }
                break;
            default:
                break;
            }
        }
    }
    cout<<endl;

    if(vm.count("verbose")) cout<<"prediction matrix:\n"<<m_predict<<endl;
    
    return pm_predict;
}
Ejemplo n.º 6
0
bool parse_commandline(int argc, char *argv[], po::variables_map& vm)
{
    try {
        po::options_description desc_cmdline ("Usage: fibonacci2 [options]");
        desc_cmdline.add_options()
            ("help,h", "print out program usage (this message)")
            ("run_agas_server,r", "run AGAS server as part of this runtime instance")
            ("worker,w", "run this instance in worker (non-console) mode")
            ("config", po::value<std::string>(), 
                "load the specified file as an application configuration file")
            ("agas,a", po::value<std::string>(), 
                "the IP address the AGAS server is running on (default taken "
                "from hpx.ini), expected format: 192.168.1.1:7912")
            ("hpx,x", po::value<std::string>(), 
                "the IP address the HPX parcelport is listening on (default "
                "is localhost:7910), expected format: 192.168.1.1:7913")
            ("localities,l", po::value<int>(), 
                "the number of localities to wait for at application startup "
                "(default is 1)")
            ("threads,t", po::value<int>(), 
                "the number of operating system threads to spawn for this "
                "HPX locality")
            ("queueing,q", po::value<std::string>(),
                "the queue scheduling policy to use, options are 'global' "
                " and 'local' (default is 'global')")
            ("value,v", po::value<int>(), 
                "the number to be used as the argument to fib (default is 10)")
            ("csv,s", "generate statistics of the run in comma separated format")
            ("busywait,b", po::value<int>(),
                "add this amount of busy wait workload to each of the iterations"
                " [in microseconds], i.e. -b1000 == 1 millisecond")
        ;

        po::store(po::command_line_parser(argc, argv)
            .options(desc_cmdline).run(), vm);
        po::notify(vm);

        // print help screen
        if (vm.count("help")) {
            std::cout << desc_cmdline;
            return false;
        }
    }
    catch (std::exception const& e) {
        std::cerr << "fibonacci2: exception caught: " << e.what() << std::endl;
        return false;
    }
    return true;
}
Ejemplo n.º 7
0
	bool readGridGraph(boost::program_options::variables_map& variableMap, int& gridDimension, std::string& message)
	{
		if(variableMap.count("gridGraph") != 1)
		{
			message = "Please enter a single value for `input' gridGraph";
			return false;
		}
		gridDimension = variableMap["gridGraph"].as<int>();
		if(gridDimension <= 0)
		{
			message = "Input `gridGraph' must be a positive number";
			return false;
		}
		return true;
	}
Ejemplo n.º 8
0
void local_tests(boost::program_options::variables_map& vm)
{
    std::size_t pxthreads = 0;
    if (vm.count("pxthreads"))
        pxthreads = vm["pxthreads"].as<std::size_t>();

    std::size_t iterations = 0;
    if (vm.count("iterations"))
        iterations = vm["iterations"].as<std::size_t>();

    hpx::id_type here = hpx::find_here();
    for (std::size_t i = 0; i < iterations; ++i)
    {
        boost::atomic<std::size_t> c(0);
        for (std::size_t j = 0; j < pxthreads; ++j)
        {
            hpx::async(hpx::util::bind(&barrier_test, pxthreads + 1, j, std::ref(c)));
        }

        hpx::lcos::barrier b("local_barrier_test", pxthreads + 1, pxthreads);
        b.wait();       // wait for all threads to enter the barrier
        HPX_TEST_EQ(pxthreads, c.load());
    }
}
Ejemplo n.º 9
0
int checkParameters(int argc,char **argv,po::variables_map & vm) {
  po::options_description desc("Allowed options");
  desc.add_options()
    ("help,h", "produce help message")
    ("r1,1", po::value<string>(), "read 1 in fastq format (gzip allowed)")
    ("r2,2", po::value<string>(), "read 2 in fastq format (gzip allowed)")
    ("output-prefix,O", po::value<string>(), "output prefix")
    ("rc", "reverse-complement  reads");

    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);    

    if (vm.count("help") || argc==1) {
      cout << desc << "\n";
      exit(1);
    }

    if (!vm.count("r1") || !vm.count("r2") ||  !vm.count("output-prefix")) {
      cout << "Missing input!"<<endl;
      exit(1);
    }

    return(0);
}
Ejemplo n.º 10
0
void listLabels( const boost::program_options::variables_map & options )
{
	std::string labelRegex = ".*";
	if ( options.count( "arg1" ) > 0 )
		labelRegex = options[ "arg1" ].as< std::string >();
	boost::regex testExpression( labelRegex );
	Osmosis::Chain::Chain chain( options[ "objectStores" ].as< std::string >(), false, false );
	if ( chain.count() > 1 )
		THROW( Error, "--objectStores must contain one object store in a list operation" );

	Osmosis::Client::LabelOps instance( chain.single() );
	std::list< std::string > result = instance.listLabels( labelRegex );
	for ( auto & i : result )
		std::cout << i << std::endl;
}
Ejemplo n.º 11
0
int hpx_main(boost::program_options::variables_map& vm)
{
    bool print_header = vm.count("no-header") == 0;
    bool do_child = vm.count("no-child") == 0;      // fork only
    bool do_parent = vm.count("no-parent") == 0;    // async only
    std::size_t num_cores = hpx::get_os_thread_count();
    if (vm.count("num_cores") != 0)
        num_cores = vm["num_cores"].as<std::size_t>();

    // first collect child stealing times
    double child_stealing_time = 0;
    if (do_parent)
        child_stealing_time = measure(hpx::launch::async);

    // now collect parent stealing times
    double parent_stealing_time = 0;
    if (do_child)
        parent_stealing_time = measure(hpx::launch::fork);

    if (print_header)
    {
        hpx::cout
            << "num_cores,num_threads,child_stealing_time[s],parent_stealing_time[s]"
            << hpx::endl;
    }

    hpx::cout
        << (boost::format("%d,%d,%f,%f") %
                num_cores %
                iterations %
                child_stealing_time %
                parent_stealing_time)
        << hpx::endl;

    return hpx::finalize();
}
Ejemplo n.º 12
0
void runConsole(const bpo::variables_map& vm)
{
  boost::asio::io_service srv;
  Drone drone(vm["address"].as<string>(), srv);
  std::auto_ptr<UdpLogger> logger;
  
  std::string logfileName;
  if (vm.count("autolog")) {
    logfileName = createLogFileName();
  } else if (vm.count("loggfile")) {
    logfileName = vm["logfile"].as<string>();
  }

  if (!logfileName.empty()) {
    logger.reset(new UdpLogger(srv, 7778, logfileName));
    logger->start();
  }

  if (vm.count("joystick")) {
    runJoystickControlled(drone, vm["joystick"].as<string>());
  } else {
    runKeyboardControlled(drone);
  }
}
Ejemplo n.º 13
0
Archivo: sort.cpp Proyecto: K-ballo/hpx
int hpx_main(boost::program_options::variables_map& vm)
{
    unsigned int seed = (unsigned int)std::time(nullptr);
    if (vm.count("seed"))
        seed = vm["seed"].as<unsigned int>();

    std::cout << "using seed: " << seed << std::endl;
    std::srand(seed);

    test_sort1();
    test_sort2();
    sort_benchmark();

    return hpx::finalize();
}
Ejemplo n.º 14
0
	bool readNGraphs(boost::program_options::variables_map& variableMap, int& out)
	{
		if(variableMap.count("nGraphs") != 1)
		{
			std::cout << "Please enter a single option value for input `nGraphs'" << std::endl;
			return false;
		}
		out = variableMap["nGraphs"].as<int>();
		if(out <= 0)
		{
			std::cout << "Input `nGraphs' must be positive" << std::endl;
			return false;
		}
		return true;
	}
Ejemplo n.º 15
0
	bool readInitialRadius(boost::program_options::variables_map& variableMap, int& out)
	{
		if(variableMap.count("initialRadius") != 1)
		{
			std::cout << "Please enter a single value for input `initialRadius'" << std::endl;
			return false;
		}
		out = variableMap["initialRadius"].as<int>();
		if(out < 0)
		{
			std::cout << "Input `initialRadius' must be nonnegative" << std::endl;
			return false;
		}
		return true;
	}
Ejemplo n.º 16
0
int start( const po::variables_map &params )
{
    if( params.count( "server" ) == 0 ) {
        throw std::runtime_error("Server endpoint is not defined;\n"
                                 "Use --help for details");
    }

    /// as far as we use only ONE thread for DB access
    /// we don't need rpc-pool anymore
    unsigned io_size = params.count( "io-pool-size" )
            ? params["io-pool-size"].as<unsigned>( )
            : 1;

    if( io_size < 1 ) {
        throw std::runtime_error( "io-pool-size must be at least 1" );
    }

    typedef std::vector<std::string> string_vector;
    string_vector servers = params["server"].as<string_vector>( );

    common::pool_pair pp( io_size - 1, 1 );
    lukki_db::application app( pp );

    for( string_vector::const_iterator b(servers.begin( )), e(servers.end( ));
                    b != e; ++b)
    {
        std::cout << "Starting listener at '" <<  *b << "'...";
        app.attach_start_listener( create_from_string( *b, app ) );
        std::cout << "Ok\n";
    }

    pp.get_io_pool( ).attach( );
    pp.join_all( );

    return 0;
}
Ejemplo n.º 17
0
static void Run(const boost::program_options::variables_map& map)
{
	if (map.count("filename") == 0)
	{
		printf("Usage:\n\n   fivem formats:fraglod *.yft...\n");
		return;
	}

	auto& entries = map["filename"].as<std::vector<boost::filesystem::path>>();

	for (auto& filePath : entries)
	{
		RunFragment(filePath);
	}
}
Ejemplo n.º 18
0
Config createConfig(const opts::variables_map& varMap)
{
    // Get the configuration file name.
    std::string configFilename = "";
    if (varMap.count("config"))
        configFilename = varMap["config"].as<std::string>();

    pelican::Config config;
    if (!configFilename.empty()) {
        config = pelican::Config(QString(configFilename.c_str()));
    } else {
        throw QString("must specify a configuration file");
    }
    return config;
}
Ejemplo n.º 19
0
void producer_plugin::plugin_initialize(const boost::program_options::variables_map& options)
{ try {
   my->_options = &options;
   LOAD_VALUE_SET(options, "producer-name", my->_producers, types::account_name)

   if( options.count("private-key") )
   {
      const std::vector<std::string> key_id_to_wif_pair_strings = options["private-key"].as<std::vector<std::string>>();
      for (const std::string& key_id_to_wif_pair_string : key_id_to_wif_pair_strings)
      {
         auto key_id_to_wif_pair = dejsonify<std::pair<public_key_type, private_key_type>>(key_id_to_wif_pair_string);
         my->_private_keys[key_id_to_wif_pair.first] = key_id_to_wif_pair.second;
      }
   }
} FC_LOG_AND_RETHROW() }
Ejemplo n.º 20
0
int hpx_main(boost::program_options::variables_map& vm)
{
    unsigned int seed = (unsigned int)std::time(nullptr);
    if (vm.count("seed"))
        seed = vm["seed"].as<unsigned int>();

    std::cout << "using seed: " << seed << std::endl;
    gen.seed(seed);

    for_each_n_exception_test<hpx::parallel::util::projection_identity>();

    for_each_n_exception_test<projection_square>();

    return hpx::finalize();
}
Ejemplo n.º 21
0
        // handle all --options-config found on the command line
        void handle_config_options(boost::program_options::variables_map& vm,
            boost::program_options::options_description const& desc_cfgfile,
            util::section const& ini, std::size_t node, int error_mode)
        {
            using boost::program_options::options_description;
            if (vm.count("hpx:options-file")) {
                std::vector<std::string> const &cfg_files =
                    vm["hpx:options-file"].as<std::vector<std::string> >();

                BOOST_FOREACH(std::string const& cfg_file, cfg_files)
                {
                    // parse a single config file and store the results
                    read_config_file_options(cfg_file, desc_cfgfile, vm, ini,
                        node, error_mode);
                }
Ejemplo n.º 22
0
int hpx_main(boost::program_options::variables_map& vm)
{
    boost::uint64_t np = vm["np"].as<boost::uint64_t>();   // Number of partitions.
    boost::uint64_t nx = vm["nx"].as<boost::uint64_t>();   // Number of grid points.
    boost::uint64_t nt = vm["nt"].as<boost::uint64_t>();   // Number of steps.

    if (vm.count("no-header"))
        header = false;


    // Create the stepper object
    stepper step;

    // Measure execution time.
    boost::uint64_t t = hpx::util::high_resolution_clock::now();

    // Execute nt time steps on nx grid points and print the final solution.
    hpx::future<stepper::space> result = step.do_work(np, nx, nt);

    stepper::space solution = result.get();
    hpx::wait_all(solution);

    boost::uint64_t elapsed = hpx::util::high_resolution_clock::now() - t;

    // Print the final solution
    if (vm.count("results"))
    {
        for (std::size_t i = 0; i != np; ++i)
            std::cout << "U[" << i << "] = " << solution[i].get() << std::endl;
    }

    boost::uint64_t const os_thread_count = hpx::get_os_thread_count();
    print_time_results(os_thread_count, elapsed, nx, np, nt, header);

    return hpx::finalize();
}
void CheckRequiredArgs(const po::variables_map vm)
{
	if(!vm.count("input"))
	{
		std::cout << "input is required!" << std::endl;
		exit(-1);
	}
/*	
	if(!vm.count("output"))
	{
		std::cout << "output is required!" << std::endl;
		exit(-1);
	}
*/
}
static void parseAppOptions(int argc, char *argv[],
                                struct app_inst_req &req,
                                po::variables_map &vm)
{

    parseCommandOptions(argc, argv, getAppOptions(), vm);

    if (vm.count("app"))
        req.appName = vm["app"].as<std::string>();
    if (vm.count("pkg"))
        req.pkgName = vm["pkg"].as<std::string>();
    if (vm.count("path")) {
        const std::vector<std::string> paths =
            vm["path"].as<std::vector<std::string> >();
        if (!loadPaths(paths, req)) {
            po::error e("Error in parsing path arguments.");
            throw e;
        }
    }
    if (vm.count("privilege")) {
        auto privVector = vm["privilege"].as<std::vector<std::string > >();
        for (auto &e : privVector)
            req.privileges.push_back(std::make_pair(e, std::string()));

        if (req.privileges.empty()) {
            po::error e("Error in parsing privilege arguments.");
            throw e;
        }
#ifdef BUILD_TYPE_DEBUG
        LogDebug("Passed privileges:");
        for (const auto &p : req.privileges) {
            LogDebug("    " << p.first);
        }
#endif
    }
    if (vm.count("uid"))
        req.uid = vm["uid"].as<uid_t>();
    if (vm.count("tizen"))
        req.tizenVersion = vm["tizen"].as<std::string>();
    if (vm.count("author-id"))
        req.authorName = vm["author-id"].as<std::string>();
    if (vm.count("install-type"))
        req.installationType = install_type_map.at(vm["install-type"].as<std::string>());

}
Ejemplo n.º 25
0
	std::shared_ptr<std::basic_ostream<CharT>> OpenOutput(const po::variables_map& variables)
	{
		if (variables.count("output"))
		{
			auto outputPath = variables["output"].as<std::wstring>();
			std::shared_ptr<std::basic_ofstream<CharT>> out(new std::basic_ofstream<CharT>(outputPath.c_str(), std::ios_base::trunc | std::ios_base::binary));
			if (!out->is_open())
			{
				std::wcerr << L"Failed to open output file for writing: " << outputPath << std::endl;
				return std::shared_ptr<std::basic_ostream<CharT>>();
			}
			return out;
		}
		else
			return std::shared_ptr<std::basic_ostream<CharT>>(new std::basic_ostream<CharT>(GetRdbuf<CharT>()));
	}
Ejemplo n.º 26
0
void handle_opts(
    po::options_description &opts_micro,
    po::variables_map &vm
)
{
    opts_main.add(opts_micro);
    po::store(po::parse_command_line(ac, av, opts_main), vm); // could be exchanged with a config file parser

    // hendling the "help" option
    if (vm.count("help"))
    {
        std::cout << opts_main;
        exit(EXIT_SUCCESS);
    }
    po::notify(vm); // includes checks for required options
}
Ejemplo n.º 27
0
void Command::setup_object_type_nrw(const boost::program_options::variables_map& vm) {
    if (vm.count("object-type")) {
        m_osm_entity_bits = osmium::osm_entity_bits::nothing;
        for (const auto& t : vm["object-type"].as<std::vector<std::string>>()) {
            if (t == "n" || t == "node") {
                m_osm_entity_bits |= osmium::osm_entity_bits::node;
            } else if (t == "w" || t == "way") {
                m_osm_entity_bits |= osmium::osm_entity_bits::way;
            } else if (t == "r" || t == "relation") {
                m_osm_entity_bits |= osmium::osm_entity_bits::relation;
            } else {
                throw argument_error(std::string("Unknown object type '") + t + "' (Allowed are 'node', 'way', and 'relation').");
            }
        }
    }
}
Ejemplo n.º 28
0
		void __EditYaml(const string& key, po::variables_map& vm) {
			if (vm.count(key) != 1)
				return;
			T v = vm[key].as<T>();
			static const auto sep = boost::is_any_of(".");
			vector<string> tokens;
			boost::split(tokens, key, sep, boost::token_compress_on);
			// Had to use a pointer to traverse the tree. Otherwise, the tree gets messed up.
			YAML::Node* n = &_yaml_root;
			for (string t: tokens) {
				YAML::Node n1 = (*n)[t];
				n = &n1;
			}
			*n = v;
			//Cons::P(Desc());
		}
Ejemplo n.º 29
0
bool initialise() {
  cout << "Initialising program..." << endl;
  bool success = true;

  // seeds
  if (vm.count("seed")) {
    theSeed = poSeed;
  }
  else {
    theSeed = time(NULL);
  }

  
  //initialise_end:
  return success;
}
void monitor_plugin::plugin_initialize(const boost::program_options::variables_map& options) {
    try {
        ilog("monitor plugin: plugin_initialize() begin");
        
        // 读取参数配置
        if (options.count(MONITOR_OPT_ACTION_TYPE)) {
            monitor_action_type = options[MONITOR_OPT_ACTION_TYPE].as<uint32_t>();
        } else {
            monitor_action_type = MONITOR_ACTION_TYPE_ALL;
        }

        ilog("monitor plugin: plugin_initialize() end");
    } FC_LOG_AND_RETHROW()

    return;
}