コード例 #1
0
ファイル: igatherv_f.c プロジェクト: XuanWang1982/ompi
void ompi_igatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype,
                     char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs,
                     MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm,
                     MPI_Fint *request, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype c_sendtype, c_recvtype;
    MPI_Request c_request;
    int size, c_ierr;
    OMPI_ARRAY_NAME_DECL(recvcounts);
    OMPI_ARRAY_NAME_DECL(displs);

    c_comm = MPI_Comm_f2c(*comm);
    c_sendtype = MPI_Type_f2c(*sendtype);
    c_recvtype = MPI_Type_f2c(*recvtype);

    MPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(recvcounts, size);
    OMPI_ARRAY_FINT_2_INT(displs, size);

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

    c_ierr = MPI_Igatherv(sendbuf, OMPI_FINT_2_INT(*sendcount),
                         c_sendtype, recvbuf,
                         OMPI_ARRAY_NAME_CONVERT(recvcounts),
                         OMPI_ARRAY_NAME_CONVERT(displs),
                         c_recvtype,
                         OMPI_FINT_2_INT(*root),
                          c_comm, &c_request);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
    if (MPI_SUCCESS == c_ierr) *request = MPI_Request_c2f(c_request);
}
コード例 #2
0
ファイル: graph_map_f.c プロジェクト: XuanWang1982/ompi
void ompi_graph_map_f(MPI_Fint *comm, MPI_Fint *nnodes, MPI_Fint *indx,
		     MPI_Fint *edges, MPI_Fint *nrank, MPI_Fint *ierr)
{
    int c_ierr;
    MPI_Comm c_comm;
    OMPI_ARRAY_NAME_DECL(indx);
    OMPI_ARRAY_NAME_DECL(edges);
    OMPI_SINGLE_NAME_DECL(nrank);

    c_comm = MPI_Comm_f2c(*comm);

    /* Number of edges is equal to the last entry in the index array */
    OMPI_ARRAY_FINT_2_INT(edges, indx[*nnodes - 1]);
    OMPI_ARRAY_FINT_2_INT(indx, *nnodes);

    c_ierr = MPI_Graph_map(c_comm, OMPI_FINT_2_INT(*nnodes),
                           OMPI_ARRAY_NAME_CONVERT(indx),
                           OMPI_ARRAY_NAME_CONVERT(edges),
                           OMPI_SINGLE_NAME_CONVERT(nrank));
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    if (MPI_SUCCESS == c_ierr) {
        OMPI_SINGLE_INT_2_FINT(nrank);
    }
    OMPI_ARRAY_FINT_2_INT_CLEANUP(edges);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(indx);
}
コード例 #3
0
ファイル: allgatherv_f.c プロジェクト: XuanWang1982/ompi
void ompi_allgatherv_f(char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype,
		      char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs,
		      MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype c_sendtype, c_recvtype;
    int size, ierr_c;
    OMPI_ARRAY_NAME_DECL(recvcounts);
    OMPI_ARRAY_NAME_DECL(displs);

    c_comm = MPI_Comm_f2c(*comm);
    c_sendtype = MPI_Type_f2c(*sendtype);
    c_recvtype = MPI_Type_f2c(*recvtype);

    MPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(recvcounts, size);
    OMPI_ARRAY_FINT_2_INT(displs, size);

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

    ierr_c = MPI_Allgatherv(sendbuf,
                            OMPI_FINT_2_INT(*sendcount),
                            c_sendtype,
                            recvbuf,
                            OMPI_ARRAY_NAME_CONVERT(recvcounts),
                            OMPI_ARRAY_NAME_CONVERT(displs),
                            c_recvtype, c_comm);

    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(ierr_c);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(displs);
}
コード例 #4
0
ファイル: graph_create_f.c プロジェクト: XuanWang1982/ompi
void ompi_graph_create_f(MPI_Fint *comm_old, MPI_Fint *nnodes,
                        MPI_Fint *indx, MPI_Fint *edges,
                        ompi_fortran_logical_t *reorder, MPI_Fint *comm_graph,
                        MPI_Fint *ierr)
{
    int c_ierr;
    MPI_Comm c_comm_old, c_comm_graph;
    OMPI_ARRAY_NAME_DECL(indx);
    OMPI_ARRAY_NAME_DECL(edges);

    c_comm_old = MPI_Comm_f2c(*comm_old);

    OMPI_ARRAY_FINT_2_INT(indx, *nnodes);

    /* Number of edges is equal to the last entry in the index array */
    OMPI_ARRAY_FINT_2_INT(edges, indx[*nnodes - 1]);

    c_ierr = MPI_Graph_create(c_comm_old,
                              OMPI_FINT_2_INT(*nnodes),
                              OMPI_ARRAY_NAME_CONVERT(indx),
                              OMPI_ARRAY_NAME_CONVERT(edges),
                              OMPI_LOGICAL_2_INT(*reorder),
                              &c_comm_graph);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    if (OMPI_SUCCESS == c_ierr) {
        *comm_graph = MPI_Comm_c2f(c_comm_graph);
    }

    OMPI_ARRAY_FINT_2_INT_CLEANUP(indx);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(edges);
}
コード例 #5
0
void mpi_scatterv_f(char *sendbuf, MPI_Fint *sendcounts,
		    MPI_Fint *displs, MPI_Fint *sendtype,
		    char *recvbuf, MPI_Fint *recvcount, 
		    MPI_Fint *recvtype, MPI_Fint *root,
		    MPI_Fint *comm, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype c_sendtype, c_recvtype;
    int size;
    OMPI_ARRAY_NAME_DECL(sendcounts);
    OMPI_ARRAY_NAME_DECL(displs);

    c_comm = MPI_Comm_f2c(*comm);
    c_sendtype = MPI_Type_f2c(*sendtype);
    c_recvtype = MPI_Type_f2c(*recvtype);

    MPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(sendcounts, size);
    OMPI_ARRAY_FINT_2_INT(displs, size);

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

    *ierr = OMPI_INT_2_FINT(MPI_Scatterv(sendbuf, 
					 OMPI_ARRAY_NAME_CONVERT(sendcounts),
					 OMPI_ARRAY_NAME_CONVERT(displs),
					 c_sendtype, recvbuf,
					 OMPI_FINT_2_INT(*recvcount),
					 c_recvtype, 
					 OMPI_FINT_2_INT(*root), c_comm));

    OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(displs);
}
コード例 #6
0
void ompi_type_create_subarray_f(MPI_Fint *ndims, MPI_Fint *size_array,
				MPI_Fint *subsize_array,
				MPI_Fint *start_array, MPI_Fint *order,
				MPI_Fint *oldtype, MPI_Fint *newtype,
				MPI_Fint *ierr)
{
    int c_ierr;
    MPI_Datatype c_old;
    MPI_Datatype c_new;
    OMPI_ARRAY_NAME_DECL(size_array);
    OMPI_ARRAY_NAME_DECL(subsize_array);
    OMPI_ARRAY_NAME_DECL(start_array);

    c_old = PMPI_Type_f2c(*oldtype);

    OMPI_ARRAY_FINT_2_INT(size_array, *ndims);
    OMPI_ARRAY_FINT_2_INT(subsize_array, *ndims);
    OMPI_ARRAY_FINT_2_INT(start_array, *ndims);

    c_ierr = PMPI_Type_create_subarray(OMPI_FINT_2_INT(*ndims),
                                      OMPI_ARRAY_NAME_CONVERT(size_array),
                                      OMPI_ARRAY_NAME_CONVERT(subsize_array),
                                      OMPI_ARRAY_NAME_CONVERT(start_array),
                                      *order, c_old, &c_new);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    if (MPI_SUCCESS == c_ierr) {
        *newtype = PMPI_Type_c2f(c_new);
    }

    OMPI_ARRAY_FINT_2_INT_CLEANUP(size_array);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(subsize_array);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(start_array);
}
コード例 #7
0
void ompi_type_indexed_f(MPI_Fint *count, MPI_Fint *array_of_blocklengths,
			MPI_Fint *array_of_displacements, MPI_Fint *oldtype,
			MPI_Fint *newtype, MPI_Fint *ierr)
{
    int c_ierr;
    MPI_Datatype c_old = MPI_Type_f2c(*oldtype);
    MPI_Datatype c_new;
    OMPI_ARRAY_NAME_DECL(array_of_blocklengths);
    OMPI_ARRAY_NAME_DECL(array_of_displacements);

    OMPI_ARRAY_FINT_2_INT(array_of_blocklengths, *count);
    OMPI_ARRAY_FINT_2_INT(array_of_displacements, *count);

    c_ierr = MPI_Type_indexed(OMPI_FINT_2_INT(*count),
                              OMPI_ARRAY_NAME_CONVERT(array_of_blocklengths), 
                              OMPI_ARRAY_NAME_CONVERT(array_of_displacements),
                              c_old, &c_new);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_blocklengths);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_displacements);

    if (MPI_SUCCESS == c_ierr) {
        *newtype = MPI_Type_c2f(c_new);
    }
}
コード例 #8
0
ファイル: alltoallw_f.c プロジェクト: 00datman/ompi
void ompi_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
		     MPI_Fint *sdispls, MPI_Fint *sendtypes,
		     char *recvbuf, MPI_Fint *recvcounts,
		     MPI_Fint *rdispls, MPI_Fint *recvtypes,
		     MPI_Fint *comm, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype *c_sendtypes, *c_recvtypes;
    int size, c_ierr;
    OMPI_ARRAY_NAME_DECL(sendcounts);
    OMPI_ARRAY_NAME_DECL(sdispls);
    OMPI_ARRAY_NAME_DECL(recvcounts);
    OMPI_ARRAY_NAME_DECL(rdispls);

    c_comm = PMPI_Comm_f2c(*comm);
    PMPI_Comm_size(c_comm, &size);

    c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
    c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));

    OMPI_ARRAY_FINT_2_INT(sendcounts, size);
    OMPI_ARRAY_FINT_2_INT(sdispls, size);
    OMPI_ARRAY_FINT_2_INT(recvcounts, size);
    OMPI_ARRAY_FINT_2_INT(rdispls, size);

    while (size > 0) {
        c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]);
        c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]);
        --size;
    }

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

    c_ierr = PMPI_Alltoallw(sendbuf,
                           OMPI_ARRAY_NAME_CONVERT(sendcounts),
                           OMPI_ARRAY_NAME_CONVERT(sdispls),
                           c_sendtypes,
                           recvbuf,
                           OMPI_ARRAY_NAME_CONVERT(recvcounts),
                           OMPI_ARRAY_NAME_CONVERT(rdispls),
                           c_recvtypes, c_comm);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls);
    free(c_sendtypes);
    free(c_recvtypes);
}
コード例 #9
0
void ompi_ireduce_scatter_f(char *sendbuf, char *recvbuf, 
                            MPI_Fint *recvcounts, MPI_Fint *datatype,
                            MPI_Fint *op, MPI_Fint *comm, MPI_Fint *request, 
                            MPI_Fint *ierr)
{
    int c_ierr;
    MPI_Comm c_comm;
    MPI_Datatype c_type;
    MPI_Request c_request;
    MPI_Op c_op;
    int size;
    OMPI_ARRAY_NAME_DECL(recvcounts);

    c_comm = MPI_Comm_f2c(*comm);
    c_type = MPI_Type_f2c(*datatype);
    c_op = MPI_Op_f2c(*op);

    MPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(recvcounts, size);

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
    
    c_ierr = MPI_Ireduce_scatter(sendbuf, recvbuf,
                                 OMPI_ARRAY_NAME_CONVERT(recvcounts),
                                 c_type, c_op, c_comm, &c_request);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
    if (MPI_SUCCESS == c_ierr) *request = MPI_Request_c2f(c_request);
}
コード例 #10
0
void ompi_group_translate_ranks_f(MPI_Fint *group1, MPI_Fint *n,
				  MPI_Fint *ranks1, MPI_Fint *group2,
				  MPI_Fint *ranks2, MPI_Fint *ierr)
{
  int c_ierr;
  ompi_group_t *c_group1, *c_group2;
  OMPI_ARRAY_NAME_DECL(ranks1);
  OMPI_ARRAY_NAME_DECL(ranks2);

  /* Make the fortran to c representation conversion */
  c_group1 = MPI_Group_f2c(*group1);
  c_group2 = MPI_Group_f2c(*group2);

  OMPI_ARRAY_FINT_2_INT(ranks1, *n);
  OMPI_ARRAY_FINT_2_INT_ALLOC(ranks2, *n);

  c_ierr = MPI_Group_translate_ranks(c_group1,
                                     OMPI_FINT_2_INT(*n),
                                     OMPI_ARRAY_NAME_CONVERT(ranks1),
                                     c_group2,
                                     OMPI_ARRAY_NAME_CONVERT(ranks2)
                                     );
  if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

  if (MPI_SUCCESS == c_ierr) {
      OMPI_ARRAY_INT_2_FINT(ranks2, *n);
  } else {
      OMPI_ARRAY_FINT_2_INT_CLEANUP(ranks2);
  }
  OMPI_ARRAY_FINT_2_INT_CLEANUP(ranks1);
}
コード例 #11
0
ファイル: cart_map_f.c プロジェクト: aosm/openmpi
void mpi_cart_map_f(MPI_Fint *comm, MPI_Fint *ndims, MPI_Fint *dims,
                    MPI_Flogical *periods, MPI_Fint *newrank, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    int size;
    OMPI_ARRAY_NAME_DECL(dims);
    OMPI_LOGICAL_ARRAY_NAME_DECL(periods);
    OMPI_SINGLE_NAME_DECL(newrank);

    c_comm = MPI_Comm_f2c(*comm);

    size = OMPI_FINT_2_INT(*ndims);
    OMPI_ARRAY_FINT_2_INT(dims, size);
    OMPI_ARRAY_LOGICAL_2_INT(periods, size);

    *ierr = OMPI_INT_2_FINT(MPI_Cart_map(c_comm, 
                                         OMPI_FINT_2_INT(*ndims),
                                         OMPI_ARRAY_NAME_CONVERT(dims),
                                         OMPI_LOGICAL_ARRAY_NAME_CONVERT(periods),
                                         OMPI_SINGLE_NAME_CONVERT(newrank)));

    OMPI_ARRAY_FINT_2_INT_CLEANUP(dims);
    OMPI_ARRAY_INT_2_LOGICAL(periods, size);
    OMPI_ARRAY_LOGICAL_2_INT_CLEANUP(periods);
    OMPI_SINGLE_INT_2_FINT(newrank);
}
コード例 #12
0
void mpi_reduce_scatter_f(char *sendbuf, char *recvbuf, 
			  MPI_Fint *recvcounts, MPI_Fint *datatype,
			  MPI_Fint *op, MPI_Fint *comm, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype c_type;
    MPI_Op c_op;
    int size;
    OMPI_ARRAY_NAME_DECL(recvcounts);

    c_comm = MPI_Comm_f2c(*comm);
    c_type = MPI_Type_f2c(*datatype);
    c_op = MPI_Op_f2c(*op);

    MPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(recvcounts, size);

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
    
    *ierr = OMPI_INT_2_FINT(MPI_Reduce_scatter(sendbuf, recvbuf,
				       OMPI_ARRAY_NAME_CONVERT(recvcounts),
				       c_type, c_op, c_comm));
}
コード例 #13
0
void ompi_cart_create_f(MPI_Fint *old_comm, MPI_Fint *ndims, MPI_Fint *dims,
                       ompi_fortran_logical_t *periods, ompi_fortran_logical_t *reorder,
                       MPI_Fint *comm_cart, MPI_Fint *ierr)
{
    MPI_Comm c_comm1, c_comm2;
    int size, c_ierr;
    OMPI_ARRAY_NAME_DECL(dims);
    OMPI_LOGICAL_ARRAY_NAME_DECL(periods);

    c_comm1 = MPI_Comm_f2c(*old_comm);

    size = OMPI_FINT_2_INT(*ndims);
    OMPI_ARRAY_FINT_2_INT(dims, size);
    OMPI_ARRAY_LOGICAL_2_INT(periods, size);

    c_ierr = MPI_Cart_create(c_comm1, OMPI_FINT_2_INT(*ndims),
                             OMPI_ARRAY_NAME_CONVERT(dims),
                             OMPI_LOGICAL_ARRAY_NAME_CONVERT(periods),
                             OMPI_LOGICAL_2_INT(*reorder),
                             &c_comm2);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    if (MPI_SUCCESS == c_ierr) {
        *comm_cart = MPI_Comm_c2f(c_comm2);
    }

    /*
     * Need to convert back into Fortran, to not surprise the user
     */
    OMPI_ARRAY_FINT_2_INT_CLEANUP(dims);
    OMPI_ARRAY_INT_2_LOGICAL(periods, size);
}
コード例 #14
0
ファイル: ineighbor_alltoallv_f.c プロジェクト: 00datman/ompi
void ompi_ineighbor_alltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls,
                                MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts,
                                MPI_Fint *rdispls, MPI_Fint *recvtype,
                                MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype c_sendtype, c_recvtype;
    MPI_Request c_request;
    int size, c_ierr;
    OMPI_ARRAY_NAME_DECL(sendcounts);
    OMPI_ARRAY_NAME_DECL(sdispls);
    OMPI_ARRAY_NAME_DECL(recvcounts);
    OMPI_ARRAY_NAME_DECL(rdispls);

    c_comm = PMPI_Comm_f2c(*comm);
    c_sendtype = PMPI_Type_f2c(*sendtype);
    c_recvtype = PMPI_Type_f2c(*recvtype);

    PMPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(sendcounts, size);
    OMPI_ARRAY_FINT_2_INT(sdispls, size);
    OMPI_ARRAY_FINT_2_INT(recvcounts, size);
    OMPI_ARRAY_FINT_2_INT(rdispls, size);

    sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

    c_ierr = PMPI_Ineighbor_alltoallv(sendbuf,
                                     OMPI_ARRAY_NAME_CONVERT(sendcounts),
                                     OMPI_ARRAY_NAME_CONVERT(sdispls),
                                     c_sendtype,
                                     recvbuf,
                                     OMPI_ARRAY_NAME_CONVERT(recvcounts),
                                     OMPI_ARRAY_NAME_CONVERT(rdispls),
                                     c_recvtype, c_comm, &c_request);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
    if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls);
}
コード例 #15
0
void ompi_dist_graph_create_f(MPI_Fint *comm_old, MPI_Fint *n, MPI_Fint *sources,
                              MPI_Fint *degrees, MPI_Fint *destinations, MPI_Fint *weights,
                              MPI_Fint *info,  ompi_fortran_logical_t *reorder, MPI_Fint *comm_graph,
                              MPI_Fint *ierr)
{
    MPI_Comm c_comm_old, c_comm_graph;
    int count = 0, i;
    MPI_Info c_info;
    OMPI_ARRAY_NAME_DECL(sources);
    OMPI_ARRAY_NAME_DECL(degrees);
    OMPI_ARRAY_NAME_DECL(destinations);
    OMPI_ARRAY_NAME_DECL(weights);

    c_comm_old = MPI_Comm_f2c(*comm_old);
    c_info = MPI_Info_f2c(*info);
    OMPI_ARRAY_FINT_2_INT(sources, *n);
    OMPI_ARRAY_FINT_2_INT(degrees, *n);
    for( i = 0; i < OMPI_FINT_2_INT(*n); i++ )
        count += OMPI_ARRAY_NAME_CONVERT(degrees)[i];
    OMPI_ARRAY_FINT_2_INT(destinations, count);
    if( !OMPI_IS_FORTRAN_UNWEIGHTED(weights) ) {
        OMPI_ARRAY_FINT_2_INT(weights, count);
    }
    

    *ierr = OMPI_INT_2_FINT(MPI_Dist_graph_create(c_comm_old, OMPI_FINT_2_INT(*n), OMPI_ARRAY_NAME_CONVERT(sources),
                                                  OMPI_ARRAY_NAME_CONVERT(degrees), OMPI_ARRAY_NAME_CONVERT(destinations),
                                                  OMPI_IS_FORTRAN_UNWEIGHTED(weights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(weights),
                                                  c_info, OMPI_LOGICAL_2_INT(*reorder), &c_comm_graph));
    if (OMPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        *comm_graph = MPI_Comm_c2f(c_comm_graph);
    }

    OMPI_ARRAY_FINT_2_INT_CLEANUP(sources);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(degrees);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(destinations);
    if( !OMPI_IS_FORTRAN_UNWEIGHTED(weights) ) {
        OMPI_ARRAY_FINT_2_INT_CLEANUP(weights);
    }
}
コード例 #16
0
ファイル: scatterv_init_f.c プロジェクト: ICLDisco/ompi
void ompix_scatterv_init_f(char *sendbuf, MPI_Fint *sendcounts,
                           MPI_Fint *displs, MPI_Fint *sendtype,
                           char *recvbuf, MPI_Fint *recvcount,
                           MPI_Fint *recvtype, MPI_Fint *root,
                           MPI_Fint *comm, MPI_Fint *info, MPI_Fint *request, MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    MPI_Datatype c_sendtype, c_recvtype;
    MPI_Info c_info;
    MPI_Request c_request;
    int size, c_ierr;
    OMPI_ARRAY_NAME_DECL(sendcounts);
    OMPI_ARRAY_NAME_DECL(displs);

    c_comm = PMPI_Comm_f2c(*comm);
    c_sendtype = PMPI_Type_f2c(*sendtype);
    c_recvtype = PMPI_Type_f2c(*recvtype);
    c_info = PMPI_Info_f2c(*info);

    PMPI_Comm_size(c_comm, &size);
    OMPI_ARRAY_FINT_2_INT(sendcounts, size);
    OMPI_ARRAY_FINT_2_INT(displs, size);

    sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
    recvbuf = (char *) OMPI_F2C_IN_PLACE(recvbuf);
    recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

    c_ierr = PMPIX_Scatterv_init(sendbuf,
                                OMPI_ARRAY_NAME_CONVERT(sendcounts),
                                OMPI_ARRAY_NAME_CONVERT(displs),
                                c_sendtype, recvbuf,
                                OMPI_FINT_2_INT(*recvcount),
                                c_recvtype,
                                OMPI_FINT_2_INT(*root), c_comm, c_info, &c_request);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
    if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(displs);
}
コード例 #17
0
void ompi_type_create_darray_f(MPI_Fint *size, MPI_Fint *rank,
			      MPI_Fint *ndims, MPI_Fint *gsize_array, 
			      MPI_Fint *distrib_array, MPI_Fint *darg_array,
			      MPI_Fint *psize_array, MPI_Fint *order, 
			      MPI_Fint *oldtype, MPI_Fint *newtype,
			      MPI_Fint *ierr)
{
    int c_ierr;
    MPI_Datatype c_old = MPI_Type_f2c(*oldtype);
    MPI_Datatype c_new;
    OMPI_ARRAY_NAME_DECL(gsize_array);
    OMPI_ARRAY_NAME_DECL(distrib_array);
    OMPI_ARRAY_NAME_DECL(darg_array);
    OMPI_ARRAY_NAME_DECL(psize_array);

    OMPI_ARRAY_FINT_2_INT(gsize_array, *ndims);
    OMPI_ARRAY_FINT_2_INT(distrib_array, *ndims);
    OMPI_ARRAY_FINT_2_INT(darg_array, *ndims);
    OMPI_ARRAY_FINT_2_INT(psize_array, *ndims);

    c_ierr = MPI_Type_create_darray(OMPI_FINT_2_INT(*size),
                                    OMPI_FINT_2_INT(*rank),
                                    OMPI_FINT_2_INT(*ndims),
                                    OMPI_ARRAY_NAME_CONVERT(gsize_array), 
                                    OMPI_ARRAY_NAME_CONVERT(distrib_array),
                                    OMPI_ARRAY_NAME_CONVERT(darg_array),
                                    OMPI_ARRAY_NAME_CONVERT(psize_array),
                                    OMPI_FINT_2_INT(*order), c_old, &c_new);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(gsize_array);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(distrib_array);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(darg_array);
    OMPI_ARRAY_FINT_2_INT_CLEANUP(psize_array);

    if (MPI_SUCCESS == c_ierr) {
      *newtype = MPI_Type_c2f(c_new);
    }
}
コード例 #18
0
ファイル: dims_create_f.c プロジェクト: bringhurst/ompi
void mpi_dims_create_f(MPI_Fint *nnodes, MPI_Fint *ndims, 
		       MPI_Fint *dims, MPI_Fint *ierr)
{
    OMPI_ARRAY_NAME_DECL(dims);

    OMPI_ARRAY_FINT_2_INT(dims, *ndims);

    *ierr = OMPI_INT_2_FINT(MPI_Dims_create(OMPI_FINT_2_INT(*nnodes),
					    OMPI_FINT_2_INT(*ndims),
					    OMPI_ARRAY_NAME_CONVERT(dims)));
    if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        OMPI_ARRAY_INT_2_FINT(dims, *ndims);
    } else {
        OMPI_ARRAY_FINT_2_INT_CLEANUP(dims);
    }
}
コード例 #19
0
ファイル: cart_rank_f.c プロジェクト: aosm/openmpi
void mpi_cart_rank_f(MPI_Fint *comm, MPI_Fint *coords, MPI_Fint *rank, 
		     MPI_Fint *ierr)
{
    MPI_Comm c_comm;
    int ndims;
    OMPI_ARRAY_NAME_DECL(coords);
    OMPI_SINGLE_NAME_DECL(rank);

    c_comm = MPI_Comm_f2c(*comm);

    MPI_Cartdim_get(c_comm, &ndims);
    OMPI_ARRAY_FINT_2_INT(coords, ndims);

    *ierr = OMPI_INT_2_FINT(MPI_Cart_rank(c_comm, 
					  OMPI_ARRAY_NAME_CONVERT(coords),
					  OMPI_SINGLE_NAME_CONVERT(rank)));
    if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        OMPI_SINGLE_INT_2_FINT(rank);
    }
}
コード例 #20
0
ファイル: type_struct_f.c プロジェクト: 00datman/ompi
void ompi_type_struct_f(MPI_Fint *count, MPI_Fint *array_of_blocklengths,
		       MPI_Fint *array_of_displacements,
		       MPI_Fint *array_of_types, MPI_Fint *newtype,
		       MPI_Fint *ierr)
{
    MPI_Aint *c_disp_array;
    MPI_Datatype *c_type_old_array;
    MPI_Datatype c_new;
    int i, c_ierr;
    OMPI_ARRAY_NAME_DECL(array_of_blocklengths);

    c_type_old_array = (MPI_Datatype *) malloc(*count * (sizeof(MPI_Datatype) +
                                        sizeof(MPI_Aint)));
    if (NULL == c_type_old_array) {
        c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
                                        FUNC_NAME);
        if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
        return;
    }
    c_disp_array = (MPI_Aint*) c_type_old_array + *count;

    for (i = 0; i < *count; i++) {
        c_disp_array[i] = (MPI_Aint) array_of_displacements[i];
        c_type_old_array[i] = PMPI_Type_f2c(array_of_types[i]);
    }

    OMPI_ARRAY_FINT_2_INT(array_of_blocklengths, *count);

    c_ierr = PMPI_Type_struct(OMPI_FINT_2_INT(*count),
                             OMPI_ARRAY_NAME_CONVERT(array_of_blocklengths),
                             c_disp_array,
                             c_type_old_array, &c_new);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_blocklengths);
    free(c_type_old_array);

    if (MPI_SUCCESS == c_ierr) {
        *newtype = PMPI_Type_c2f(c_new);
    }
}
コード例 #21
0
void mpi_type_create_hindexed_f(MPI_Fint *count,
                                MPI_Fint *array_of_blocklengths,
                                MPI_Aint *array_of_displacements,
                                MPI_Fint *oldtype, MPI_Fint *newtype,
                                MPI_Fint *ierr)
{
    MPI_Datatype c_old = MPI_Type_f2c(*oldtype);
    MPI_Datatype c_new = MPI_Type_f2c(*newtype);
    OMPI_ARRAY_NAME_DECL(array_of_blocklengths);

    OMPI_ARRAY_FINT_2_INT(array_of_blocklengths, *count);

    *ierr = OMPI_INT_2_FINT(MPI_Type_create_hindexed(OMPI_FINT_2_INT(*count),
                            OMPI_ARRAY_NAME_CONVERT(array_of_blocklengths),
                            array_of_displacements, c_old,
                            &c_new));

    if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        *newtype = MPI_Type_c2f(c_new);
    }

    OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_blocklengths);
}
コード例 #22
0
ファイル: group_excl_f.c プロジェクト: cysheen/ompi
void ompi_group_excl_f(MPI_Fint *group, MPI_Fint *n,
                       MPI_Fint *ranks, MPI_Fint *newgroup,
                       MPI_Fint *ierr)
{
    int c_ierr;
    ompi_group_t *c_group, *c_newgroup;
    OMPI_ARRAY_NAME_DECL(ranks);

    /* Make the fortran to c representation conversion */
    c_group = PMPI_Group_f2c(*group);

    OMPI_ARRAY_FINT_2_INT(ranks, *n);
    c_ierr = PMPI_Group_excl(c_group,
                             OMPI_FINT_2_INT(*n),
                             OMPI_ARRAY_NAME_CONVERT(ranks),
                             &c_newgroup);
    if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

    /* translate the results from c to fortran */
    if (MPI_SUCCESS == c_ierr) {
        *newgroup = c_newgroup->grp_f_to_c_index;
    }
}
コード例 #23
0
void ompi_dist_graph_create_adjacent_f(MPI_Fint *comm_old, MPI_Fint *indegree,
                                       MPI_Fint *sources, MPI_Fint *sourceweights,
                                       MPI_Fint *outdegree,
                                       MPI_Fint *destinations, MPI_Fint *destweights, MPI_Fint *info,
                                       ompi_fortran_logical_t *reorder, MPI_Fint *comm_graph,
                                       MPI_Fint *ierr)
{
    MPI_Info c_info;
    MPI_Comm c_comm_old, c_comm_graph;
    const int *c_destweights, *c_sourceweights;

    OMPI_ARRAY_NAME_DECL(sources);
    OMPI_ARRAY_NAME_DECL(sourceweights);
    OMPI_ARRAY_NAME_DECL(destinations);
    OMPI_ARRAY_NAME_DECL(destweights);

    c_comm_old = MPI_Comm_f2c(*comm_old);
    c_info = MPI_Info_f2c(*info);

    OMPI_ARRAY_FINT_2_INT(sources, *indegree);
    if (OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights)) {
        c_sourceweights = MPI_UNWEIGHTED;
    } else if (OMPI_IS_FORTRAN_WEIGHTS_EMPTY(sourceweights)) {
        c_sourceweights = MPI_WEIGHTS_EMPTY;
    } else {
        OMPI_ARRAY_FINT_2_INT(sourceweights, *indegree);
        c_sourceweights = OMPI_ARRAY_NAME_CONVERT(sourceweights);
    }

    OMPI_ARRAY_FINT_2_INT(destinations, *outdegree);
    if (OMPI_IS_FORTRAN_UNWEIGHTED(destweights)) {
        c_destweights = MPI_UNWEIGHTED;
    } else if (OMPI_IS_FORTRAN_WEIGHTS_EMPTY(destweights)) {
        c_destweights = MPI_WEIGHTS_EMPTY;
    } else {
        OMPI_ARRAY_FINT_2_INT(destweights, *indegree);
        c_destweights = OMPI_ARRAY_NAME_CONVERT(destweights);
    }

    *ierr = OMPI_INT_2_FINT(MPI_Dist_graph_create_adjacent(c_comm_old, OMPI_FINT_2_INT(*indegree),
                                                           OMPI_ARRAY_NAME_CONVERT(sources),
                                                           c_sourceweights,
                                                           OMPI_FINT_2_INT(*outdegree),
                                                           OMPI_ARRAY_NAME_CONVERT(destinations),
                                                           c_destweights,
                                                           c_info, 
                                                           OMPI_LOGICAL_2_INT(*reorder),
                                                           &c_comm_graph));
    if (OMPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        *comm_graph = MPI_Comm_c2f(c_comm_graph);
    }

    OMPI_ARRAY_FINT_2_INT_CLEANUP(sources);
    if( MPI_UNWEIGHTED != c_sourceweights && MPI_WEIGHTS_EMPTY != c_sourceweights ) {
        OMPI_ARRAY_FINT_2_INT_CLEANUP(sourceweights);
    }
    OMPI_ARRAY_FINT_2_INT_CLEANUP(destinations);
    if( MPI_UNWEIGHTED != c_destweights && MPI_WEIGHTS_EMPTY != c_destweights ) {
        OMPI_ARRAY_FINT_2_INT_CLEANUP(destweights);
    }
}
コード例 #24
0
ファイル: comm_spawn_multiple_f.c プロジェクト: aosm/openmpi
void mpi_comm_spawn_multiple_f(MPI_Fint *count, char *array_commands,
			       char *array_argv,
			       MPI_Fint *array_maxprocs,
			       MPI_Fint *array_info, MPI_Fint *root,
			       MPI_Fint *comm, MPI_Fint *intercomm,
			       MPI_Fint *array_errcds, MPI_Fint *ierr,
			       int cmd_len, int argv_len)
{
    MPI_Comm c_comm, c_new_comm;
    MPI_Info *c_info;
    int size, array_size, i;
    int *c_errs;
    char **c_array_commands;
    char ***c_array_argv;
    OMPI_ARRAY_NAME_DECL(array_maxprocs);
    OMPI_ARRAY_NAME_DECL(array_errcds);
    
    c_comm = MPI_Comm_f2c(*comm);
    
    MPI_Comm_size(c_comm, &size);

    array_size = OMPI_FINT_2_INT(*count);

    /* It's allowed to ignore the errcodes */

    if (OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_errcds)) {
        c_errs = MPI_ERRCODES_IGNORE;
    } else {
        OMPI_ARRAY_FINT_2_INT_ALLOC(array_errcds, size);
        c_errs = OMPI_ARRAY_NAME_CONVERT(array_errcds);
    }

    /* It's allowed to have no argv */

    if (OMPI_IS_FORTRAN_ARGVS_NULL(array_argv)) {
        c_array_argv = MPI_ARGVS_NULL;
    } else {
	ompi_fortran_multiple_argvs_f2c(OMPI_FINT_2_INT(*count), array_argv, 
					argv_len, &c_array_argv);
    }

    OMPI_ARRAY_FINT_2_INT(array_maxprocs, array_size);
    
    ompi_fortran_argv_f2c(array_commands, cmd_len, &c_array_commands);
	
    c_info = malloc (array_size * sizeof(MPI_Info));
    for (i = 0; i < array_size; ++i) {
	c_info[i] = MPI_Info_f2c(array_info[i]);
    }

    *ierr = 
	OMPI_INT_2_FINT(MPI_Comm_spawn_multiple(OMPI_FINT_2_INT(*count),
				       c_array_commands,
				       c_array_argv, 
				       OMPI_ARRAY_NAME_CONVERT(array_maxprocs),
				       c_info,
				       OMPI_FINT_2_INT(*root),
				       c_comm, &c_new_comm,
				       c_errs));
    if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        *intercomm = MPI_Comm_c2f(c_new_comm);
    }

    if (!OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_errcds)) {
	OMPI_ARRAY_INT_2_FINT(array_errcds, size);
    }
    OMPI_ARRAY_FINT_2_INT_CLEANUP(array_maxprocs);

    opal_argv_free(c_array_commands);

    if (MPI_ARGVS_NULL != c_array_argv && NULL != c_array_argv) {
	for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) { 
	    opal_argv_free(c_array_argv[i]);
	}
    }
    free(c_array_argv);
}