Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ruben Laso Rodríguez
Thanos
Commits
f6fee4fd
Commit
f6fee4fd
authored
Mar 26, 2020
by
Ruben Laso Rodríguez
Browse files
Fixed bug when numa.h functions are not available.
parent
b0900e1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/system_info/system_info.hpp
View file @
f6fee4fd
...
...
@@ -13,6 +13,7 @@
#include
<linux/sched.h>
#include
<numa.h>
#include
<numeric>
#include
<sys/sysinfo.h>
#include
<unistd.h>
...
...
@@ -153,47 +154,88 @@ namespace system_info {
return
proc
.
unpin
(
print
);
}
}
// namespace auxiliary_functions
bool
detect_system
()
{
details
::
node_cpu_map
=
std
::
vector
<
std
::
vector
<
cpu_t
>>
(
details
::
NUM_OF_MEMORIES
);
for
(
node_t
node
=
0
;
node
<
details
::
NUM_OF_MEMORIES
;
node
++
)
{
details
::
node_cpu_map
[
node
]
=
auxiliary_functions
::
cpus_from_node
(
node
);
if
(
details
::
node_cpu_map
[
node
].
empty
())
{
return
false
;
bool
detect_system_NUMA
()
{
details
::
node_cpu_map
.
resize
(
details
::
NUM_OF_MEMORIES
);
for
(
node_t
node
=
0
;
node
<
details
::
NUM_OF_MEMORIES
;
node
++
)
{
details
::
node_cpu_map
[
node
]
=
auxiliary_functions
::
cpus_from_node
(
node
);
if
(
details
::
node_cpu_map
[
node
].
empty
())
{
return
false
;
}
}
}
details
::
cpu_node_map
=
std
::
vector
<
node_t
>
(
details
::
NUM_OF_CPUS
);
details
::
cpu_node_map
=
std
::
vector
<
node_t
>
(
details
::
NUM_OF_CPUS
);
details
::
cpu_tid_map
.
resize
(
details
::
NUM_OF_CPUS
);
details
::
node_tid_map
.
resize
(
details
::
NUM_OF_MEMORIES
);
details
::
cpu_tid_map
.
resize
(
details
::
NUM_OF_CPUS
);
details
::
node_tid_map
.
resize
(
details
::
NUM_OF_MEMORIES
);
// For each CPU, reads topology file to get package (node) id
for
(
size_t
cpu
=
0
;
cpu
<
details
::
NUM_OF_CPUS
;
cpu
++
)
{
details
::
cpu_node_map
[
cpu
]
=
numa_node_of_cpu
(
cpu
);
}
// For each CPU, reads topology file to get package (node) id
for
(
size_t
cpu
=
0
;
cpu
<
details
::
NUM_OF_CPUS
;
cpu
++
)
{
details
::
cpu_node_map
[
cpu
]
=
numa_node_of_cpu
(
cpu
);
}
// Compute the lists of nodes sorted by distance from a given node...
for
(
node_t
node
=
0
;
node
<
details
::
NUM_OF_MEMORIES
;
node
++
)
{
std
::
multimap
<
int
,
node_t
>
distance_nodes_map
{};
for
(
size_t
node2
=
0
;
node2
<
details
::
NUM_OF_MEMORIES
;
node2
++
)
{
distance_nodes_map
.
insert
(
std
::
pair
(
numa_distance
(
node
,
node2
),
node2
));
// Compute the lists of nodes sorted by distance from a given node...
for
(
node_t
node
=
0
;
node
<
details
::
NUM_OF_MEMORIES
;
node
++
)
{
std
::
multimap
<
int
,
node_t
>
distance_nodes_map
{};
for
(
size_t
node2
=
0
;
node2
<
details
::
NUM_OF_MEMORIES
;
node2
++
)
{
distance_nodes_map
.
insert
(
std
::
pair
(
numa_distance
(
node
,
node2
),
node2
));
}
std
::
vector
<
node_t
>
nodes_by_distance
;
for
(
const
auto
&
[
distance
,
node2
]
:
distance_nodes_map
)
{
nodes_by_distance
.
push_back
(
node2
);
}
details
::
nodes_by_distance
[
node
]
=
nodes_by_distance
;
}
std
::
vector
<
node_t
>
nodes_by_distance
;
for
(
const
auto
&
[
distance
,
node2
]
:
distance_nodes_map
)
{
nodes_by_distance
.
push_back
(
node2
);
if
(
VERBOSE_LVL
>=
DEFAULT_VERB
)
{
for
(
const
auto
&
[
node
,
nodes
]
:
details
::
nodes_by_distance
)
{
std
::
cout
<<
"Node "
<<
node
<<
":"
<<
'\n'
;
for
(
const
auto
&
node2
:
nodes
)
{
std
::
cout
<<
"
\t
Node "
<<
node2
<<
" (distance "
<<
numa_distance
(
node
,
node2
)
<<
")"
<<
'\n'
;
}
}
}
details
::
nodes_by_distance
[
node
]
=
nodes_by_distance
;
return
true
;
}
if
(
VERBOSE_LVL
>=
DEFAULT_VERB
)
{
for
(
const
auto
&
[
node
,
nodes
]
:
details
::
nodes_by_distance
)
{
std
::
cout
<<
"Node "
<<
node
<<
":"
<<
'\n'
;
for
(
const
auto
&
node2
:
nodes
)
{
std
::
cout
<<
"
\t
Node "
<<
node2
<<
" (distance "
<<
numa_distance
(
node
,
node2
)
<<
")"
<<
'\n'
;
}
bool
detect_system_UMA
()
{
details
::
NUM_OF_MEMORIES
=
1
;
details
::
CPUS_PER_MEMORY
=
details
::
NUM_OF_CPUS
/
details
::
NUM_OF_MEMORIES
;
std
::
vector
<
cpu_t
>
cpus
(
details
::
NUM_OF_CPUS
);
std
::
iota
(
cpus
.
begin
(),
cpus
.
end
(),
0
);
details
::
node_cpu_map
.
resize
(
details
::
NUM_OF_MEMORIES
);
details
::
node_cpu_map
[
0
]
=
cpus
;
details
::
cpu_node_map
=
std
::
vector
<
node_t
>
(
details
::
NUM_OF_CPUS
,
0
);
details
::
cpu_tid_map
.
resize
(
details
::
NUM_OF_CPUS
);
details
::
node_tid_map
.
resize
(
details
::
NUM_OF_MEMORIES
);
// For each CPU, reads topology file to get package (node) id
for
(
size_t
cpu
=
0
;
cpu
<
details
::
NUM_OF_CPUS
;
cpu
++
)
{
details
::
cpu_node_map
[
cpu
]
=
0
;
}
// Compute the lists of nodes sorted by distance from a given node...
details
::
nodes_by_distance
[
0
]
=
{
0
};
return
true
;
}
}
// namespace auxiliary_functions
bool
detect_system
()
{
bool
ret_value
;
if
(
numa_available
()
==
-
1
)
{
std
::
cerr
<<
"NUMA support not available. Assuming you are using a UMA machine. Trying to survive..."
<<
'\n'
;
ret_value
=
auxiliary_functions
::
detect_system_UMA
();
}
else
{
ret_value
=
auxiliary_functions
::
detect_system_NUMA
();
}
if
(
VERBOSE_LVL
>=
DEFAULT_VERB
)
{
...
...
@@ -201,7 +243,7 @@ namespace system_info {
<<
" memory nodes, "
<<
details
::
CPUS_PER_MEMORY
<<
" CPUs per node."
<<
'\n'
;
}
return
t
rue
;
return
r
et_val
ue
;
}
void
scan_dir
(
const
char
*
dirname
,
process
*
parent
=
nullptr
,
bool
scan_children
=
true
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment