• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ hwloc_topology类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中hwloc_topology的典型用法代码示例。如果您正苦于以下问题:C++ hwloc_topology类的具体用法?C++ hwloc_topology怎么用?C++ hwloc_topology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了hwloc_topology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: decode_scatter_distribution

    void decode_scatter_distribution(hwloc_topology& t,
        std::vector<mask_type>& affinities, error_code& ec)
    {
        std::size_t num_threads = affinities.size();
        std::size_t num_cores = t.get_number_of_cores();

        std::vector<std::size_t> num_pus_cores(num_cores, 0);
        for (std::size_t num_thread = 0; num_thread != num_threads; /**/)
        {
            for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
            {
                if (any(affinities[num_thread]))
                {
                    HPX_THROWS_IF(ec, bad_parameter, "decode_scatter_distribution",
                        boost::str(boost::format("affinity mask for thread %1% has "
                            "already been set") % num_thread));
                    return;
                }

                // Check if we exceed the number of PUs on the current core.
                // If yes, we need to proceed with the next one.
                std::size_t num_pus_core = t.get_number_of_core_pus(num_core);
                if(num_pus_cores[num_core] == num_pus_core) continue;

                affinities[num_thread] = t.init_thread_affinity_mask(
                    num_core, num_pus_cores[num_core]++);

                if(++num_thread == num_threads)
                    return;
            }
        }
    }
开发者ID:qiutaoleo,项目名称:hpx,代码行数:32,代码来源:parse_affinity_options.cpp


示例2: decode_scatter_distribution

    void decode_scatter_distribution(hwloc_topology& t,
        std::vector<mask_type>& affinities,
        std::size_t used_cores, std::size_t max_cores,
        std::vector<std::size_t>& num_pus, error_code& ec)
    {
        std::size_t num_threads = affinities.size();
        std::size_t num_cores = (std::min)(max_cores, t.get_number_of_cores());

        std::vector<std::size_t> num_pus_cores(num_cores, 0);
        num_pus.resize(num_threads);

        for (std::size_t num_thread = 0; num_thread != num_threads; /**/)
        {
            for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
            {
                if (any(affinities[num_thread]))
                {
                    HPX_THROWS_IF(ec, bad_parameter, "decode_scatter_distribution",
                        boost::str(boost::format("affinity mask for thread %1% has "
                            "already been set") % num_thread));
                    return;
                }

                num_pus[num_thread] = t.get_pu_number(num_core + used_cores,
                    num_pus_cores[num_core]);
                affinities[num_thread] = t.init_thread_affinity_mask(
                    num_core + used_cores, num_pus_cores[num_core]++);

                if(++num_thread == num_threads)
                    return;
            }
        }
    }
开发者ID:HadrienG2,项目名称:hpx,代码行数:33,代码来源:parse_affinity_options.cpp


示例3: decode_mapping_numanode

    mask_type decode_mapping_numanode(hwloc_topology const& t,
        mapping_type& m, std::size_t size, std::size_t thread_index,
        error_code& ec)
    {
        bounds_type b = extract_bounds(m[0], size, ec);
        if (ec) return 0;

        std::size_t index = std::size_t(-1);
        if (m[1].type_ == spec_type::unknown &&
            m[2].type_ == spec_type::unknown &&
            b.size() > 1)
        {
            index = thread_index;
        }

        mask_type mask = 0;
        std::size_t node_index = 0;
        for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++node_index)
        {
            if (index == std::size_t(-1) || node_index == index)
                mask |= t.init_numa_node_affinity_mask_from_numa_node(*it);
        }

        std::size_t node_base_index = *b.begin();
        if (thread_index != std::size_t(-1) && b.size() > 1)
            node_base_index += thread_index;

        std::size_t base_index = 0;
        for (std::size_t i = 0; i != node_base_index; ++i)
            base_index += t.get_number_of_numa_node_cores(i);

        return decode_mapping0_unknown(t, m, size, mask, base_index,
            thread_index, ec);
    }
开发者ID:fpelliccioni,项目名称:hpx,代码行数:34,代码来源:parse_affinity_options.cpp


示例4: decode_mapping_core

    mask_type decode_mapping_core(hwloc_topology const& t,
        mapping_type& m, std::size_t size, mask_type mask,
        std::size_t core_base_index, std::size_t thread_index, error_code& ec)
    {
        bounds_type b = extract_bounds(m[1], size, ec);
        if (ec) return 0;

        // We have to account for the thread index at this level if there are
        // no specifications related to processing units.
        std::size_t index = std::size_t(-1);
        if (m[2].type_ == spec_type::unknown && b.size() > 1)
            index = thread_index;

        mask_type core_mask = 0;
        std::size_t core_index = 0;
        for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++core_index)
        {
            if (index == std::size_t(-1) || core_index == index)
            {
                core_mask |= t.init_core_affinity_mask_from_core(
                    *it+core_base_index, 0);
            }
        }

        core_base_index += *b.begin();
        if (thread_index != std::size_t(-1) && b.size() > 1)
            core_base_index += thread_index;

        std::size_t base_index = 0;
        for (std::size_t i = 0; i != core_base_index; ++i)
            base_index += t.get_number_of_core_pus(i);

        return decode_mapping1_unknown(t, m, size, mask & core_mask,
            base_index, thread_index, ec);
    }
开发者ID:fpelliccioni,项目名称:hpx,代码行数:35,代码来源:parse_affinity_options.cpp


示例5: extract_core_masks

    std::vector<mask_info>
    extract_core_masks(hwloc_topology const& t, spec_type const& s,
        std::size_t socket, mask_cref_type socket_mask, error_code& ec)
    {
        std::vector<mask_info> masks;

        switch (s.type_)
        {
        case spec_type::core:
            {
                std::size_t base = 0;
                std::size_t num_cores = 0;

                if (socket != std::size_t(-1))
                {
                    for (std::size_t i = 0; i != socket; ++i)
                        base += t.get_number_of_socket_cores(i);
                    num_cores = t.get_number_of_socket_cores(socket);
                }
                else
                {
                    num_cores = t.get_number_of_cores();
                }

                bounds_type bounds = extract_bounds(s, num_cores, ec);
                if (ec) break;

                for (std::int64_t index : bounds)
                {
                    mask_type mask =
                        t.init_core_affinity_mask_from_core(index + base);
                    masks.push_back(util::make_tuple(index, mask & socket_mask));
                }
            }
            break;

        case spec_type::unknown:
            {
                mask_type mask = extract_machine_mask(t, ec);
                masks.push_back(util::make_tuple(
                    std::size_t(-1), mask & socket_mask
                ));
            }
            break;

        default:
            HPX_THROWS_IF(ec, bad_parameter, "extract_core_mask",
                boost::str(boost::format(
                    "unexpected specification type %s"
                ) % spec_type::type_name(s.type_)));
            break;
        }

        return masks;
    }
开发者ID:brycelelbach,项目名称:hpx,代码行数:55,代码来源:parse_affinity_options.cpp


示例6: decode_balanced_distribution

    void decode_balanced_distribution(hwloc_topology& t,
        std::vector<mask_type>& affinities,
        std::size_t used_cores, std::size_t max_cores,
        std::vector<std::size_t>& num_pus, error_code& ec)
    {
        std::size_t num_threads = affinities.size();
        std::size_t num_cores = (std::min)(max_cores, t.get_number_of_cores());

        std::vector<std::size_t> num_pus_cores(num_cores, 0);
        num_pus.resize(num_threads);

        // At first, calculate the number of used pus per core.
        // This needs to be done to make sure that we occupy all the available
        // cores
        for (std::size_t num_thread = 0; num_thread != num_threads; /**/)
        {
            for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
            {
                num_pus_cores[num_core]++;
                if(++num_thread == num_threads)
                    break;
            }
        }

        // Iterate over the cores and assigned pus per core. this additional
        // loop is needed so that we have consecutive worker thread numbers
        std::size_t num_thread = 0;
        for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
        {
            for(std::size_t num_pu = 0; num_pu != num_pus_cores[num_core]; ++num_pu)
            {
                if (any(affinities[num_thread]))
                {
                    HPX_THROWS_IF(ec, bad_parameter,
                        "decode_balanced_distribution",
                        boost::str(boost::format(
                            "affinity mask for thread %1% has "
                            "already been set"
                        ) % num_thread));
                    return;
                }
                num_pus[num_thread] = t.get_pu_number(num_core + used_cores, num_pu);
                affinities[num_thread] = t.init_thread_affinity_mask(
                    num_core + used_cores, num_pu);
                ++num_thread;
            }
        }
    }
开发者ID:brycelelbach,项目名称:hpx,代码行数:48,代码来源:parse_affinity_options.cpp


示例7: decode_mapping

    mask_type decode_mapping(hwloc_topology const& t,
        mapping_type& m, std::vector<mask_type>& affinities,
        std::size_t thread_index, error_code& ec)
    {
        std::size_t size = affinities.size();
        mask_type mask;
        switch (m[0].type_) {
        case spec_type::socket:
            // requested top level is a socket
            mask = decode_mapping_socket(t, m, size, thread_index, ec);
            break;

        case spec_type::numanode:
            // requested top level is a NUMA node
            mask = decode_mapping_numanode(t, m, size, thread_index, ec);
            break;

        case spec_type::unknown:
            // no top level is requested
            mask = decode_mapping0_unknown(t, m, size,
                t.get_machine_affinity_mask(), 0, thread_index, ec);
            break;

        default:
            HPX_THROWS_IF(ec, bad_parameter, "decode_mapping",
                boost::str(boost::format("unexpected specification type at "
                    "index zero: %x (%s)") %
                        static_cast<unsigned>(m[0].type_) %
                        spec_type::type_name(m[0].type_)));
            return mask_type();
        }
        return mask;
    }
开发者ID:HadrienG2,项目名称:hpx,代码行数:33,代码来源:parse_affinity_options.cpp


示例8: decode_mapping0_unknown

    mask_type decode_mapping0_unknown(hwloc_topology const& t,
        mapping_type& m, std::size_t size, mask_type mask,
        std::size_t core_base_index, std::size_t thread_index, error_code& ec)
    {
        switch (m[1].type_) {
        case spec_type::core:
            mask = decode_mapping_core(t, m, size, mask, core_base_index,
                thread_index, ec);
            break;

        case spec_type::unknown:
            {
                std::size_t base_index = 0;
                for (std::size_t i = 0; i != core_base_index; ++i)
                    base_index += t.get_number_of_core_pus(i);

                mask = decode_mapping1_unknown(t, m, size, mask, base_index,
                    thread_index, ec);
            }
            break;

        default:
            HPX_THROWS_IF(ec, bad_parameter, "decode_mapping0_unknown",
                boost::str(boost::format("unexpected specification type at "
                    "index one: %x (%s)") %
                        static_cast<unsigned>(m[1].type_) %
                        spec_type::type_name(m[1].type_)));
            break;
        }
        return mask;
    }
开发者ID:HadrienG2,项目名称:hpx,代码行数:31,代码来源:parse_affinity_options.cpp


示例9: decode_balanced_distribution

    void decode_balanced_distribution(hwloc_topology& t,
        std::vector<mask_type>& affinities, error_code& ec)
    {
        std::size_t num_threads = affinities.size();
        std::size_t num_cores = t.get_number_of_cores();

        std::vector<std::size_t> num_pus_cores(num_cores, 0);
        // At first, calculate the number of used pus per core.
        // This needs to be done to make sure that we occupy all the available cores
        for (std::size_t num_thread = 0; num_thread != num_threads; /**/)
        {
            for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
            {
                // Check if we exceed the number of PUs on the current core.
                // If yes, we need to proceed with the next one.
                std::size_t num_pus_core = t.get_number_of_core_pus(num_core);
                if(num_pus_cores[num_core] == num_pus_core) continue;

                num_pus_cores[num_core]++;
                if(++num_thread == num_threads)
                    break;
            }
        }
        // Iterate over the cores and assigned pus per core. this additional loop
        // is needed so that we have consecutive worker thread numbers
        std::size_t num_thread = 0;
        for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
        {
            for(std::size_t num_pu = 0; num_pu != num_pus_cores[num_core]; ++num_pu)
            {
                if (any(affinities[num_thread]))
                {
                    HPX_THROWS_IF(ec, bad_parameter, "decode_balanced_distribution",
                        boost::str(boost::format("affinity mask for thread %1% has "
                            "already been set") % num_thread));
                    return;
                }
                affinities[num_thread] = t.init_thread_affinity_mask(
                    num_core, num_pu);
                ++num_thread;
            }
        }
    }
开发者ID:qiutaoleo,项目名称:hpx,代码行数:43,代码来源:parse_affinity_options.cpp


示例10: extract_socket_or_numanode_masks

    std::vector<mask_info>
    extract_socket_or_numanode_masks(hwloc_topology const& t,
        spec_type const& s, error_code& ec)
    {
        switch (s.type_)
        {
        case spec_type::socket:
            // requested top level is a socket
            {
                std::size_t num_sockets = t.get_number_of_sockets();
                return extract_socket_masks(
                    t, extract_bounds(s, num_sockets, ec));
            }

        case spec_type::numanode:
            // requested top level is a NUMA node
            {
                std::size_t num_numanodes = t.get_number_of_numa_nodes();
                return extract_numanode_masks(
                    t, extract_bounds(s, num_numanodes, ec));
            }

        case spec_type::unknown:
            {
                std::vector<mask_info> masks;
                masks.push_back(util::make_tuple(
                    std::size_t(-1), extract_machine_mask(t, ec)
                ));
                return masks;
            }

        default:
            HPX_THROWS_IF(ec, bad_parameter, "extract_socket_or_numanode_mask",
                boost::str(boost::format(
                    "unexpected specification type %s"
                ) % spec_type::type_name(s.type_)));
            break;
        }

        return std::vector<mask_info>();
    }
开发者ID:brycelelbach,项目名称:hpx,代码行数:41,代码来源:parse_affinity_options.cpp


示例11: extract_numanode_masks

 std::vector<mask_info>
 extract_numanode_masks(hwloc_topology const& t, bounds_type const& b)
 {
     std::vector<mask_info> masks;
     for (std::int64_t index : b)
     {
         masks.push_back(util::make_tuple(
             index, t.init_numa_node_affinity_mask_from_numa_node(index)
         ));
     }
     return masks;
 }
开发者ID:brycelelbach,项目名称:hpx,代码行数:12,代码来源:parse_affinity_options.cpp


示例12: decode_compact_distribution

 void decode_compact_distribution(hwloc_topology& t,
     std::vector<mask_type>& affinities, error_code& ec)
 {
     std::size_t num_threads = affinities.size();
     for(std::size_t i = 0; i != num_threads; ++i)
     {
         if (any(affinities[i]))
         {
             HPX_THROWS_IF(ec, bad_parameter, "decode_compact_distribution",
                 boost::str(boost::format("affinity mask for thread %1% has "
                     "already been set") % i));
             return;
         }
         affinities[i] = t.init_thread_affinity_mask(i);
     }
 }
开发者ID:qiutaoleo,项目名称:hpx,代码行数:16,代码来源:parse_affinity_options.cpp


示例13: decode_mapping_pu

    mask_type decode_mapping_pu(hwloc_topology const& t,
        mapping_type& m, std::size_t size, mask_type mask,
        std::size_t pu_base_index, std::size_t thread_index, error_code& ec)
    {
        bounds_type b = extract_bounds(m[2], size, ec);
        if (ec) return 0;

        std::size_t index = std::size_t(-1);
        if (b.size() > 1)
            index = thread_index;

        mask_type pu_mask = 0;
        std::size_t pu_index = 0;
        for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++pu_index)
        {
            if (index == std::size_t(-1) || pu_index == index)
                pu_mask |= t.init_thread_affinity_mask(*it+pu_base_index);
        }

        return mask & pu_mask;
    }
开发者ID:fpelliccioni,项目名称:hpx,代码行数:21,代码来源:parse_affinity_options.cpp


示例14: extract_pu_masks

    std::vector<mask_info>
    extract_pu_masks(hwloc_topology const& t, spec_type const& s,
        std::size_t socket, std::size_t core, mask_cref_type core_mask,
        error_code& ec)
    {
        std::vector<mask_info> masks;

        switch (s.type_)
        {
        case spec_type::pu:
            {
                std::size_t num_pus = 0;
                std::size_t socket_base = 0;
                if (std::size_t(-1) != socket)
                {
                    // core number is relative to socket
                    for (std::size_t i = 0; i != socket; ++i)
                        socket_base += t.get_number_of_socket_cores(i);
                }

                if (std::size_t(-1) != core)
                {
                    num_pus = t.get_number_of_core_pus(core);
                }
                else
                {
                    num_pus = t.get_number_of_pus();
                }

                bounds_type bounds = extract_bounds(s, num_pus, ec);
                if (ec) break;

                std::size_t num_cores = t.get_number_of_cores();
                for (std::int64_t index : bounds)
                {
                    std::size_t base_core = socket_base;
                    if (std::size_t(-1) != core)
                    {
                        base_core += core;
                    }
                    else
                    {
                        // find core the given pu belongs to
                        std::size_t base = 0;
                        for (/**/; base_core < num_cores; ++base_core)
                        {
                            std::size_t num_core_pus =
                                t.get_number_of_core_pus(base_core);
                            if (base + num_core_pus > std::size_t(index))
                                break;
                            base += num_core_pus;
                        }
                    }

                    mask_type mask = t.init_thread_affinity_mask(base_core, index);
                    masks.push_back(util::make_tuple(index, mask & core_mask));
                }
            }
            break;

        case spec_type::unknown:
            {
                mask_type mask = extract_machine_mask(t, ec);
                masks.push_back(util::make_tuple(
                    std::size_t(-1), mask & core_mask
                ));
            }
            break;

        default:
            HPX_THROWS_IF(ec, bad_parameter, "extract_pu_mask",
                boost::str(boost::format(
                    "unexpected specification type %s"
                ) % spec_type::type_name(s.type_)));
            break;
        }

        return masks;
    }
开发者ID:brycelelbach,项目名称:hpx,代码行数:79,代码来源:parse_affinity_options.cpp


示例15: extract_machine_mask

 mask_cref_type extract_machine_mask(hwloc_topology const& t, error_code& ec)
 {
     return t.get_machine_affinity_mask(ec);
 }
开发者ID:brycelelbach,项目名称:hpx,代码行数:4,代码来源:parse_affinity_options.cpp



注:本文中的hwloc_topology类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ i2c_iface类代码示例发布时间:2022-05-31
下一篇:
C++ http_request类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap