本文整理汇总了C++中hwloc_topology::init_core_affinity_mask_from_core方法的典型用法代码示例。如果您正苦于以下问题:C++ hwloc_topology::init_core_affinity_mask_from_core方法的具体用法?C++ hwloc_topology::init_core_affinity_mask_from_core怎么用?C++ hwloc_topology::init_core_affinity_mask_from_core使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hwloc_topology
的用法示例。
在下文中一共展示了hwloc_topology::init_core_affinity_mask_from_core方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: switch
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;
}