本文整理汇总了C++中hwloc_topology::get_number_of_socket_cores方法的典型用法代码示例。如果您正苦于以下问题:C++ hwloc_topology::get_number_of_socket_cores方法的具体用法?C++ hwloc_topology::get_number_of_socket_cores怎么用?C++ hwloc_topology::get_number_of_socket_cores使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hwloc_topology
的用法示例。
在下文中一共展示了hwloc_topology::get_number_of_socket_cores方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: decode_mapping_socket
mask_type decode_mapping_socket(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 socket_index = 0;
for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++socket_index)
{
if (index == std::size_t(-1) || socket_index == index)
mask |= t.init_socket_affinity_mask_from_socket(*it);
}
std::size_t socket_base_index = *b.begin();
if (thread_index != std::size_t(-1) && b.size() > 1)
socket_base_index += thread_index;
std::size_t base_index = 0;
for (std::size_t i = 0; i != socket_base_index; ++i)
base_index += t.get_number_of_socket_cores(i);
return decode_mapping0_unknown(t, m, size, mask, base_index,
thread_index, ec);
}