Example #1
0
/// \brief Load a collection of alignments based on command line parameters and generate a random tree.
///
/// \param args The command line parameters.
/// \param alignments The alignments.
/// \param T The leaf-labelled tree.
/// \param internal_sequences Should each resulting alignment have sequences for internal nodes on the tree?
/// 
void load_As_and_random_T(const variables_map& args,vector<alignment>& alignments,SequenceTree& T,const vector<bool>& internal_sequences)
{
  alignments = load_As(args);

  //------------- Load random tree ------------------------//
  SequenceTree TC = star_tree(sequence_names(alignments[0]));
  if (args.count("t-constraint"))
    TC = load_constraint_tree(args["t-constraint"].as<string>(),sequence_names(alignments[0]));

  T = TC;
  RandomTree(T,1.0);

  //-------------- Link --------------------------------//
  link(alignments,T,internal_sequences);

  //---------------process----------------//
  for(int i=0;i<alignments.size();i++) 
  {
    
    //---------------- Randomize alignment? -----------------//
    if (args.count("randomize-alignment"))
      alignments[i] = randomize(alignments[i],T.n_leaves());
  
    //------------------ Analyze 'internal'------------------//
    if ((args.count("internal") and args["internal"].as<string>() == "+")
	or args.count("randomize-alignment"))
      for(int column=0;column< alignments[i].length();column++) {
	for(int j=T.n_leaves();j<alignments[i].n_sequences();j++) 
	  alignments[i](column,j) = alphabet::not_gap;
      }

    //---- Check that internal sequence satisfy constraints ----//
    check_alignment(alignments[i],T,internal_sequences[i]);
  }
}
Example #2
0
string run_name(const variables_map& args)
{
    string name;
    if (args.count("name"))
        name = args["name"].as<string>();
    else if (args.count("align"))
    {
        vector<string> alignment_filenames = args["align"].as<vector<string> >();
        for(int i=0; i<alignment_filenames.size(); i++)
            alignment_filenames[i] = remove_extension( fs::path( alignment_filenames[i] ).leaf().string() );
        name = join(alignment_filenames,'-');
    }
    else if (args.count("model"))
    {
        string filename = args["model"].as<string>();
        Module M ( module_loader().read_module_from_file(filename) );
        name = M.name;
        name = get_unqualified_name(name);
    }
    else if (args.count("Model"))
    {
        name = args["Model"].as<string>();
        name = get_unqualified_name(name);
    }

    return name;
}
Example #3
0
void callback(const sensor_msgs::ImageConstPtr& msg)
{
  cv_bridge::CvImageConstPtr cv_ptr;
  try
  {
    // convert to OpenCV Mat
    cv_ptr=cv_bridge::toCvShare(msg,"bgr8");
    // compute new size
    if (!variablesMap.count("aw"))
      abWidth=cv_ptr->image.size().width*scWidth+0.5;
    if (!variablesMap.count("ah"))
      abHeight=cv_ptr->image.size().height*scHeight+0.5;
    // resize
    cv::resize(cv_ptr->image,resize, cv::Size(abWidth,abHeight));
    // convert to Ros image
    cv_bridge::CvImage resizeRos;
    resizeRos.encoding = "bgr8";
    resizeRos.image = resize;
    // republish image
    imagePub->publish(resizeRos.toImageMsg());
  }
  catch (cv_bridge::Exception& e)
  {
    ROS_ERROR("cv_bridge exception: %s", e.what());
    return;
  }
} 
Example #4
0
/// \brief Load an alignment based on command line parameters and generate a random tree.
///
/// \param args The command line parameters.
/// \param alignments The alignments.
/// \param T The leaf-labelled tree.
/// \param internal_sequences Should each resulting alignment have sequences for internal nodes on the tree?
/// 
void load_A_and_random_T(const variables_map& args,alignment& A,SequenceTree& T,bool internal_sequences)
{
  // NO internal sequences, yet!
  A = load_A(args,internal_sequences);

  //------------- Load random tree ------------------------//
  SequenceTree TC = star_tree(sequence_names(A));
  if (args.count("t-constraint"))
    TC = load_constraint_tree(args["t-constraint"].as<string>(),sequence_names(A));

  T = TC;
  RandomTree(T,1.0);

  //------------- Link Alignment and Tree -----------------//
  link(A,T,internal_sequences);

  //---------------- Randomize alignment? -----------------//
  if (args.count("randomize-alignment"))
    A = randomize(A,T.n_leaves());
  
  //------------------ Analyze 'internal'------------------//
  if ((args.count("internal") and args["internal"].as<string>() == "+")
      or args.count("randomize-alignment"))
    for(int column=0;column< A.length();column++) {
      for(int i=T.n_leaves();i<A.n_sequences();i++) 
	A(column,i) = alphabet::not_gap;
    }

  //---- Check that internal sequence satisfy constraints ----//
  check_alignment(A,T,internal_sequences);
}
Example #5
0
void http_client_plugin::plugin_initialize(const variables_map& options) {
   if ( options.count("https-client-root-cert") ) {
      const std::vector<std::string> root_pems = options["https-client-root-cert"].as<std::vector<std::string>>();
      for (const auto& root_pem : root_pems) {
         std::string pem_str = root_pem;
         if (!boost::algorithm::starts_with(pem_str, "-----BEGIN CERTIFICATE-----\n")) {
            try {
               auto infile = std::ifstream(pem_str);
               std::stringstream sstr;
               sstr << infile.rdbuf();
               pem_str = sstr.str();
               FC_ASSERT(boost::algorithm::starts_with(pem_str, "-----BEGIN CERTIFICATE-----\n"), "File does not appear to be a PEM encoded certificate");
            } catch (const fc::exception& e) {
               elog("Failed to read PEM ${f} : ${e}", ("f", root_pem)("e",e.to_detail_string()));
            }
         }

         try {
            my->add_cert(pem_str);
         } catch (const fc::exception& e) {
            elog("Failed to read PEM : ${e} \n${pem}\n", ("pem", pem_str)("e",e.to_detail_string()));
         }
      }
   }

   my->set_verify_peers(options.at("https-client-validate-peers").as<bool>());
}
int hpx_main(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>();

    std::size_t suspend_duration = 0;

    if (vm.count("suspend-duration"))
        suspend_duration = vm["suspend-duration"].as<std::size_t>();

    {
        barrier b(pxthreads + 1);

        // Create the hpx-threads.
        for (std::size_t i = 0; i < pxthreads; ++i)
            register_work(boost::bind
                (&suspend_test, boost::ref(b), iterations, suspend_duration));

        b.wait(); // Wait for all hpx-threads to enter the barrier.
    }

    // Initiate shutdown of the runtime system.
    return finalize();
}
Example #7
0
/// \brief Load a tree and an alignment based on command line parameters.
///
/// \param args The command line parameters.
/// \param alignments The alignments.
/// \param T The leaf-labelled tree.
/// \param internal_sequences Should each resulting alignment have sequences for internal nodes on the tree?
/// 
void load_A_and_T(const variables_map& args,alignment& A,RootedSequenceTree& T,bool internal_sequences)
{
  A = load_A(args,internal_sequences);

  T = load_T(args);

  //------------- Link Alignment and Tree -----------------//
  link(A,T,internal_sequences);

  //---------------- Randomize alignment? -----------------//
  if (args.count("randomize-alignment"))
    A = randomize(A,T.n_leaves());
  else if (args.count("unalign-all"))
    A = unalign_all(A,T.n_leaves()); 
 
  //------------------ Analyze 'internal'------------------//
  if ((args.count("internal") and args["internal"].as<string>() == "+")
      or args.count("randomize-alignment"))
    for(int column=0;column< A.length();column++) {
      for(int i=T.n_leaves();i<A.n_sequences();i++) 
	A.set_value(column,i, alphabet::not_gap );
    }

  //---- Check that internal sequence satisfy constraints ----//
  check_alignment(A,T,internal_sequences);
}
Example #8
0
    // checks options for sanity; returns true if papi component is needed
    bool check_options(variables_map const& vm)
    {
        bool needed = need_papi_component(vm);
        if (vm.count("hpx:papi-event-info"))
        {
            std::string v = vm["hpx:papi-event-info"].as<std::string>();
            if (v != "preset" && v != "native" && v != "all")
                HPX_THROW_EXCEPTION(hpx::commandline_option_error,
                    NS_STR "check_options()",
                    "unsupported mode "+v+" in --hpx:papi-event-info");
        }
        if (vm.count("hpx:papi-domain"))
        {
            std::string v = vm["hpx:papi-domain"].as<std::string>();
            int dom = map_domain(v); // throws if not found
            papi_call(PAPI_set_domain(dom),
                "could not switch to \""+v+"\" domain monitoring",
                NS_STR "check_options()");
            needed = true;
        }
        // FIXME: implement multiplexing properly and uncomment below when done
        if (vm.count("hpx:papi-multiplex"))
            HPX_THROW_EXCEPTION(hpx::not_implemented,
                NS_STR "check_options()",
                "counter multiplexing is currently not supported");
#if 0
        if (vm.count("hpx:papi-multiplex") && vm["hpx:papi-multiplex"].as<long>() < 0)
            HPX_THROW_EXCEPTION(hpx::commandline_option_error,
                NS_STR "check_options()",
                "argument to --hpx:papi-multiplex must be positive");
#endif
        return needed;
    }
Example #9
0
/// \brief Load a tree and a collection of alignments based on command line parameters.
///
/// \param args The command line parameters.
/// \param alignments The alignments.
/// \param T The leaf-labelled tree.
/// \param internal_sequences Should each resulting alignment have sequences for internal nodes on the tree?
/// 
void load_As_and_T(const variables_map& args,vector<alignment>& alignments,RootedSequenceTree& T,const vector<bool>& internal_sequences)
{
  alignments = load_As(args);

  T = load_T(args);

  link(alignments,T,internal_sequences);

  for(int i=0;i<alignments.size();i++) 
  {
    
    //---------------- Randomize alignment? -----------------//
    if (args.count("randomize-alignment"))
      alignments[i] = randomize(alignments[i],T.n_leaves());
  
    //------------------ Analyze 'internal'------------------//
    if ((args.count("internal") and args["internal"].as<string>() == "+")
	or args.count("randomize-alignment"))
      for(int column=0;column< alignments[i].length();column++) {
	for(int j=T.n_leaves();j<alignments[i].n_sequences();j++) 
	  alignments[i](column,j) = alphabet::not_gap;
      }

    //---- Check that internal sequence satisfy constraints ----//
    check_alignment(alignments[i],T,internal_sequences[i]);
  }
}
Example #10
0
int hpx_main(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>();

    for (std::size_t i = 0; i < iterations; ++i)
    {
        // create a barrier waiting on 'count' threads
        barrier b(pxthreads + 1);

        boost::atomic<std::size_t> c(0);

        // create the threads which will wait on the barrier
        for (std::size_t i = 0; i < pxthreads; ++i)
            register_work(hpx::util::bind
                (&local_barrier_test, std::ref(b), std::ref(c)));

        b.wait(); // wait for all threads to enter the barrier
        HPX_TEST_EQ(pxthreads, c);
    }

    // initiate shutdown of the runtime system
    finalize();
    return 0;
}
Example #11
0
void report_distances(const valarray<double>& distances,
		      const string& name,
		      variables_map& args
		      )
{
  if (not distances.size()) return;

  bool show_mean = args.count("mean");
  bool show_median = args.count("median");
  bool show_minmax = args.count("minmax");

  if (not show_mean and not show_median and not show_minmax)
    show_median = true;

  if (show_minmax)
    cout<<"    "<<name<<" in ["<<min(distances)<<", "<<max(distances)<<"]"<<endl;
  if (show_mean){
      cout<<"  E "<<name<<" = "<<distances.sum()/distances.size();
      cout<<"   [+- "<<sqrt(Var(distances))<<"]"<<endl;
  }
  if (show_median) {
    double P = args["CI"].as<double>();
    pair<double,double> interval = central_confidence_interval(distances,P);
    cout<<"    "<<name<<" ~ "<<median(distances);
    cout<<"   ("<<interval.first<<", "<<interval.second<<")"<<endl;
  }
}
Example #12
0
File: real.cpp Project: gijs/hexer
/* Function used to check that 'opt1' and 'opt2' are not specified
   at the same time. */
void conflicting_options(const variables_map& vm, 
                         const char* opt1, const char* opt2)
{
    if (vm.count(opt1) && !vm[opt1].defaulted() 
        && vm.count(opt2) && !vm[opt2].defaulted())
        throw logic_error(string("Conflicting options '") 
                          + opt1 + "' and '" + opt2 + "'.");
}
Example #13
0
void Configuration::Configuration_Impl::conflicting_options(const variables_map& vm,
		const string& opt1, const string& opt2)
{
	if (vm.count(opt1) && !vm[opt1].defaulted()
			&& vm.count(opt2) && !vm[opt2].defaulted())
		throw logic_error(string("Conflicting options '")
				+ opt1 + "' and '" + opt2 + "'.");
}
Example #14
0
File: real.cpp Project: gijs/hexer
/* Function used to check that of 'for_what' is specified, then
   'required_option' is specified too. */
void option_dependency(const variables_map& vm,
                        const char* for_what, const char* required_option)
{
    if (vm.count(for_what) && !vm[for_what].defaulted())
        if (vm.count(required_option) == 0 || vm[required_option].defaulted())
            throw logic_error(string("Option '") + for_what 
                              + "' requires option '" + required_option + "'.");
}
Example #15
0
void Configuration::Configuration_Impl::dependent_options(const variables_map& vm,
		const string& for_what, const string& required_option)
{
	if (vm.count(for_what) && !vm[for_what].defaulted())
		if (vm.count(required_option) == 0 || vm[required_option].defaulted())
			throw logic_error(string("Option '") + for_what
					+ "' requires option '" + required_option + "'.");
}
int hpx_main(variables_map& vm){
    uint64_t num = vm["number-spawned"].as<uint64_t>();
    bool rtype = (vm.count("result-action") ? true : false);
    string atype = vm["arg-type"].as<string>();
    int c = vm["argc"].as<int>();
    csv = (vm.count("csv") ? true : false);
    parse_arg(atype, rtype, num, c);
    return hpx::finalize();
}
Example #17
0
int hpx_main(variables_map& vm)
{
    try {
        std::cout << ( boost::format("prefix: %d")
                     % hpx::naming::get_locality_id_from_id(hpx::find_here()))
                  << std::endl;

        // Try to connect to existing throttle instance, create a new one if
        // this fails.
        char const* throttle_component_name = "/throttle/0";
        hpx::naming::id_type gid;
        hpx::agas::resolve_name(throttle_component_name, gid);
        throttle::throttle t;
        if (!t.get_gid()) {
            std::vector<hpx::naming::id_type> localities =
                hpx::find_remote_localities();

            // create throttle on the console, register the instance with AGAS
            // and add an additional reference count to keep it alive
            if (!localities.empty()) {
                // use AGAS client to get the component type as we do not
                // register any factories
                hpx::components::component_type type =
                    get_agas_client().get_component_id("throttle_throttle_type");
                std::cout << "throttle component type: " << (int)type << std::endl;

                t.create(localities[0], type);
                hpx::agas::register_name(throttle_component_name, t.get_gid());
            }
            else {
                std::cerr << "Can't find throttle component." << std::endl;
            }
        }

        // handle commands
        if (t.get_gid()) {
            if (vm.count("suspend")) {
                t.suspend(vm["suspend"].as<int>());
            }
            else if (vm.count("resume")) {
                t.resume(vm["resume"].as<int>());
            }
            else if (vm.count("release")) {
                // unregister from AGAS, remove additional reference count which
                // will allow for the throttle instance to be released
                hpx::agas::unregister_name(throttle_component_name);
            }
        }
    }
    catch (hpx::exception const& e) {
        std::cerr << "throttle_client: caught exception: " << e.what() << std::endl;
    }

    hpx::disconnect();
    return 0;
}
Example #18
0
config::stitching_options program_options_parser::
transform_options(const variables_map& vm) const {
    config::stitching_options r;

    r.verbose(vm.count(verbose_arg));
    if (!vm.count(target_arg))
        throw_missing_target();

    r.target(vm[target_arg].as<std::string>());
    r.force_write(vm.count(force_write_arg));
    return r;
}
Example #19
0
vector<shared_ptr<const alphabet> > load_alphabets(const variables_map& args) 
{
  vector<shared_ptr<const alphabet> > alphabets; 

  if (not args.count("alphabet")) {
    alphabets.push_back(shared_ptr<const alphabet>(new DNA));
    alphabets.push_back(shared_ptr<const alphabet>(new RNA));
    alphabets.push_back(shared_ptr<const alphabet>(new AminoAcids));
    alphabets.push_back(shared_ptr<const alphabet>(new AminoAcidsWithStop));

    return alphabets;
  }

  const string name = args["alphabet"].as<string>();

  if (name == "Codons" or name == "Codons+stop") {

    shared_ptr<const AminoAcids> AA;
    if (name == "Codons")
      AA = shared_ptr<const AminoAcids>(new AminoAcids);
    else
      AA = shared_ptr<const AminoAcids>(new AminoAcidsWithStop);
    
    string genetic_code_filename = "standard-code.txt";
    if (args.count("genetic-code"))
      genetic_code_filename = args["genetic-code"].as<string>();

    genetic_code_filename = args["data-dir"].as<string>() + "/" + genetic_code_filename;

    alphabets.push_back(shared_ptr<const alphabet>(new Codons(DNA(),*AA,genetic_code_filename)));
    alphabets.push_back(shared_ptr<const alphabet>(new Codons(RNA(),*AA,genetic_code_filename)));
  }
  else if (name == "Triplets") {
    alphabets.push_back(shared_ptr<const alphabet>(new Triplets(DNA())));
    alphabets.push_back(shared_ptr<const alphabet>(new Triplets(RNA())));
  }
  else if (name == "DNA")
    alphabets.push_back(shared_ptr<const alphabet>(new DNA()));
  else if (name == "RNA")
    alphabets.push_back(shared_ptr<const alphabet>(new RNA()));
  else if (name == "Amino-Acids")
    alphabets.push_back(shared_ptr<const alphabet>(new AminoAcids()));
  else if (name == "Amino-Acids+stop")
    alphabets.push_back(shared_ptr<const alphabet>(new AminoAcidsWithStop()));
  else 
    throw myexception()<<"I don't recognize alphabet '"<<name<<"'";

  return alphabets;
}
int qthreads_main(
    variables_map& vm
    )
{
    if (vm.count("no-header"))
        header = false;
    {
        // Validate command line.
        if (0 == tasks)
            throw std::invalid_argument("count of 0 tasks specified\n");

        // Start the clock.
        high_resolution_timer t;

        for (boost::uint64_t i = 0; i < tasks; ++i)
        {
            void* const ptr = &delay;
            qthread_fork(&worker_func, ptr, NULL);
        }

        // Yield until all our null qthreads are done.
        do {
            qthread_yield();
        } while (donecount != tasks);

        print_results(qthread_num_workers(), t.elapsed());
    }

    return 0;
}
int hpx_main(
    variables_map& vm
    )
{
    {
        boost::uint64_t test_runs = vm["test-runs"].as<boost::uint64_t>();

        boost::uint64_t children = vm["children"].as<boost::uint64_t>();

        boost::uint64_t max_depth = vm["depth"].as<boost::uint64_t>() + 1;

        boost::uint64_t delay_iterations
            = vm["delay-iterations"].as<boost::uint64_t>();

        bool verbose = vm.count("verbose") != 0;

        hpx::id_type const here = hpx::find_here();

        double d = 0.;

        null_tree_action null_act;
        for ( boost::uint64_t i = 0
            ; (test_runs == 0) || (i < test_runs)
            ; ++i)
        {
            d += null_act(here, 0, children, 1, max_depth, delay_iterations);

            if (verbose)
                std::cout << (boost::format("%016u : %f\n") % i % d)
                          << std::flush;
        }
    }

    return hpx::finalize();
}
Example #22
0
int hpx_main(variables_map& vm)
{
    {
        num_iterations = vm["delay-iterations"].as<std::uint64_t>();

        const std::uint64_t count = vm["futures"].as<std::uint64_t>();
        bool csv = vm.count("csv") != 0;
        if (HPX_UNLIKELY(0 == count))
            throw std::logic_error("error: count of 0 futures specified\n");
        const int nl = 1;

        hpx::parallel::execution::default_executor def;
        hpx::parallel::execution::parallel_executor par;

        for (int i=0; i<nl; i++) {
            measure_action_futures_wait_each(count, csv);
            measure_action_futures_wait_all(count, csv);
            measure_function_futures_wait_each(count, csv, def);
            measure_function_futures_wait_each(count, csv, par);
            measure_function_futures_wait_all(count, csv, def);
            measure_function_futures_wait_all(count, csv, par);
            measure_function_futures_thread_count(count, csv, def);
            measure_function_futures_thread_count(count, csv, par);
            measure_function_futures_limiting_executor(count, csv, def);
            measure_function_futures_limiting_executor(count, csv, par);
            measure_function_futures_sliding_semaphore(count, csv, def);
        }
    }

    return hpx::finalize();
}
Example #23
0
int app_main(
    variables_map& vm
    )
{
    if (vm.count("no-header"))
        header = false;

    if (0 == tasks)
        throw std::invalid_argument("count of 0 tasks specified\n");

    // Start the clock.
    high_resolution_timer t;

    for (boost::uint64_t i = 0; i < tasks; ++i)
    {
        worker_timed(delay * 1000);
    }

    double elapsed = t.elapsed();

    // Print out the results.
    print_results(vm, elapsed, (elapsed * 1e6) / double(tasks));

    return 0;
}
Example #24
0
int hpx_main(variables_map& vm){
    uint64_t num = vm["iterations"].as<uint64_t>();
    int threads = vm["hpx-threads"].as<int>();
    csv = (vm.count("csv") ? true : false);
    run_tests(num, threads);
    return hpx::finalize();
}
int hpx_main(
    variables_map& vm
    )
{
    if (vm.count("no-header"))
        header = false;

    {
        if (0 == tasks)
            throw std::invalid_argument("count of 0 tasks specified\n");

        // Start the clock.
        high_resolution_timer t;

        for (boost::uint64_t i = 0; i < tasks; ++i)
            register_work(HPX_STD_BIND(&invoke_worker, delay));

        // Reschedule hpx_main until all other hpx-threads have finished. We
        // should be resumed after most of the null px-threads have been
        // executed. If we haven't, we just reschedule ourselves again.
        do {
            suspend();
        } while (get_thread_count(hpx::threads::thread_priority_normal) > 1);

        print_results(get_os_thread_count(), t.elapsed());
    }

    return finalize();
}
Example #26
0
void wallet_api_plugin::plugin_initialize(const variables_map& options) {
   if (options.count("http-server-address")) {
      const auto& lipstr = options.at("http-server-address").as<string>();
      const auto& host = lipstr.substr(0, lipstr.find(':'));
      if (host != "localhost" && host != "127.0.0.1") {
         wlog("\n"
              "*************************************\n"
              "*                                   *\n"
              "*  --   Wallet NOT on localhost  -- *\n"
              "*  - Password and/or Private Keys - *\n"
              "*  - are transferred unencrypted. - *\n"
              "*                                   *\n"
              "*************************************\n");
      }
   }
}
int hpx_main(
    variables_map& vm
    )
{
    if (vm.count("no-header"))
        header = false;

    std::size_t num_os_threads = hpx::get_os_thread_count();

    int num_executors = vm["executors"].as<int>();
    if (num_executors <= 0)
        throw std::invalid_argument("number of executors to use must be larger than 0");

    if (std::size_t(num_executors) > num_os_threads)
        throw std::invalid_argument("number of executors to use must be \
                                        smaller than number of OS threads");

    std::size_t num_cores_per_executor = vm["cores"].as<int>();

    if ((num_executors - 1) * num_cores_per_executor > num_os_threads)
        throw std::invalid_argument("number of cores per executor should not \
                                     cause oversubscription");

    if (0 == tasks)
        throw std::invalid_argument("count of 0 tasks specified\n");

    // Start the clock.
    high_resolution_timer t;

    // create the executor instances
    using hpx::threads::executors::local_priority_queue_executor;

    {
        std::vector<local_priority_queue_executor> executors;
        for (std::size_t i = 0; i != std::size_t(num_executors); ++i)
        {
            // make sure we don't oversubscribe the cores, the last executor will
            // be bound to the remaining number of cores
            if ((i + 1) * num_cores_per_executor > num_os_threads)
            {
                HPX_ASSERT(i == std::size_t(num_executors) - 1);
                num_cores_per_executor = num_os_threads - i * num_cores_per_executor;
            }
            executors.push_back(local_priority_queue_executor(num_cores_per_executor));
        }

        t.restart();

        // schedule normal threads
        for (boost::uint64_t i = 0; i < tasks; ++i)
            executors[i % num_executors].add(
                hpx::util::bind(&worker_timed, delay * 1000));
    // destructors of executors will wait for all tasks to finish executing
    }

    print_results(num_os_threads, t.elapsed());

    return finalize();
}
Example #28
0
/// Load a tree from command line args "--tree filename"
RootedSequenceTree load_T(const variables_map& args) {
  if (not args.count("tree"))
    throw myexception()<<"Tree file not specified! (--tree <filename>)";
    
  RootedSequenceTree RT;
  RT.read(args["tree"].as<string>());

  return RT;
}
///////////////////////////////////////////////////////////////////////////////
//required to run hpx
int hpx_main(variables_map& vm){
    uint64_t num = vm["iterations"].as<uint64_t>();
    int threads = vm["hpx-threads"].as<int>();
    int os;
    if(!vm.count("hpx:threads")) os = 1;
    else os = atoi(vm["hpx:threads"].as<std::string>().c_str());
    run_tests(num, threads, os);
    return hpx::finalize();
}
/// \brief Return whether or not the specified variables_map has specified any of the options in this block
bool display_options_block::has_specified_options(const variables_map &arg_vm ///< The variables_map to examine
                                                  ) const {
	for (const string &block_po : ALL_BLOCK_POS) {
		if ( arg_vm.count( block_po ) && ! arg_vm[ block_po ].defaulted() ) {
			return true;
		}
	}
	return false;
}