]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/src/numa/solaris/topology.cpp
2 // Copyright Oliver Kowalke 2017.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #include "boost/fiber/numa/topology.hpp"
11 #include <sys/lgrp_user.h>
14 #include <system_error>
16 #ifdef BOOST_HAS_ABI_HEADERS
17 # include BOOST_ABI_PREFIX
22 void explore( std::vector
< boost::fibers::numa::node
> & topo
, lgrp_cookie_t cookie
, lgrp_id_t node
) {
23 int size
= ::lgrp_cpus( cookie
, node
, nullptr, 0, LGRP_CONTENT_HIERARCHY
);
27 // is node a NUMA Node?
28 if ( 0 < ::lgrp_mem_size( cookie
, node
, LGRP_MEM_SZ_INSTALLED
, LGRP_CONTENT_DIRECT
) ) {
29 std::vector
< processorid_t
> cpus
;
31 ::lgrp_cpus( cookie
, node
, cpus
.data(), size
, LGRP_CONTENT_HIERARCHY
);
32 boost::fibers::numa::node n
;
33 n
.id
= static_cast< std::uint32_t >( node
);
34 for ( auto cpu_id
: cpus
) {
35 n
.logical_cpus
.insert( static_cast< std::uint32_t >( cpu_id
) );
39 size
= ::lgrp_children( cookie
, node
, nullptr, 0);
40 std::vector
< lgrp_id_t
> nodes
;
42 ::lgrp_children( cookie
, node
, nodes
.data(), size
);
43 for ( auto node
: nodes
) {
44 explore( topo
, cookie
, node
);
55 std::vector
< node
> topology() {
56 std::vector
< node
> topo
;
57 lgrp_cookie_t cookie
= ::lgrp_init( LGRP_VIEW_OS
);
58 if ( BOOST_UNLIKELY( LGRP_COOKIE_NONE
== cookie
) ) {
59 throw std::system_error
{
60 std::error_code
{ errno
, std::system_category() },
61 "lprp_init() failed" };
63 lgrp_id_t root
= ::lgrp_root( cookie
);
64 explore( topo
, cookie
, root
);
67 std::size_t size
= topo
.size();
68 for ( auto & n
: topo
) {
69 for ( std::size_t i
= 0; i
< size
; ++i
) {
70 n
.distance
.push_back( n
.id
== i
? 10 : 20);
78 #ifdef BOOST_HAS_ABI_HEADERS
79 # include BOOST_ABI_SUFFIX