Commit f1d1b932 authored by Philippe SWARTVAGHER's avatar Philippe SWARTVAGHER
Browse files

Fix round-robin mecanism to allocate memory for computations

parent 55ceaf9c
......@@ -224,7 +224,7 @@ int main(int argc, char* argv[])
#endif
fill_machine(&machine);
init_malloc(&machine, params.memory_comp_numa_node_str, params.memory_comm_numa_node);
init_malloc(&machine, params.memory_comp_numa_nodes, params.memory_comp_numa_nodes_nb, params.memory_comm_numa_node);
if (params.display_help)
{
......
......@@ -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_str = NULL;
params->memory_comp_numa_nodes_nb = 0;
params->memory_comm_numa_node = -1;
params->pingpong_type = PING_PONG;
......@@ -192,7 +192,18 @@ 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_str = argv[i] + 19;
const char delim[] = "-,";
char* sub = strtok(argv[i]+19, delim);
for (; sub != NULL; sub = strtok(NULL, delim))
{
if (params->memory_comp_numa_nodes_nb >= MAX_NUMA_NODES)
{
fprintf(stderr, "Maximum number of NUMA nodes reached (%d)\n", MAX_NUMA_NODES);
abort();
}
params->memory_comp_numa_nodes[params->memory_comp_numa_nodes_nb++] = atoi(sub);
}
}
else if (strncmp(argv[i], "--bind_memory_comm=", 19) == 0)
{
......@@ -347,13 +358,18 @@ void print_params(struct params_s params)
if (enabled_params[BIND_MEMORY_COMP])
{
if (params.memory_comp_numa_node_str == NULL)
if (params.memory_comp_numa_nodes_nb == 0)
{
printf("# Will not bind memory used for computations\n");
}
else
{
printf("# Will bind memory used for computations to NUMA node(s) %s\n", params.memory_comp_numa_node_str);
printf("# Will bind memory used for computations to NUMA node%s: ", (params.memory_comp_numa_nodes_nb == 1) ? "" : "s");
for (unsigned i = 0; i < params.memory_comp_numa_nodes_nb; i++)
{
printf("%u ", params.memory_comp_numa_nodes[i]);
}
printf("\n");
}
}
......
......@@ -6,6 +6,8 @@
#define DO_COMP_ALONE (1 << 0)
#define DO_COMM_ALONE (1 << 1)
#define MAX_NUMA_NODES 16
enum param_e {
DISABLE_COMM,
PING_THREAD,
......@@ -43,7 +45,8 @@ struct params_s {
int display_binding;
int pingpong_size;
int display_help;
char* memory_comp_numa_node_str;
int memory_comp_numa_nodes[MAX_NUMA_NODES];
unsigned memory_comp_numa_nodes_nb;
int memory_comm_numa_node;
int one_computing_rank;
int per_thread_perf;
......
......@@ -99,7 +99,7 @@ struct computing_functions memset_get_functions();
#include <starpu.h>
#include <starpu_mpi.h>
#define init_malloc(_a, _b, _c)
#define init_malloc(_a, _b, _c, _d)
#define release_malloc()
#define get_worker_count starpu_worker_get_count
#define timing_now(var) var = starpu_timing_now()
......
......@@ -8,27 +8,25 @@ static hwloc_topology_t topology;
static int memory_comm_numa_node;
/* Array describing on which NUMA nodes memory for computations can be allocated: */
static int* numa_nodes_comp = NULL;
static int* numa_nodes_comp;
/* Number of NUMA nodes on which memory for computations can be allocated: */
static int nb_numa_nodes_comp = 0;
static unsigned nb_numa_nodes_comp = 0;
void init_malloc(struct machine_s* machine, char* _memory_comp_numa_node_str, int _memory_comm_numa_node)
void init_malloc(struct machine_s* machine, int* _numa_nodes_comp, unsigned _nb_numa_nodes_comp, int _memory_comm_numa_node)
{
topology = machine->topology;
memory_comm_numa_node = _memory_comm_numa_node;
numa_nodes_comp = _numa_nodes_comp;
nb_numa_nodes_comp = _nb_numa_nodes_comp;
numa_nodes_comp = malloc(machine->nb_numa * sizeof(int));
const char delim[] = "-,";
char* sub = strtok(_memory_comp_numa_node_str, delim);
for (; sub != NULL; sub = strtok(NULL, delim))
// Just check the given ids are valid:
for (unsigned i = 0; i < nb_numa_nodes_comp; i++)
{
if (nb_numa_nodes_comp >= machine->nb_numa)
if (numa_nodes_comp[i] >= machine->nb_numa)
{
fprintf(stderr, "There is no such number of NUMA nodes (%d) !\n", machine->nb_numa);
fprintf(stderr, "This logical id of a NUMA node (%d) is superior to the number of NUMA nodes (%d)!\n", numa_nodes_comp[i], machine->nb_numa);
abort();
}
numa_nodes_comp[nb_numa_nodes_comp++] = atoi(sub);
}
}
......
......@@ -5,7 +5,7 @@
#include "helper.h"
struct machine_s;
void init_malloc(struct machine_s* machine, char* _memory_comp_numa_node_str, int _memory_comm_numa_node);
void init_malloc(struct machine_s* machine, int* _numa_nodes_comp, unsigned _nb_numa_nodes_comp, int _memory_comm_numa_node);
void release_malloc();
void* comm_malloc(size_t size);
void* comp_malloc(size_t size);
......
......@@ -125,7 +125,7 @@ static int memset_init()
#pragma omp parallel for
for (int i = 0; i < nb_threads; i++)
{
a[i] = data_malloc(array_size*sizeof(MEMSET_TYPE), get_numa_node_comp_for_id(i % machine.nb_numa));
a[i] = data_malloc(array_size*sizeof(MEMSET_TYPE), get_numa_node_comp_for_id(i % params.memory_comp_numa_nodes_nb));
for (int j = 0; j < array_size; j++)
{
......
......@@ -130,7 +130,7 @@ int main(int argc, char* argv[])
#endif
fill_machine(&machine);
init_malloc(&machine, params.memory_comp_numa_node_str, params.memory_comm_numa_node);
init_malloc(&machine, params.memory_comp_numa_nodes, params.memory_comp_numa_nodes_nb, params.memory_comm_numa_node);
if (params.display_help)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment