コード例 #1
0
ファイル: parcelport.cpp プロジェクト: adk9/hpx
    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;
        }
    }
コード例 #2
0
ファイル: parcelport.cpp プロジェクト: adk9/hpx
    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);
    }
コード例 #3
0
ファイル: parcelport.cpp プロジェクト: fpelliccioni/hpx
    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>();
    }
コード例 #4
0
ファイル: mpi_environment.cpp プロジェクト: pra85/hpx
        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
        }
コード例 #5
0
ファイル: parcelport.cpp プロジェクト: adk9/hpx
    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>();
    }