Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philippe SWARTVAGHER
memory-contention
Commits
e1d233b0
Commit
e1d233b0
authored
Nov 08, 2021
by
Philippe SWARTVAGHER
Browse files
Support binding on many NUMA nodes for computation memory
parent
3358e6fb
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/bench.c
View file @
e1d233b0
...
...
@@ -224,7 +224,7 @@ int main(int argc, char* argv[])
#endif
fill_machine
(
&
machine
);
init_malloc
(
machine
.
topology
,
params
.
memory_comp_numa_node
,
params
.
memory_comm_numa_node
);
init_malloc
(
machine
.
topology
,
params
.
memory_comp_numa_node
_str
,
params
.
memory_comm_numa_node
);
if
(
params
.
display_help
)
{
...
...
@@ -479,5 +479,7 @@ int main(int argc, char* argv[])
}
#endif
release_malloc
();
return
EXIT_SUCCESS
;
}
src/cli.c
View file @
e1d233b0
...
...
@@ -83,7 +83,7 @@ void parse_args(int argc, char* argv[], struct params_s* params)
params
->
comm_bench_type
=
LATENCY
;
params
->
computing
=
stream_get_functions
();
params
->
ping_thread_location
=
LAST
;
params
->
memory_comp_numa_node
=
-
1
;
params
->
memory_comp_numa_node
_str
=
NULL
;
params
->
memory_comm_numa_node
=
-
1
;
params
->
pingpong_type
=
PING_PONG
;
...
...
@@ -192,7 +192,7 @@ void parse_args(int argc, char* argv[], struct params_s* params)
else
if
(
strncmp
(
argv
[
i
],
"--bind_memory_comp="
,
19
)
==
0
)
{
CHECK_PARAM
(
BIND_MEMORY_COMP
);
params
->
memory_comp_numa_node
=
atoi
(
argv
[
i
]
+
19
)
;
params
->
memory_comp_numa_node
_str
=
argv
[
i
]
+
19
;
}
else
if
(
strncmp
(
argv
[
i
],
"--bind_memory_comm="
,
19
)
==
0
)
{
...
...
@@ -347,13 +347,13 @@ void print_params(struct params_s params)
if
(
enabled_params
[
BIND_MEMORY_COMP
])
{
if
(
params
.
memory_comp_numa_node
==
-
1
)
if
(
params
.
memory_comp_numa_node
_str
==
NULL
)
{
printf
(
"# Will not bind memory used for computations
\n
"
);
}
else
{
printf
(
"# Will bind memory used for computations to NUMA node %
d
\n
"
,
params
.
memory_comp_numa_node
);
printf
(
"# Will bind memory used for computations to NUMA node
(s)
%
s
\n
"
,
params
.
memory_comp_numa_node
_str
);
}
}
...
...
@@ -439,7 +439,7 @@ void print_help(struct params_s params)
}
if
(
enabled_params
[
BIND_MEMORY_COMP
])
{
printf
(
"--bind_memory_comp=<numa node> on which NUMA node bind memory allocated for computations
\n
"
);
printf
(
"--bind_memory_comp=<numa node> on which NUMA node
(s)
bind memory allocated for computations
(separate with commas)
\n
"
);
}
if
(
enabled_params
[
BIND_MEMORY_COMM
])
{
...
...
src/cli.h
View file @
e1d233b0
...
...
@@ -43,7 +43,7 @@ struct params_s {
int
display_binding
;
int
pingpong_size
;
int
display_help
;
int
memory_comp_numa_node
;
char
*
memory_comp_numa_node
_str
;
int
memory_comm_numa_node
;
int
one_computing_rank
;
int
per_thread_perf
;
...
...
src/helper.h
View file @
e1d233b0
...
...
@@ -100,6 +100,7 @@ struct computing_functions memset_get_functions();
#include
<starpu_mpi.h>
#define init_malloc(_a, _b, _c)
#define release_malloc()
#define get_worker_count starpu_worker_get_count
#define timing_now(var) var = starpu_timing_now()
#define time_type double
...
...
src/malloc.c
View file @
e1d233b0
...
...
@@ -5,14 +5,36 @@
#endif
static
hwloc_topology_t
topology
;
static
in
t
memory_comp_numa_node
;
static
hwloc_bitmap_
t
memory_comp_numa_node
_bitmap
;
static
int
memory_comm_numa_node
;
void
init_malloc
(
hwloc_topology_t
_topology
,
int
_memory_comp_numa_node
,
int
_memory_comm_numa_node
)
void
init_malloc
(
hwloc_topology_t
_topology
,
char
*
_memory_comp_numa_node
_str
,
int
_memory_comm_numa_node
)
{
topology
=
_topology
;
memory_comm_numa_node
=
_memory_comm_numa_node
;
memory_comp_numa_node
=
_memory_comp_numa_node
;
memory_comp_numa_node_bitmap
=
hwloc_bitmap_alloc
();
// empty when allocated
const
char
delim
[]
=
","
;
char
*
sub
=
strtok
(
_memory_comp_numa_node_str
,
delim
);
for
(;
sub
!=
NULL
;
sub
=
strtok
(
NULL
,
delim
))
{
int
logical_index
=
atoi
(
sub
);
hwloc_obj_t
obj
=
hwloc_get_obj_by_type
(
topology
,
HWLOC_OBJ_NUMANODE
,
logical_index
);
if
(
obj
==
NULL
)
{
fprintf
(
stderr
,
"Cannot find NUMA node %d
\n
"
,
logical_index
);
abort
();
}
hwloc_bitmap_or
(
memory_comp_numa_node_bitmap
,
memory_comp_numa_node_bitmap
,
obj
->
nodeset
);
}
}
void
release_malloc
()
{
hwloc_bitmap_free
(
memory_comp_numa_node_bitmap
);
}
static
inline
void
*
data_malloc
(
size_t
size
,
int
numa_node
)
...
...
@@ -48,7 +70,21 @@ void* comm_malloc(size_t size)
void
*
comp_malloc
(
size_t
size
)
{
return
data_malloc
(
size
,
memory_comp_numa_node
);
if
(
hwloc_bitmap_iszero
(
memory_comp_numa_node_bitmap
))
{
return
malloc
(
size
);
}
else
{
const
hwloc_membind_policy_t
policy
=
(
hwloc_bitmap_weight
(
memory_comp_numa_node_bitmap
)
==
1
)
?
HWLOC_MEMBIND_BIND
:
HWLOC_MEMBIND_INTERLEAVE
;
/* HWLOC_MEMBIND_BYNODESET: Consider the bitmap argument as a nodeset.
* HWLOC_MEMBIND_NOCPUBIND: Avoid any effect on CPU binding. */
#if HWLOC_API_VERSION >= 0x00020000
return
hwloc_alloc_membind
(
topology
,
size
,
memory_comp_numa_node_bitmap
,
policy
,
HWLOC_MEMBIND_BYNODESET
|
HWLOC_MEMBIND_NOCPUBIND
);
#else
return
hwloc_alloc_membind_nodeset
(
topology
,
size
,
memory_comp_numa_node_bitmap
,
policy
,
HWLOC_MEMBIND_NOCPUBIND
);
#endif
}
}
static
inline
void
data_free
(
void
*
ptr
,
size_t
size
,
int
numa_node
)
...
...
@@ -70,5 +106,12 @@ void comm_free(void* ptr, size_t size)
void
comp_free
(
void
*
ptr
,
size_t
size
)
{
data_free
(
ptr
,
size
,
memory_comp_numa_node
);
if
(
hwloc_bitmap_iszero
(
memory_comp_numa_node_bitmap
))
{
free
(
ptr
);
}
else
{
hwloc_free
(
topology
,
ptr
,
size
);
}
}
src/malloc.h
View file @
e1d233b0
...
...
@@ -3,7 +3,8 @@
#include
<hwloc.h>
void
init_malloc
(
hwloc_topology_t
_topology
,
int
_memory_comp_numa_node
,
int
_memory_comm_numa_node
);
void
init_malloc
(
hwloc_topology_t
_topology
,
char
*
_memory_comp_numa_node_str
,
int
_memory_comm_numa_node
);
void
release_malloc
();
void
*
comm_malloc
(
size_t
size
);
void
*
comp_malloc
(
size_t
size
);
void
comm_free
(
void
*
ptr
,
size_t
size
);
...
...
src/overlap.c
View file @
e1d233b0
...
...
@@ -130,7 +130,7 @@ int main(int argc, char* argv[])
#endif
fill_machine
(
&
machine
);
init_malloc
(
machine
.
topology
,
params
.
memory_comp_numa_node
,
params
.
memory_comm_numa_node
);
init_malloc
(
machine
.
topology
,
params
.
memory_comp_numa_node
_str
,
params
.
memory_comm_numa_node
);
if
(
params
.
display_help
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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