当前位置: 首页>>代码示例>>C++>>正文


C++ hwloc_topology::get_pu_number方法代码示例

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


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

示例1: 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

示例2: 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


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