Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 99b72f52 authored by Jens Gustedt's avatar Jens Gustedt
Browse files

avoid the use of a mutex

parent 3690826f
Branches master_com
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ ORWL_DECLARE_ENV(ORWL_AFFINITY_BINDING);
**/
typedef struct o_rwl_dependency o_rwl_dependency;
struct o_rwl_dependency {
size_t nb; /*!< number of neigboors */
_Atomic(size_t) nb; /*!< number of neigboors */
size_t loc_ids[O_RWL_MAX_DEPENDENCY]; /*!< location id of neigboors */
};
......
......@@ -32,11 +32,6 @@ static o_rwl_dependency(*communications)[] = 0;
**/
static double* locations = 0;
/**
** @brief mutex to manage concurent writes on communications
**/
static mtx_t communications_lock;
/**
** @brief mutex to manage concurent writes on o_rw_locations
**/
......@@ -79,11 +74,6 @@ static int dependency_init(void) {
P99_THROW_ASSERT(EINVAL, op_nb);
communications = P99_CALLOC(o_rwl_dependency, op_nb * op_nb);
if (mtx_init(&communications_lock, mtx_plain)) {
report(1, "smutex communications init failed");
return 1;
}
if (loc_total) {
locations = P99_CALLOC(double, loc_total);
}
......@@ -120,7 +110,6 @@ static void dependency_print(void) {
static int dependency_destroy(void) {
mtx_destroy(&locations_lock);
mtx_destroy(&communications_lock);
free(communications);
free(locations);
return 0;
......@@ -188,7 +177,7 @@ static int build_affinity(tm_affinity_mat_t** aff_mat) {
for (size_t j = 0; j < op_nb; j++) {
if (com_mat[i][j].nb) {
for (size_t s = 0; s < com_mat[i][j].nb; s++) {
/// NOTE: put 1 if there is dependency but location_size is 0 ///
// add 1 if there is a dependency, even if location_size is 0
double increment = locations[com_mat[i][j].loc_ids[s]];
mat[i][j] += increment ? increment : 1;
}
......@@ -364,10 +353,8 @@ int orwl_dependency_set(size_t loc_src, size_t loc_dst, size_t location_id) {
size_t src = ((loc_src - loc_offs) / loc_task) * op_task;
size_t dst = ((loc_dst - loc_offs) / loc_task) * op_task;
if (src < op_nb && dst < op_nb) {
P99_MUTUAL_EXCLUDE(communications_lock) {
com_mat[src][dst].loc_ids[com_mat[src][dst].nb] = location_id;
com_mat[src][dst].nb += 1;
}
size_t nb = atomic_fetch_add(&com_mat[src][dst].nb, 1);
com_mat[src][dst].loc_ids[nb] = location_id;
}
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment