Commit aa8a7afb authored by James Dinan's avatar James Dinan
Browse files

[svn-r10143] Implementation of dynamic windows.

This commit adds an implementation of MPI-3 dynamic windows.  This
implementation exposes all of memory in the window, rendering attach and detach
as no-ops.  Currently, no error checking is done to determine if RMA ops target
valid/exposed locations at the target.  This would be a nice addition (and can
be done at the target in the two-sided ch3 implementation), but it would incur
a O(log(attached_segments)) performance cost.

Reviewer: buntinas
parent 3530af43
......@@ -28,26 +28,6 @@
/* --END ERROR HANDLING-- */
#undef FUNCNAME
#define FUNCNAME MPIDI_Win_attach
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_attach(MPID_Win *win, void *base, MPI_Aint size)
{
MPIDI_FUNC_NOTIMPL(WIN_ATTACH)
}
#undef FUNCNAME
#define FUNCNAME MPIDI_Win_detach
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_detach(MPID_Win *win, const void *base)
{
MPIDI_FUNC_NOTIMPL(WIN_DETACH)
}
#undef FUNCNAME
#define FUNCNAME MPIDI_Fetch_and_op
#undef FCNAME
......
......@@ -151,7 +151,8 @@ int MPIDI_CH3U_Win_create_dynamic(MPID_Info *info, MPID_Comm *comm_ptr, MPID_Win
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_WIN_CREATE_DYNAMIC);
MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**notimpl");
mpi_errno = MPIDI_CH3U_Win_create_gather(MPI_BOTTOM, 0, 1, info, comm_ptr, win_ptr);
if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_WIN_CREATE_DYNAMIC);
......@@ -163,6 +164,52 @@ fn_fail:
}
#undef FUNCNAME
#define FUNCNAME MPIDI_Win_attach
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_attach(MPID_Win *win, void *base, MPI_Aint size)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_WIN_ATTACH);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_WIN_ATTACH);
/* no op, all of memory is exposed */
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_WIN_ATTACH);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
fn_fail:
goto fn_exit;
/* --END ERROR HANDLING-- */
}
#undef FUNCNAME
#define FUNCNAME MPIDI_Win_detach
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_detach(MPID_Win *win, const void *base)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_WIN_DETACH);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_WIN_DETACH);
/* no op, all of memory is exposed */
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_WIN_DETACH);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
fn_fail:
goto fn_exit;
/* --END ERROR HANDLING-- */
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3U_Win_allocate_shared
#undef FCNAME
......
......@@ -128,10 +128,15 @@ int MPID_Win_create_dynamic(MPID_Info *info, MPID_Comm *comm_ptr,
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPID_WIN_CREATE_DYNAMIC);
mpi_errno = win_init(0 /* size */, 1 /* disp_unit */, MPIX_WIN_FLAVOR_DYNAMIC,
MPIX_WIN_SEPARATE, info, comm_ptr, win_ptr);
mpi_errno = win_init(0 /* spec defines size to be 0 */,
1 /* spec defines disp_unit to be 1 */,
MPIX_WIN_FLAVOR_DYNAMIC, MPIX_WIN_SEPARATE, info,
comm_ptr, win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
(*win_ptr)->base = MPI_BOTTOM;
mpi_errno = MPIDI_CH3U_Win_fns.create_dynamic(info, comm_ptr, win_ptr);
if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
......
......@@ -79,6 +79,7 @@ noinst_PROGRAMS = \
win_shared \
win_shared_noncontig \
win_shared_noncontig_put \
win_dynamic_acc \
get_acc_local
strided_acc_indexed_LDADD = $(LDADD) -lm
......
......@@ -64,4 +64,5 @@ manyrma2 2 timeLimit=800
win_shared 4 strict=false
win_shared_noncontig 4 strict=false
win_shared_noncontig_put 4 strict=false
win_dynamic_acc 4 strict=false
get_acc_local 1 strict=false
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
*
* (C) 2012 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <mpi.h>
#include "mpitest.h"
/* MPI-3 is not yet standardized -- allow MPI-3 routines to be switched off.
*/
#if !defined(USE_STRICT_MPI) && defined(MPICH2)
# define TEST_MPI3_ROUTINES 1
#endif
#define ITER 100
const int verbose = 0;
int main(int argc, char **argv) {
int i, j, rank, nproc;
int errors = 0, all_errors = 0;
int val = 0, one = 1;
MPI_Aint *val_ptrs;
MPI_Win dyn_win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
val_ptrs = malloc(nproc * sizeof(MPI_Aint));
MPI_Get_address(&val, &val_ptrs[rank]);
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, val_ptrs, 1, MPI_AINT,
MPI_COMM_WORLD);
#ifdef TEST_MPI3_ROUTINES
MPIX_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &dyn_win);
MPIX_Win_attach(dyn_win, &one, sizeof(int));
for (i = 0; i < ITER; i++) {
MPI_Win_fence(MPI_MODE_NOPRECEDE, dyn_win);
MPI_Accumulate(&one, 1, MPI_INT, i%nproc, val_ptrs[i%nproc], 1, MPI_INT, MPI_SUM, dyn_win);
MPI_Win_fence(MPI_MODE_NOSUCCEED, dyn_win);
}
MPI_Barrier(MPI_COMM_WORLD);
/* Read and verify my data */
if ( val != ITER ) {
errors++;
printf("%d -- Got %d, expected %d\n", rank, val, ITER);
}
MPIX_Win_detach(dyn_win, &one);
MPI_Win_free(&dyn_win);
#endif /* TEST_MPI3_ROUTINES */
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0 && all_errors == 0)
printf(" No Errors\n");
free(val_ptrs);
MPI_Finalize();
return 0;
}
......@@ -94,6 +94,32 @@ int main( int argc, char *argv[] )
MPI_Win_free(&window);
/** Create using MPI_Win_create_dynamic() **/
MPIX_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &window);
MPI_Win_get_attr(window, MPIX_WIN_CREATE_FLAVOR, &flavor, &flag);
if (!flag) {
printf("%d: MPI_Win_create_dynamic - Error, no flavor\n", rank);
errors++;
} else if (*flavor != MPIX_WIN_FLAVOR_DYNAMIC) {
printf("%d: MPI_Win_create_dynamic - Error, bad flavor (%d)\n", rank, *flavor);
errors++;
}
MPI_Win_get_attr(window, MPIX_WIN_MODEL, &model, &flag);
if (!flag) {
printf("%d: MPI_Win_create_dynamic - Error, no model\n", rank);
errors++;
} else if (*model != MPIX_WIN_SEPARATE && *model != MPIX_WIN_UNIFIED) {
printf("%d: MPI_Win_create_dynamic - Error, bad model (%d)\n", rank, *model);
errors++;
}
MPI_Win_free(&window);
#endif /* TEST_MPI3_ROUTINES */
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
......
Markdown is supported
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