Commit 496f23f8 authored by lykos98's avatar lykos98
Browse files

added proto implementation of single locks on centers elimination

parent be12bbfb
Loading
Loading
Loading
Loading
+32 −24
Original line number Diff line number Diff line
@@ -737,9 +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);



@@ -765,15 +768,20 @@ 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
                {

                    int owner = foreign_owner(ctx, jidx);
                    idx_t jpos = jidx - ctx -> rank_idx_start[owner];

                    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;

                    MPI_Rget(&mask_element, sizeof(heap_node), MPI_BYTE, 
                            owner, jpos * sizeof(heap_node), sizeof(heap_node), MPI_BYTE, win_to_remove_mask, &request);
                    MPI_Wait(&request, MPI_STATUS_IGNORE);
@@ -789,9 +797,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);
@@ -817,13 +826,12 @@ clusters_t Heuristic1(global_context_t *ctx)

                    MPI_Win_unlock(owner, win_to_remove_mask);
                }
                */
            }
        }
    }
    
    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 */
@@ -873,7 +881,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;