Commit 8fdf2836 authored by lykos98's avatar lykos98
Browse files

added implementation of private locks for centers pruning

parent 496f23f8
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -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;