mpid_win_create_dynamic.c 3.16 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* begin_generated_IBM_copyright_prolog                             */
/*                                                                  */
/* This is an automatically generated copyright prolog.             */
/* After initializing,  DO NOT MODIFY OR MOVE                       */
/*  --------------------------------------------------------------- */
/* Licensed Materials - Property of IBM                             */
/* Blue Gene/Q 5765-PER 5765-PRP                                    */
/*                                                                  */
/* (C) Copyright IBM Corp. 2011, 2012 All Rights Reserved           */
/* US Government Users Restricted Rights -                          */
/* Use, duplication, or disclosure restricted                       */
/* by GSA ADP Schedule Contract with IBM Corp.                      */
/*                                                                  */
/*  --------------------------------------------------------------- */
/*                                                                  */
/* end_generated_IBM_copyright_prolog                               */
/*  (C)Copyright IBM Corp.  2007, 2011  */
/**
 * \file src/onesided/mpid_win_create.c
 * \brief ???
 */
#include "mpidi_onesided.h"

/**
 * \brief MPI-PAMI glue for MPI_Win_create_dynamic function
 *
 * Create a window object. Allocates a MPID_Win object and initializes it,
 * then allocates the collective info array, initalizes our entry, and
 * performs an Allgather to distribute/collect the rest of the array entries.
 * The function returns a window win without memory attached.
 *
 * Input Parameters:
 * \param[in] info      info argument
 * \param[in] comm      intra-Communicator (handle)
 * \param[out] win_ptr  window object returned by the call (handle)
 * \return MPI_SUCCESS, MPI_ERR_ARG, MPI_ERR_COMM, MPI_ERR_INFO. MPI_ERR_OTHER,
 *         MPI_ERR_SIZE
 */

int
MPID_Win_create_dynamic( MPID_Info  * info,
                  MPID_Comm  * comm_ptr,
                  MPID_Win  ** win_ptr)
{
  int mpi_errno  = MPI_SUCCESS;
  int rc = MPI_SUCCESS;
  static char FCNAME[] = "MPID_Win_allocate_dynamic";
  MPIDI_Win_info  *winfo;
  MPID_Win     *win;
  int          rank,i;  

52
  rc=MPIDI_Win_init(0,1,win_ptr, info, comm_ptr, MPI_WIN_FLAVOR_DYNAMIC, MPI_WIN_UNIFIED);
53
54
55
  win = *win_ptr;

  rank = comm_ptr->rank;
56
  win->base = MPI_BOTTOM;
57
58
59
  winfo = &win->mpid.info[rank];
  winfo->win = win;

60
61
62
63
#ifdef __BGQ__
  void *base = NULL;
  size_t length = 0;
  Kernel_MemoryRegion_t memregion;
64
  void *tmpbuf = MPIU_Malloc(sizeof(int));
65
66
67
68
  Kernel_CreateMemoryRegion(&memregion, tmpbuf, sizeof(int));
  //Reset base to base VA of local heap
  base = memregion.BaseVa;
  length = memregion.Bytes;
69
  MPIU_Free(tmpbuf);
70
71
72
73
74
75
76
77
78
79
80
81
82
  
  if (length != 0)
    {
      size_t length_out = 0;
      pami_result_t rc;
      rc = PAMI_Memregion_create(MPIDI_Context[0], base, length, &length_out, &winfo->memregion);
      MPID_assert(rc == PAMI_SUCCESS);
      MPID_assert(length == length_out);
    }
  win->base = base;
  winfo->base_addr = base;  
#endif

Su Huang's avatar
Su Huang committed
83
  rc= MPIDI_Win_allgather(0,win_ptr);
84
85
86
87
88
89
90
  if (rc != MPI_SUCCESS)
      return rc;

  mpi_errno = MPIR_Barrier_impl(comm_ptr, &mpi_errno);

  return mpi_errno;
}