Пример #1
0
    runtime_impl<SchedulingPolicy, NotificationPolicy>::runtime_impl(
            util::runtime_configuration const& rtcfg,
            runtime_mode locality_mode, std::size_t num_threads,
            init_scheduler_type const& init,
            threads::policies::init_affinity_data const& init_affinity)
      : runtime(rtcfg, init_affinity),
        mode_(locality_mode), result_(0), num_threads_(num_threads),
        main_pool_(1,
            boost::bind(&runtime_impl::init_tss, This(), "main-thread", ::_1, ::_2, false),
            boost::bind(&runtime_impl::deinit_tss, This()), "main_pool"),
        io_pool_(rtcfg.get_thread_pool_size("io_pool"),
            boost::bind(&runtime_impl::init_tss, This(), "io-thread", ::_1, ::_2, true),
            boost::bind(&runtime_impl::deinit_tss, This()), "io_pool"),
        timer_pool_(rtcfg.get_thread_pool_size("timer_pool"),
            boost::bind(&runtime_impl::init_tss, This(), "timer-thread", ::_1, ::_2, true),
            boost::bind(&runtime_impl::deinit_tss, This()), "timer_pool"),
        parcel_port_(parcelset::parcelport::create_bootstrap(ini_,
            boost::bind(&runtime_impl::init_tss, This(), "parcel-thread", ::_1, ::_2, true),
            boost::bind(&runtime_impl::deinit_tss, This()))),
        scheduler_(init),
        notifier_(
            boost::bind(&runtime_impl::init_tss, This(), "worker-thread", ::_1, ::_2, false),
            boost::bind(&runtime_impl::deinit_tss, This()),
            boost::bind(&runtime_impl::report_error, This(), _1, _2)),
        thread_manager_(new hpx::threads::threadmanager_impl<
            SchedulingPolicy, NotificationPolicy>(
                timer_pool_, scheduler_, notifier_, num_threads)),
        agas_client_(*parcel_port_, ini_, mode_),
        parcel_handler_(agas_client_, thread_manager_.get(),
            new parcelset::policies::global_parcelhandler_queue),
        init_logging_(ini_, mode_ == runtime_mode_console, agas_client_),
        applier_(parcel_handler_, *thread_manager_,
            boost::uint64_t(runtime_support_.get()), boost::uint64_t(memory_.get())),
        action_manager_(applier_)
    {
        components::server::get_error_dispatcher().register_error_sink(
            &runtime_impl::default_errorsink, default_error_sink_);

        // in AGAS v2, the runtime pointer (accessible through get_runtime
        // and get_runtime_ptr) is already initialized at this point.
        applier_.init_tss();

#if defined(HPX_HAVE_SECURITY)
        // once all has been initialized, finalize security data for bootstrap
        this->init_security();
#endif
        // now, launch AGAS and register all nodes, launch all other components
        agas_client_.initialize(*parcel_port_);
        parcel_handler_.initialize(parcel_port_);

#if defined(HPX_HAVE_SECURITY)
        // enable parcel capability checking
        applier_.enable_verify_capabilities();
#endif

        // copy over all startup functions registered so far
        BOOST_FOREACH(HPX_STD_FUNCTION<void()> const& f, global_pre_startup_functions)
        {
            add_pre_startup_function(f);
        }
Пример #2
0
 parcelset::locality connection_handler::agas_locality(
     util::runtime_configuration const & ini) const
 {
     // load all components as described in the configuration information
     if (ini.has_section("hpx.agas")) {
         util::section const* sec = ini.get_section("hpx.agas");
         if (nullptr != sec) {
             return
                 parcelset::locality(
                     locality(
                         sec->get_entry("address", HPX_INITIAL_IP_ADDRESS)
                       , hpx::util::get_entry_as<boost::uint16_t>(
                             *sec, "port", HPX_INITIAL_IP_PORT)
                     )
                 );
         }
     }
     return
         parcelset::locality(
             locality(
                 HPX_INITIAL_IP_ADDRESS
               , HPX_INITIAL_IP_PORT
             )
         );
 }
Пример #3
0
    parcelport::parcelport(util::runtime_configuration const& ini,
            locality const & here, std::string const& type)
      : applier_(nullptr),
        here_(here),
        max_inbound_message_size_(ini.get_max_inbound_message_size()),
        max_outbound_message_size_(ini.get_max_outbound_message_size()),
        allow_array_optimizations_(true),
        allow_zero_copy_optimizations_(true),
        enable_security_(false),
        async_serialization_(false),
        priority_(hpx::util::get_entry_as<int>(ini,
            "hpx.parcel." + type + ".priority", "0")),
        type_(type)
    {
        std::string key("hpx.parcel.");
        key += type;

        if (hpx::util::get_entry_as<int>(
                ini, key + ".array_optimization", "1") == 0)
        {
            allow_array_optimizations_ = false;
            allow_zero_copy_optimizations_ = false;
        }
        else
        {
            if (hpx::util::get_entry_as<int>(
                    ini, key + ".zero_copy_optimization", "1") == 0)
            {
                allow_zero_copy_optimizations_ = false;
            }
        }

        if (hpx::util::get_entry_as<int>(
                ini, key + ".enable_security", "0") != 0)
        {
            enable_security_ = true;
        }

        if (hpx::util::get_entry_as<int>(
                ini, key + ".async_serialization", "0") != 0)
        {
            async_serialization_ = true;
        }
    }
Пример #4
0
    runtime_impl<SchedulingPolicy, NotificationPolicy>::runtime_impl(
            util::runtime_configuration const& rtcfg,
            runtime_mode locality_mode, init_scheduler_type const& init)
      : runtime(agas_client_, rtcfg),
        mode_(locality_mode), result_(0),
        main_pool_(1,
            boost::bind(&runtime_impl::init_tss, This(), "main-thread", ::_1),
            boost::bind(&runtime_impl::deinit_tss, This()), "main_pool"),
        io_pool_(rtcfg.get_thread_pool_size("io_pool"),
            boost::bind(&runtime_impl::init_tss, This(), "io-thread", ::_1),
            boost::bind(&runtime_impl::deinit_tss, This()), "io_pool"),
        parcel_pool_(rtcfg.get_thread_pool_size("parcel_pool"),
            boost::bind(&runtime_impl::init_tss, This(), "parcel-thread", ::_1),
            boost::bind(&runtime_impl::deinit_tss, This()), "parcel_pool"),
        timer_pool_(rtcfg.get_thread_pool_size("timer_pool"),
            boost::bind(&runtime_impl::init_tss, This(), "timer-thread", ::_1),
            boost::bind(&runtime_impl::deinit_tss, This()), "timer_pool"),
        parcel_port_(parcel_pool_, ini_.get_parcelport_address(),
            ini_.get_max_connections(), ini_.get_max_connections_per_loc()),
        scheduler_(init),
        notifier_(boost::bind(&runtime_impl::init_tss, This(), "worker-thread", ::_1),
            boost::bind(&runtime_impl::deinit_tss, This()),
            boost::bind(&runtime_impl::report_error, This(), _1, _2)),
        thread_manager_(new hpx::threads::threadmanager_impl<
            SchedulingPolicy, NotificationPolicy>(timer_pool_, scheduler_, notifier_)),
        agas_client_(parcel_port_, ini_, mode_),
        parcel_handler_(agas_client_, parcel_port_, thread_manager_.get(),
            new parcelset::policies::global_parcelhandler_queue),
        init_logging_(ini_, mode_ == runtime_mode_console, agas_client_),
        applier_(parcel_handler_, *thread_manager_,
            boost::uint64_t(&runtime_support_), boost::uint64_t(&memory_)),
        action_manager_(applier_),
        runtime_support_(ini_, parcel_handler_.get_locality(), agas_client_, applier_)
    {
        components::server::get_error_dispatcher().register_error_sink(
            &runtime_impl::default_errorsink, default_error_sink_);

        // copy over all startup functions registered so far
        BOOST_FOREACH(HPX_STD_FUNCTION<void()> const& f, global_pre_startup_functions)
        {
            add_pre_startup_function(f);
        }
Пример #5
0
    boost::shared_ptr<parcelport> parcelport::create_bootstrap(
        util::runtime_configuration const& cfg,
        HPX_STD_FUNCTION<void(std::size_t, char const*)> const& on_start_thread,
        HPX_STD_FUNCTION<void()> const& on_stop_thread)
    {
        std::string pptype = cfg.get_entry("hpx.parcel.bootstrap", "tcp");

        int type = get_connection_type_from_name(pptype);
        if (type == connection_unknown)
            type = connection_tcp;

        return create(type, cfg, on_start_thread, on_stop_thread);
    }
Пример #6
0
    boost::shared_ptr<parcelport> parcelport::create(connection_type type,
        util::runtime_configuration const& cfg,
        HPX_STD_FUNCTION<void(std::size_t, char const*)> const& on_start_thread,
        HPX_STD_FUNCTION<void()> const& on_stop_thread)
    {
        switch(type) {
        case connection_tcpip:
            return boost::make_shared<parcelset::tcp::parcelport>(
                cfg, on_start_thread, on_stop_thread);

        case connection_shmem:
            {
#if defined(HPX_HAVE_PARCELPORT_SHMEM)
                // Create shmem based parcelport only if allowed by the 
                // configuration info.
                std::string enable_shmem = 
                    cfg.get_entry("hpx.parcel.shmem.enable", "0");

                if (boost::lexical_cast<int>(enable_shmem)) 
                {
                    return boost::make_shared<parcelset::shmem::parcelport>(
                        cfg, on_start_thread, on_stop_thread);
                }
#endif
                HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                    "unsupported connection type 'connection_shmem'");
            }
            break;

        case connection_portals4:
            HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                "unsupported connection type 'connection_portals4'");
            break;

        default:
            HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                "unknown connection type");
            break;
        }

        return boost::shared_ptr<parcelport>();
    }
Пример #7
0
        bool detect_mpi_environment(util::runtime_configuration const& cfg,
            char const* default_env)
        {
#if defined(__bgq__)
            // If running on BG/Q, we can safely assume to always run in an
            // MPI environment
            return true;
#else
            std::string mpi_environment_strings = cfg.get_entry(
                "hpx.parcel.mpi.env", default_env);

            typedef
                boost::tokenizer<boost::char_separator<char> >
                tokenizer;
            boost::char_separator<char> sep(";,: ");
            tokenizer tokens(mpi_environment_strings, sep);
            for(tokenizer::iterator it = tokens.begin(); it != tokens.end(); ++it)
            {
                char *env = std::getenv(it->c_str());
                if(env) return true;
            }
            return false;
#endif
        }
Пример #8
0
    parcelport::parcelport(util::runtime_configuration const& ini,
            std::string const& type)
      : parcels_(),
        here_(ini.get_parcelport_address()),
        max_message_size_(ini.get_max_message_size()),
        allow_array_optimizations_(true),
        allow_zero_copy_optimizations_(true),
        enable_security_(false),
        async_serialization_(false)
    {
        std::string key("hpx.parcel.");
        key += type;

        std::string array_optimization =
            ini.get_entry(key + ".array_optimization", "1");

        if (boost::lexical_cast<int>(array_optimization) == 0) {
            allow_array_optimizations_ = false;
            allow_zero_copy_optimizations_ = false;
        }
        else {
            std::string zero_copy_optimization =
                ini.get_entry(key + ".zero_copy_optimization", "1");
            if (boost::lexical_cast<int>(zero_copy_optimization) == 0)
                allow_zero_copy_optimizations_ = false;
        }

        std::string enable_security =
            ini.get_entry(key + ".enable_security", "0");
        if(boost::lexical_cast<int>(enable_security) != 0)
        {
            enable_security_ = true;
        }

        std::string async_serialization =
            ini.get_entry(key + ".async_serialization", "0");
        if(boost::lexical_cast<int>(async_serialization) != 0)
        {
            async_serialization_ = true;
        }
    }
Пример #9
0
    boost::shared_ptr<parcelport> parcelport::create(int type,
        util::runtime_configuration const& cfg,
        HPX_STD_FUNCTION<void(std::size_t, char const*)> const& on_start_thread,
        HPX_STD_FUNCTION<void()> const& on_stop_thread)
    {
        switch(type) {
        case connection_tcp:
            {
#if defined(HPX_HAVE_PARCELPORT_TCP)
                std::string enable_tcp =
                    cfg.get_entry("hpx.parcel.tcp.enable", "1");

                if (boost::lexical_cast<int>(enable_tcp))
                {
                    return boost::make_shared<policies::tcp::connection_handler>(
                        cfg, on_start_thread, on_stop_thread);
                }
#endif

                HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                    "unsupported connection type 'connection_tcp'");
            }

        case connection_ipc:
            {
#if defined(HPX_HAVE_PARCELPORT_IPC)
                // Create ipc based parcelport only if allowed by the
                // configuration info.
                std::string enable_ipc =
                    cfg.get_entry("hpx.parcel.ipc.enable", "0");

                if (boost::lexical_cast<int>(enable_ipc))
                {
                    return boost::make_shared<policies::ipc::connection_handler>(
                        cfg, on_start_thread, on_stop_thread);
                }
#endif
                HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                    "unsupported connection type 'connection_ipc'");
            }
            break;

        case connection_ibverbs:
#if defined(HPX_HAVE_PARCELPORT_IBVERBS)
            {
                // Create ibverbs based parcelport only if allowed by the
                // configuration info.
                std::string enable_ibverbs =
                    cfg.get_entry("hpx.parcel.ibverbs.enable", "0");

                if (boost::lexical_cast<int>(enable_ibverbs))
                {
                    return boost::make_shared<policies::ibverbs::connection_handler>(
                        cfg, on_start_thread, on_stop_thread);
                }
            }
#endif
            HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                "unsupported connection type 'connection_ibverbs'");
            break;

        case connection_portals4:
            HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                "unsupported connection type 'connection_portals4'");
            break;

        case connection_mpi:
#if defined(HPX_HAVE_PARCELPORT_MPI)
            {
                // Create MPI based parcelport only if allowed by the
                // configuration info.
                std::string enable_mpi =
                    cfg.get_entry("hpx.parcel.mpi.enable", "0");

                if (boost::lexical_cast<int>(enable_mpi))
                {
                    return boost::make_shared<policies::mpi::connection_handler>(
                        cfg, on_start_thread, on_stop_thread);
                }
            }
#endif

            HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                "unsupported connection type 'connection_mpi'");
            break;

        default:
            HPX_THROW_EXCEPTION(bad_parameter, "parcelport::create",
                "unknown connection type");
            break;
        }

        return boost::shared_ptr<parcelport>();
    }