From 8fdf2836fd3b1e5c21d31fa5da131c8ca02455b9 Mon Sep 17 00:00:00 2001 From: lykos98 <francy273998@gmail.com> Date: Thu, 30 Jan 2025 17:48:53 +0100 Subject: [PATCH] added implementation of private locks for centers pruning --- src/adp/adp.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/adp/adp.c b/src/adp/adp.c index 962aaba..b6b7e38 100644 --- a/src/adp/adp.c +++ b/src/adp/adp.c @@ -737,12 +737,12 @@ clusters_t Heuristic1(global_context_t *ctx) MPI_Win_create(to_remove_mask, n * sizeof(heap_node), 1, MPI_INFO_NULL, ctx -> mpi_communicator, &win_to_remove_mask); MPI_Win_fence(0, win_to_remove_mask); - //MPI_Win win_locks; - //MPI_Win_create(lock_array, n * sizeof(lock_t), sizeof(lock_t), MPI_INFO_NULL, ctx -> mpi_communicator, &win_locks); - //MPI_Win_fence(0, win_locks); + MPI_Win win_locks; + MPI_Win_create(lock_array, n * sizeof(lock_t), sizeof(lock_t), MPI_INFO_NULL, ctx -> mpi_communicator, &win_locks); + MPI_Win_fence(0, win_locks); - //MPI_Win_lock_all(MPI_LOCK_SHARED, win_to_remove_mask); - //MPI_Win_lock_all(MPI_LOCK_SHARED, win_locks); + MPI_Win_lock_all(0, win_to_remove_mask); + MPI_Win_lock_all(0, win_locks); @@ -768,7 +768,6 @@ clusters_t Heuristic1(global_context_t *ctx) * use an array of locks, and compare and swap to actually gain control of the thing * * */ - /* #pragma omp critical { @@ -777,7 +776,7 @@ clusters_t Heuristic1(global_context_t *ctx) lock_t state = LOCK_FREE; - //state = h1_lock_acquire(ctx, win_locks, owner, jpos, state); + state = h1_lock_acquire(ctx, win_locks, owner, jpos, state); heap_node mask_element; MPI_Request request; @@ -797,10 +796,10 @@ clusters_t Heuristic1(global_context_t *ctx) } - //state = h1_lock_free(ctx, win_locks, owner, jpos, state); + state = h1_lock_free(ctx, win_locks, owner, jpos, state); } - */ + /* #pragma omp critical (h1_centers_elimination) { int owner = foreign_owner(ctx, jidx); @@ -826,12 +825,16 @@ clusters_t Heuristic1(global_context_t *ctx) MPI_Win_unlock(owner, win_to_remove_mask); } + */ } } } + + MPI_Win_unlock_all(win_to_remove_mask); + MPI_Win_unlock_all(win_locks); MPI_Win_fence(0, win_to_remove_mask); - //MPI_Win_fence(0, win_locks); + MPI_Win_fence(0, win_locks); MPI_Barrier(ctx -> mpi_communicator); /* populate the usual arrays */ @@ -881,7 +884,7 @@ clusters_t Heuristic1(global_context_t *ctx) MPI_Win_free(&win_to_remove_mask); free(to_remove_mask); - //MPI_Win_free(&win_locks); + MPI_Win_free(&win_locks); free(lock_array); int n_centers = (int)actual_centers.count; -- GitLab