class Topo_Cart;
class Topo_Graph;
class Topo_Dist_Graph;
+class Type_Contiguous;
+class Type_Hindexed;
+class Type_Hvector;
+class Type_Indexed;
+class Type_Struct;
+class Type_Vector;
class Win;
-
-
}
}
typedef simgrid::smpi::Topo_Dist_Graph SMPI_Dist_Graph_topology;
typedef simgrid::smpi::Topo_Graph SMPI_Graph_topology;
typedef simgrid::smpi::Win SMPI_Win;
+typedef simgrid::smpi::Type_Contiguous SMPI_Type_Contiguous;
+typedef simgrid::smpi::Type_Hindexed SMPI_Type_Hindexed;
+typedef simgrid::smpi::Type_Hvector SMPI_Type_Hvector;
+typedef simgrid::smpi::Type_Indexed SMPI_Type_Indexed;
+typedef simgrid::smpi::Type_Struct SMPI_Type_Struct;
+typedef simgrid::smpi::Type_Vector SMPI_Type_Vector;
#else
typedef struct SMPI_Graph_topology SMPI_Graph_topology;
typedef struct SMPI_Cart_topology SMPI_Cart_topology;
typedef struct SMPI_Dist_Graph_topology SMPI_Dist_Graph_topology;
+typedef struct SMPI_Type_Contiguous SMPI_Type_Contiguous;
+typedef struct SMPI_Type_Hindexed SMPI_Type_Hindexed;
+typedef struct SMPI_Type_Hvector SMPI_Type_Hvector;
+typedef struct SMPI_Type_Indexed SMPI_Type_Indexed;
+typedef struct SMPI_Type_Struct SMPI_Type_Struct;
+typedef struct SMPI_Type_Vector SMPI_Type_Vector;
#endif
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
block_size = extent * send_count;
// do local allgather/local copy
recv_offset = rank * block_size;
- smpi_datatype_copy(send_buff, send_count, send_type, (char *)recv_buff + recv_offset,
+ Datatype::copy(send_buff, send_count, send_type, (char *)recv_buff + recv_offset,
recv_count, recv_type);
// do row-wise comm
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
if (!is_3dmesh(num_procs, &X, &Y, &Z))
THROWF(arg_error,0, "allgather_3dmesh algorithm can't be used with this number of processes! ");
// do local allgather/local copy
recv_offset = rank * block_size;
- smpi_datatype_copy(send_buff, send_count, send_type, (char *)recv_buff + recv_offset,
+ Datatype::copy(send_buff, send_count, send_type, (char *)recv_buff + recv_offset,
recv_count, recv_type);
// do rowwise comm
rank = comm->rank();
size = comm->size();
- rextent = smpi_datatype_get_extent(rtype);
- sextent = smpi_datatype_get_extent(stype);
+ rextent = rtype->get_extent();
+ sextent = stype->get_extent();
MPI_Request *rrequest_array;
MPI_Request *srequest_array;
rrequest_array = (MPI_Request *) xbt_malloc(size * sizeof(MPI_Request));
rank = comm->rank();
size = comm->size();
- rextent = smpi_datatype_get_extent(rtype);
- sextent = smpi_datatype_get_extent(stype);
+ rextent = rtype->get_extent();
+ sextent = stype->get_extent();
// irregular case use default MPI fucntions
if (scount * sextent != rcount * rextent) {
comm_size = comm->size();
rank = comm->rank();
MPI_Aint rextent, sextent;
- rextent = smpi_datatype_get_extent(rtype);
- sextent = smpi_datatype_get_extent(stype);
+ rextent = rtype->get_extent();
+ sextent = stype->get_extent();
int tag = COLL_TAG_ALLGATHER;
int i, send_offset, recv_offset;
rank = comm->rank();
// get size of single element's type for recv buffer
- recv_extent = smpi_datatype_get_extent(recv_type);
+ recv_extent = recv_type->get_extent();
count = recv_count;
tmp_buff = (char *) smpi_get_tmp_sendbuffer(num_procs * recv_count * recv_extent);
// perform a local copy
- smpi_datatype_copy(send_ptr, send_count, send_type,
+ Datatype::copy(send_ptr, send_count, send_type,
tmp_buff, recv_count, recv_type);
while (pof2 <= (num_procs / 2)) {
src = (rank + pof2) % num_procs;
rank = comm->rank();
MPI_Aint rextent, sextent;
- rextent = smpi_datatype_get_extent(rtype);
- sextent = smpi_datatype_get_extent(stype);
+ rextent = rtype->get_extent();
+ sextent = stype->get_extent();
MPI_Request inter_rrequest;
MPI_Request rrequest_array[128];
MPI_Request srequest_array[128];
size = comm->size();
/* extract the rank,size information for the intra-node communicator */
- recvtype_extent=smpi_datatype_get_extent(recvtype);
+ recvtype_extent=recvtype->get_extent();
shmem_comm = comm->get_intra_comm();
local_rank = shmem_comm->rank();
}
- void* sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[leader_comm->rank()];
+ void* sendbuf=((char*)recvbuf)+recvtype->get_extent()*displs[leader_comm->rank()];
mpi_errno = mpi_coll_allgatherv_fun(sendbuf,
(recvcnt*local_size),
xbt_free(displs);
xbt_free(recvcnts);
} else {
- void* sendtmpbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*(recvcnt*local_size)*leader_comm->rank();
+ void* sendtmpbuf=((char*)recvbuf)+recvtype->get_extent()*(recvcnt*local_size)*leader_comm->rank();
XBT_DEBUG(
"coll:tuned:allgather_intra_neighborexchange rank %d", rank);
- err = smpi_datatype_extent (sdtype, &slb, &sext);
+ err = sdtype->extent(&slb, &sext);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
- err = smpi_datatype_extent (rdtype, &rlb, &rext);
+ err = rdtype->extent(&rlb, &rext);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
/* Initialization step:
tmprecv = (char*) rbuf + rank * rcount * rext;
if (MPI_IN_PLACE != sbuf) {
tmpsend = (char*) sbuf;
- smpi_datatype_copy (tmpsend, scount, sdtype, tmprecv, rcount, rdtype);
+ Datatype::copy (tmpsend, scount, sdtype, tmprecv, rcount, rdtype);
}
/* Determine neighbors, order in which blocks will arrive, etc. */
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "allgather pair algorithm can't be used with non power of two number of processes ! ");
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
// local send/recv
Request::sendrecv(send_ptr, send_count, send_type, rank, tag,
unsigned int rank = comm->rank();
// get size of single element's type for send buffer and recv buffer
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
// multiply size of each element by number of elements to send or recv
send_chunk *= send_count;
unsigned int rank = comm->rank();
// get size of single element's type for send buffer and recv buffer
- s_extent = smpi_datatype_get_extent(send_type);
- r_extent = smpi_datatype_get_extent(recv_type);
+ s_extent = send_type->get_extent();
+ r_extent = recv_type->get_extent();
// multiply size of each element by number of elements to send or recv
send_chunk = s_extent * send_count;
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
// local send/recv
Request::sendrecv(sendptr, send_count, send_type, rank, tag,
rank = comm->rank();
MPI_Aint rextent, sextent;
- rextent = smpi_datatype_get_extent(rtype);
- sextent = smpi_datatype_get_extent(stype);
+ rextent = rtype->get_extent();
+ sextent = stype->get_extent();
int tag = COLL_TAG_ALLGATHER;
MPI_Status status;
int i, send_offset, recv_offset;
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
num_reqs = (2 * num_procs) - 2;
reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
if (total_count == 0)
return MPI_ERR_COUNT;
- recvtype_extent=smpi_datatype_get_extent( recvtype);
+ recvtype_extent=recvtype->get_extent();
/* need to receive contiguously into tmp_buf because
displs could make the recvbuf noncontiguous */
- smpi_datatype_extent(recvtype, &recvtype_true_lb, &recvtype_true_extent);
+ recvtype->extent(&recvtype_true_lb, &recvtype_true_extent);
tmp_buf_rl= (void*)smpi_get_tmp_sendbuffer(total_count*(MAX(recvtype_true_extent,recvtype_extent)));
position += recvcounts[i];
if (sendbuf != MPI_IN_PLACE)
{
- smpi_datatype_copy(sendbuf, sendcount, sendtype,
+ Datatype::copy(sendbuf, sendcount, sendtype,
((char *)tmp_buf + position*
recvtype_extent),
recvcounts[rank], recvtype);
else
{
/* if in_place specified, local data is found in recvbuf */
- smpi_datatype_copy(((char *)recvbuf +
+ Datatype::copy(((char *)recvbuf +
displs[rank]*recvtype_extent),
recvcounts[rank], recvtype,
((char *)tmp_buf + position*
if ((sendbuf != MPI_IN_PLACE) || (j != rank)) {
/* not necessary to copy if in_place and
j==rank. otherwise copy. */
- smpi_datatype_copy(((char *)tmp_buf + position*recvtype_extent),
+ Datatype::copy(((char *)tmp_buf + position*recvtype_extent),
recvcounts[j], recvtype,
((char *)recvbuf + displs[j]*recvtype_extent),
recvcounts[j], recvtype);
rank= comm->rank();
comm_size=comm->size();
- recvtype_extent= smpi_datatype_get_extent( recvtype);
+ recvtype_extent= recvtype->get_extent();
total_count = 0;
for (i=0; i<comm_size; i++)
total_count += recvcounts[i];
if (sendbuf != MPI_IN_PLACE) {
/* First, load the "local" version in the recvbuf. */
- smpi_datatype_copy(sendbuf, sendcount, send_type,
+ Datatype::copy(sendbuf, sendcount, send_type,
((char *)recvbuf + displs[rank]*recvtype_extent),
recvcounts[rank], recvtype);
}
XBT_DEBUG(
"coll:tuned:allgather_ompi_bruck rank %d", rank);
- smpi_datatype_extent (sdtype, &slb, &sext);
+ sdtype->extent(&slb, &sext);
- smpi_datatype_extent (rdtype, &rlb, &rext);
+ rdtype->extent(&rlb, &rext);
/* Initialization step:
- if send buffer is not MPI_IN_PLACE, copy send buffer to block rank of
tmprecv = (char*) rbuf + rdispls[rank] * rext;
if (MPI_IN_PLACE != sbuf) {
tmpsend = (char*) sbuf;
- smpi_datatype_copy(tmpsend, scount, sdtype,
+ Datatype::copy(tmpsend, scount, sdtype,
tmprecv, rcounts[rank], rdtype);
}
new_rcounts[i] = rcounts[tmp_rrank];
new_rdispls[i] = rdispls[tmp_rrank];
}
- smpi_datatype_indexed(blockcount, new_scounts, new_sdispls,
+ Datatype::create_indexed(blockcount, new_scounts, new_sdispls,
rdtype, &new_sdtype);
- smpi_datatype_indexed(blockcount, new_rcounts, new_rdispls,
+ Datatype::create_indexed(blockcount, new_rcounts, new_rdispls,
rdtype, &new_rdtype);
- smpi_datatype_commit(&new_sdtype);
- smpi_datatype_commit(&new_rdtype);
+ new_sdtype->commit();
+ new_rdtype->commit();
/* Sendreceive */
Request::sendrecv(rbuf, 1, new_sdtype, sendto,
rbuf, 1, new_rdtype, recvfrom,
COLL_TAG_ALLGATHERV,
comm, MPI_STATUS_IGNORE);
- smpi_datatype_unuse(new_sdtype);
- smpi_datatype_unuse(new_rdtype);
+ new_sdtype->unuse();
+ new_rdtype->unuse();
}
XBT_DEBUG(
"coll:tuned:allgatherv_ompi_neighborexchange rank %d", rank);
- err = smpi_datatype_extent (sdtype, &slb, &sext);
+ err = sdtype->extent(&slb, &sext);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
- err = smpi_datatype_extent (rdtype, &rlb, &rext);
+ err = rdtype->extent(&rlb, &rext);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
/* Initialization step:
tmprecv = (char*) rbuf + rdispls[rank] * rext;
if (MPI_IN_PLACE != sbuf) {
tmpsend = (char*) sbuf;
- err = smpi_datatype_copy(tmpsend, scount, sdtype,
+ err = Datatype::copy(tmpsend, scount, sdtype,
tmprecv, rcounts[rank], rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
}
new_scounts[1] = rcounts[(send_data_from + 1)];
new_sdispls[0] = rdispls[send_data_from];
new_sdispls[1] = rdispls[(send_data_from + 1)];
- err = smpi_datatype_indexed(2, new_scounts, new_sdispls, rdtype,
+ err = Datatype::create_indexed(2, new_scounts, new_sdispls, rdtype,
&new_sdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
- smpi_datatype_commit(&new_sdtype);
+ new_sdtype->commit();
new_rcounts[0] = rcounts[recv_data_from[i_parity]];
new_rcounts[1] = rcounts[(recv_data_from[i_parity] + 1)];
new_rdispls[0] = rdispls[recv_data_from[i_parity]];
new_rdispls[1] = rdispls[(recv_data_from[i_parity] + 1)];
- err = smpi_datatype_indexed(2, new_rcounts, new_rdispls, rdtype,
+ err = Datatype::create_indexed(2, new_rcounts, new_rdispls, rdtype,
&new_rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
- smpi_datatype_commit(&new_rdtype);
+ new_rdtype->commit();
tmprecv = (char*)rbuf;
tmpsend = (char*)rbuf;
send_data_from = recv_data_from[i_parity];
- smpi_datatype_unuse(new_sdtype);
- smpi_datatype_unuse(new_rdtype);
+ new_sdtype->unuse();
+ new_rdtype->unuse();
}
return MPI_SUCCESS;
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "allgatherv pair algorithm can't be used with non power of two number of processes ! ");
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
// local send/recv
Request::sendrecv(send_ptr, send_count, send_type, rank, tag,
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
// local send/recv
Request::sendrecv(sendptr, send_count, send_type, rank, tag,
/* make it compatible with all data type */
MPI_Aint extent;
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
/* when communication size is smaller than number of process (not support) */
if (rcount < size) {
is_commutative = (op==MPI_OP_NULL || op->is_commutative());
/* need to allocate temporary buffer to store incoming data */
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
- extent = smpi_datatype_get_extent(datatype);
+ datatype->extent(&true_lb, &true_extent);
+ extent = datatype->get_extent();
tmp_buf_free= smpi_get_tmp_recvbuffer(count * (MAX(extent, true_extent)));
/* copy local data into recvbuf */
if (sendbuf != MPI_IN_PLACE) {
mpi_errno =
- smpi_datatype_copy(sendbuf, count, datatype, recvbuf, count,
+ Datatype::copy(sendbuf, count, datatype, recvbuf, count,
datatype);
}
/* op is noncommutative and the order is not right */
if(op!=MPI_OP_NULL) op->apply( recvbuf, tmp_buf, &count, datatype);
/* copy result back into recvbuf */
- mpi_errno = smpi_datatype_copy(tmp_buf, count, datatype,
+ mpi_errno = Datatype::copy(tmp_buf, count, datatype,
recvbuf, count, datatype);
}
mask <<= 1;
if (count == 0) {
return MPI_SUCCESS;
}
- smpi_datatype_extent(datatype, &true_lb,
+ datatype->extent(&true_lb,
&true_extent);
total_size = comm->size();
if (local_rank == 0) {
if (sendbuf != MPI_IN_PLACE) {
- smpi_datatype_copy(sendbuf, count, datatype, recvbuf,
+ Datatype::copy(sendbuf, count, datatype, recvbuf,
count, datatype);
}
}
}
if (local_size != total_size) {
- void* sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype));
- smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
+ void* sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*datatype->get_extent());
+ Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
/* inter-node allreduce */
if(MV2_Allreduce_function == &MPIR_Allreduce_pt2pt_rd_MV2){
mpi_errno =
/* Special case for size == 1 */
if (1 == size) {
if (MPI_IN_PLACE != sbuf) {
- ret= smpi_datatype_copy(sbuf, count, dtype,rbuf, count, dtype);
+ ret= Datatype::copy(sbuf, count, dtype,rbuf, count, dtype);
if (ret < 0) { line = __LINE__; goto error_hndl; }
}
return MPI_SUCCESS;
}
/* Determine segment count based on the suggested segment size */
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
if (MPI_SUCCESS != ret) { line = __LINE__; goto error_hndl; }
- true_extent = smpi_datatype_get_extent(dtype);
+ true_extent = dtype->get_extent();
if (MPI_SUCCESS != ret) { line = __LINE__; goto error_hndl; }
- typelng = smpi_datatype_size(dtype);
+ typelng = dtype->size();
if (MPI_SUCCESS != ret) { line = __LINE__; goto error_hndl; }
segcount = count;
COLL_TUNED_COMPUTED_SEGCOUNT(segsize, typelng, segcount)
/* Handle MPI_IN_PLACE */
if (MPI_IN_PLACE != sbuf) {
- ret= smpi_datatype_copy(sbuf, count, dtype,rbuf, count, dtype);
+ ret= Datatype::copy(sbuf, count, dtype,rbuf, count, dtype);
if (ret < 0) { line = __LINE__; goto error_hndl; }
}
unsigned int nprocs = comm->size();
int rank = comm->rank();
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
- smpi_datatype_copy(sbuff, count, dtype, rbuff, count, dtype);
+ Datatype::copy(sbuff, count, dtype, rbuff, count, dtype);
// find nearest power-of-two less than or equal to comm_size
pof2 = 1;
if((nprocs&(nprocs-1)))
THROWF(arg_error,0, "allreduce rab1 algorithm can't be used with non power of two number of processes ! ");
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
pof2 = 1;
while (pof2 <= nprocs)
nprocs = comm->size();
- s_extent = smpi_datatype_get_extent(dtype);
+ s_extent = dtype->get_extent();
// uneven count
if (count % nprocs) {
nprocs=comm->size();
rank=comm->rank();
- smpi_datatype_extent(dtype, &lb, &extent);
+ dtype->extent(&lb, &extent);
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
Request::sendrecv(sbuff, count, dtype, rank, 500,
comm_size = comm->size();
rank = comm->rank();
MPI_Aint extent;
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
int intra_rank, inter_rank;
comm_size=comm->size();
rank=comm->rank();
MPI_Aint extent, lb;
- smpi_datatype_extent(dtype, &lb, &extent);
+ dtype->extent(&lb, &extent);
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
/* compute intra and inter ranking */
comm_size = comm->size();
rank = comm->rank();
MPI_Aint extent;
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
/* compute intra and inter ranking */
comm_size = comm->size();
rank = comm->rank();
MPI_Aint extent;
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
int intra_rank, inter_rank;
rank = comm->rank();
MPI_Aint extent;
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
int intra_rank, inter_rank;
comm_size = comm->size();
rank = comm->rank();
MPI_Aint extent;
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
int intra_rank, inter_rank;
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
if (!alltoall_check_is_2dmesh(num_procs, &X, &Y))
return MPI_ERR_OTHER;
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(send_type);
+ extent = send_type->get_extent();
if (!alltoall_check_is_3dmesh(num_procs, &X, &Y, &Z))
return MPI_ERR_OTHER;
num_procs = comm->size();
rank = comm->rank();
- extent = smpi_datatype_get_extent(recv_type);
+ extent = recv_type->get_extent();
tmp_buff = (char *) smpi_get_tmp_sendbuffer(num_procs * recv_count * extent);
disps = (int *) xbt_malloc(sizeof(int) * num_procs);
rank = comm->rank();
/* Get extent of send and recv types */
- recvtype_extent = smpi_datatype_get_extent(recvtype);
- sendtype_extent = smpi_datatype_get_extent(sendtype);
+ recvtype_extent = recvtype->get_extent();
+ sendtype_extent = sendtype->get_extent();
/* Medium-size message. Use isend/irecv with scattered
destinations. Use Tony Ladd's modification to post only
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
win=new Win(recv_buff, num_procs * recv_chunk * send_count, recv_chunk, 0,
comm);
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
num_procs = comm->size();
rank = comm->rank();
- send_increment = smpi_datatype_get_extent(send_type);
- recv_increment = smpi_datatype_get_extent(recv_type);
- extent = smpi_datatype_get_extent(recv_type);
+ send_increment = send_type->get_extent();
+ recv_increment = recv_type->get_extent();
+ extent = recv_type->get_extent();
send_increment *= (send_count * num_procs);
recv_increment *= (recv_count * num_procs);
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
send_chunk *= send_count;
recv_chunk *= recv_count;
size = comm->size();
XBT_DEBUG("<%d> algorithm alltoall_bruck() called.", rank);
- smpi_datatype_extent(sendtype, &lb, &sendext);
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ sendtype->extent(&lb, &sendext);
+ recvtype->extent(&lb, &recvext);
/* Local copy from self */
err =
- smpi_datatype_copy((char *)sendbuf + senddisps[rank] * sendext,
+ Datatype::copy((char *)sendbuf + senddisps[rank] * sendext,
sendcounts[rank], sendtype,
(char *)recvbuf + recvdisps[rank] * recvext,
recvcounts[rank], recvtype);
XBT_DEBUG(
"coll:tuned:alltoallv_intra_basic_linear rank %d", rank);
- sext=smpi_datatype_get_extent(sdtype);
- rext=smpi_datatype_get_extent(rdtype);
+ sext=sdtype->get_extent();
+ rext=rdtype->get_extent();
/* Simple optimization - handle send to self first */
psnd = ((char *) sbuf) + (sdisps[rank] * sext);
prcv = ((char *) rbuf) + (rdisps[rank] * rext);
if (0 != scounts[rank]) {
- smpi_datatype_copy(psnd, scounts[rank], sdtype,
+ Datatype::copy(psnd, scounts[rank], sdtype,
prcv, rcounts[rank], rdtype);
}
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
Request::sendrecv(send_ptr + send_disps[rank] * send_chunk, send_counts[rank], send_type, rank, tag,
recv_ptr + recv_disps[rank] * recv_chunk, recv_counts[rank], recv_type, rank, tag,
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
for (i = 0; i < num_procs; i++) {
src = dst = rank ^ i;
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
smpi_mpi_barrier(comm);
for (i = 0; i < num_procs; i++) {
if((num_procs&(num_procs-1)))
THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
for (i = 0; i < num_procs; i++) {
src = dst = rank ^ i;
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
Request::sendrecv(send_ptr + send_disps[rank] * send_chunk, send_counts[rank], send_type, rank, tag,
recv_ptr + recv_disps[rank] * recv_chunk, recv_counts[rank], recv_type, rank, tag,
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
for (i = 0; i < num_procs; i++) {
src = (rank - i + num_procs) % num_procs;
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
smpi_mpi_barrier(comm);
for (i = 0; i < num_procs; i++) {
rank = comm->rank();
num_procs = comm->size();
- send_chunk = smpi_datatype_get_extent(send_type);
- recv_chunk = smpi_datatype_get_extent(recv_type);
+ send_chunk = send_type->get_extent();
+ recv_chunk = recv_type->get_extent();
int pof2 = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs));
for (i = 0; i < num_procs; i++) {
MPI_Status *recv_status_array;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
rank = comm->rank();
size = comm->size();
int rank, size;
int i;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
rank = comm->rank();
size = comm->size();
int rank, size;
int i;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
rank = comm->rank();
size = comm->size();
int rank, size;
int i;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
rank = comm->rank();
size = comm->size();
int rank, size;
int i;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
rank = comm->rank();
size = comm->size();
int header_size = BCAST_ARRIVAL_PATTERN_AWARE_HEADER_SIZE;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
/* source and destination */
int to, from;
char temp_buf[MAX_NODE];
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
/* destination */
int to;
int header_size = BCAST_ARRIVAL_PATTERN_AWARE_HEADER_SIZE;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
/* source and destination */
int tag = COLL_TAG_BCAST;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(data_type);
+ extent = data_type->get_extent();
int segment = flattree_segment_in_byte / extent;
segment = segment == 0 ? 1 :segment;
* possible, and MPI_Pack_size() in other places.
*/
//if (is_homogeneous) {
- type_size=smpi_datatype_size(datatype);
+ type_size=datatype->size();
//}
/* else {*/
/* MPIR_Pack_size_impl(1, datatype, &type_size);*/
/**
* Determine number of elements sent per operation.
*/
- type_size = smpi_datatype_size(datatype);
+ type_size = datatype->size();
size = comm->size();
rank = comm->rank();
- extent = smpi_datatype_get_extent (datatype);
+ extent = datatype->get_extent();
num_segments = (original_count + count_by_segment - 1) / count_by_segment;
realsegsize = count_by_segment * extent;
//compute again segsize
const size_t intermediate_message_size = 370728;
- size_t message_size = smpi_datatype_size(datatype) * (unsigned long)count;
+ size_t message_size = datatype->size() * (unsigned long)count;
if(message_size < intermediate_message_size)
segsize = 1024 ;
else
/* setup the binary tree topology. */
tree = ompi_coll_tuned_topo_build_tree(2,comm,root);
- type_size = smpi_datatype_size( datatype );
+ type_size = datatype->size();
/* Determine number of segments and number of elements per segment */
counts[0] = count/2;
return (smpi_coll_tuned_bcast_SMP_linear ( buffer, count, datatype,
root, comm));
}
- type_extent = smpi_datatype_get_extent(datatype);
+ type_extent = datatype->get_extent();
/* Determine real segment size */
rank = comm->rank();
num_procs = comm->size();
- extent = smpi_datatype_get_extent(data_type);
+ extent = data_type->get_extent();
nbytes = extent * count;
#include "colls_private.h"
-#include "src/smpi/smpi_mpi_dt_private.h"
static int scatter_for_bcast(
int root,
* possible, and MPI_Pack_size() in other places.
*/
if (is_homogeneous)
- type_size=smpi_datatype_size(datatype);
+ type_size=datatype->size();
nbytes = type_size * count;
if (nbytes == 0)
if (is_contig && is_homogeneous)
{
/* contiguous and homogeneous. no need to pack. */
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
+ datatype->extent(&true_lb, &true_extent);
tmp_buf = (char *) buffer + true_lb;
}
/* TODO: Pipeline the packing and communication */
position = 0;
if (rank == root) {
- mpi_errno = smpi_mpi_pack(buffer, count, datatype, tmp_buf, nbytes,
+ mpi_errno = datatype->pack(buffer, count, tmp_buf, nbytes,
&position, comm);
if (mpi_errno) xbt_die("crash while packing %d", mpi_errno);
}
if (sendtype != MPI_DATATYPE_NULL) {
- smpi_datatype_extent(sendtype, &true_lb,
+ sendtype->extent(&true_lb,
&sendtype_true_extent);
}
if (recvtype != MPI_DATATYPE_NULL) {
- recvtype_extent=smpi_datatype_get_extent(recvtype);
- smpi_datatype_extent(recvtype, &true_lb,
+ recvtype_extent=recvtype->get_extent();
+ recvtype->extent(&true_lb,
&recvtype_true_extent);
}
}
if (sendtype != MPI_DATATYPE_NULL) {
- sendtype_extent=smpi_datatype_get_extent(sendtype);
- sendtype_size=smpi_datatype_size(sendtype);
- smpi_datatype_extent(sendtype, &true_lb,
+ sendtype_extent=sendtype->get_extent();
+ sendtype_size=sendtype->size();
+ sendtype->extent(&true_lb,
&sendtype_true_extent);
}
if (recvtype != MPI_DATATYPE_NULL) {
- recvtype_extent=smpi_datatype_get_extent(recvtype);
- recvtype_size=smpi_datatype_size(recvtype);
- smpi_datatype_extent(recvtype, &true_lb,
+ recvtype_extent=recvtype->get_extent();
+ recvtype_size=recvtype->size();
+ recvtype->extent(&true_lb,
&recvtype_true_extent);
}
bmtree = ompi_coll_tuned_topo_build_in_order_bmtree(comm, root);
// data->cached_in_order_bmtree;
- smpi_datatype_extent(sdtype, &slb, &sextent);
- smpi_datatype_extent(sdtype, &strue_lb, &strue_extent);
+ sdtype->extent(&slb, &sextent);
+ sdtype->extent(&strue_lb, &strue_extent);
vrank = (rank - root + size) % size;
if (rank == root) {
- smpi_datatype_extent(rdtype, &rlb, &rextent);
- smpi_datatype_extent(rdtype, &rtrue_lb, &rtrue_extent);
+ rdtype->extent(&rlb, &rextent);
+ rdtype->extent(&rtrue_lb, &rtrue_extent);
if (0 == root){
/* root on 0, just use the recv buffer */
ptmp = (char *) rbuf;
if (sbuf != MPI_IN_PLACE) {
- err = smpi_datatype_copy(sbuf, scount, sdtype,
+ err = Datatype::copy(sbuf, scount, sdtype,
ptmp, rcount, rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
}
ptmp = tempbuf - rlb;
if (sbuf != MPI_IN_PLACE) {
/* copy from sbuf to temp buffer */
- err = smpi_datatype_copy(sbuf, scount, sdtype,
+ err = Datatype::copy(sbuf, scount, sdtype,
ptmp, rcount, rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
} else {
/* copy from rbuf to temp buffer */
- err = smpi_datatype_copy((char *) rbuf + rank*rextent*rcount, rcount, rdtype, ptmp, rcount, rdtype );
+ err = Datatype::copy((char *) rbuf + rank*rextent*rcount, rcount, rdtype, ptmp, rcount, rdtype );
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
}
}
ptmp = tempbuf - slb;
/* local copy to tempbuf */
- err = smpi_datatype_copy(sbuf, scount, sdtype,
+ err = Datatype::copy(sbuf, scount, sdtype,
ptmp, scount, sdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
if (rank == root) {
if (root != 0) {
/* rotate received data on root if root != 0 */
- err = smpi_datatype_copy(ptmp, rcount*(size - root), rdtype,
+ err = Datatype::copy(ptmp, rcount*(size - root), rdtype,
(char *) rbuf + rextent*root*rcount, rcount*(size - root), rdtype );
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
- err = smpi_datatype_copy( ptmp + rextent*rcount*(size-root), rcount*root,rdtype,
+ err = Datatype::copy( ptmp + rextent*rcount*(size-root), rcount*root,rdtype,
(char *) rbuf,rcount*root,rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
size_t dsize, block_size;
if (rank == root) {
- dsize= smpi_datatype_size(rdtype);
+ dsize= rdtype->size();
block_size = dsize * rcount;
} else {
- dsize=smpi_datatype_size(sdtype);
+ dsize=sdtype->size();
block_size = dsize * scount;
}
- send the second segment of the data.
*/
- typelng= smpi_datatype_size(sdtype);
- smpi_datatype_extent(sdtype, &lb, &extent);
+ typelng= sdtype->size();
+ sdtype->extent(&lb, &extent);
first_segment_count = scount;
COLL_TUNED_COMPUTED_SEGCOUNT( (size_t) first_segment_size, typelng,
first_segment_count );
reqs = (MPI_Request *) calloc(size, sizeof(MPI_Request ));
if (NULL == reqs) { ret = -1; line = __LINE__; goto error_hndl; }
- typelng=smpi_datatype_size(rdtype);
- smpi_datatype_extent(rdtype, &lb, &extent);
+ typelng=rdtype->size();
+ rdtype->extent(&lb, &extent);
first_segment_count = rcount;
COLL_TUNED_COMPUTED_SEGCOUNT( (size_t)first_segment_size, typelng,
first_segment_count );
/* copy local data if necessary */
if (MPI_IN_PLACE != sbuf) {
- ret = smpi_datatype_copy(sbuf, scount, sdtype,
+ ret = Datatype::copy(sbuf, scount, sdtype,
(char*)rbuf + rank * rcount * extent,
rcount, rdtype);
if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; }
/* I am the root, loop receiving the data. */
- smpi_datatype_extent(rdtype, &lb, &extent);
+ rdtype->extent(&lb, &extent);
incr = extent * rcount;
for (i = 0, ptmp = (char *) rbuf; i < size; ++i, ptmp += incr) {
if (i == rank) {
if (MPI_IN_PLACE != sbuf) {
- err = smpi_datatype_copy(sbuf, scount, sdtype,
+ err = Datatype::copy(sbuf, scount, sdtype,
ptmp, rcount, rdtype);
} else {
err = MPI_SUCCESS;
int rank, size;
int i;
MPI_Aint extent;
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
rank = comm->rank();
size = comm->size();
char temp_buf[MAX_NODE];
MPI_Aint extent, lb;
- smpi_datatype_extent(datatype, &lb, &extent);
+ datatype->extent(&lb, &extent);
/* source and destination */
int to, from;
rank = comm->rank();
comm_size = comm->size();
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
int is_commutative = (op==MPI_OP_NULL || op->is_commutative());
lroot = 0;
relrank = (rank - lroot + comm_size) % comm_size;
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
+ datatype->extent(&true_lb, &true_extent);
/* adjust for potential negative lower bound in datatype */
tmp_buf = (void *)((char*)tmp_buf - true_lb);
recvbuf = (void *)((char*)recvbuf - true_lb);
}
if ((rank != root) || (sendbuf != MPI_IN_PLACE)) {
- smpi_datatype_copy(sendbuf, count, datatype, recvbuf,count, datatype);
+ Datatype::copy(sendbuf, count, datatype, recvbuf,count, datatype);
}
while (mask < comm_size) {
if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, datatype);
} else {
if(op!=MPI_OP_NULL) op->apply( recvbuf, tmp_buf, &count, datatype);
- smpi_datatype_copy(tmp_buf, count, datatype,recvbuf, count, datatype);
+ Datatype::copy(tmp_buf, count, datatype,recvbuf, count, datatype);
}
}
} else {
size = comm->size();
/* If not root, send data to the root. */
- extent = smpi_datatype_get_extent(dtype);
+ extent = dtype->get_extent();
if (rank != root) {
Request::send(sbuf, count, dtype, root, tag, comm);
/* Create a temporary buffer */
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
- extent = smpi_datatype_get_extent(datatype);
+ datatype->extent(&true_lb, &true_extent);
+ extent = datatype->get_extent();
is_commutative = (op==MPI_OP_NULL || op->is_commutative());
}
if ((rank != root) || (sendbuf != MPI_IN_PLACE)) {
- mpi_errno = smpi_datatype_copy(sendbuf, count, datatype, recvbuf,
+ mpi_errno = Datatype::copy(sendbuf, count, datatype, recvbuf,
count, datatype);
}
is_commutative= (op==MPI_OP_NULL || op->is_commutative());
- smpi_datatype_extent(datatype, &true_lb,
+ datatype->extent(&true_lb,
&true_extent);
- extent =smpi_datatype_get_extent(datatype);
+ extent =datatype->get_extent();
stride = count * MAX(extent, true_extent);
if (local_size == total_size) {
} else {
in_buf = (char *)smpi_get_tmp_sendbuffer(count*
- smpi_datatype_get_extent(datatype));
- smpi_datatype_copy(tmp_buf, count, datatype,
+ datatype->get_extent());
+ Datatype::copy(tmp_buf, count, datatype,
in_buf, count, datatype);
//in_buf = MPI_IN_PLACE;
out_buf = recvbuf;
}
} else {
in_buf = (char *)smpi_get_tmp_sendbuffer(count*
- smpi_datatype_get_extent(datatype));
- smpi_datatype_copy(tmp_buf, count, datatype,
+ datatype->get_extent());
+ Datatype::copy(tmp_buf, count, datatype,
in_buf, count, datatype);
//in_buf = MPI_IN_PLACE;
out_buf = tmp_buf;
* Determine number of segments and number of elements
* sent per operation
*/
- smpi_datatype_extent( datatype, &lower_bound, &extent);
+ datatype->extent(&lower_bound, &extent);
num_segments = (original_count + count_by_segment - 1) / count_by_segment;
segment_increment = count_by_segment * extent;
(if needed) */
if( tree->tree_nextsize > 0 ) {
ptrdiff_t true_extent, real_segment_size;
- true_extent=smpi_datatype_get_extent( datatype);
+ true_extent=datatype->get_extent();
/* handle non existant recv buffer (i.e. its NULL) and
protect the recv buffer on non-root nodes */
/* If this is a non-commutative operation we must copy
sendbuf to the accumbuf, in order to simplfy the loops */
if ( (op!=MPI_OP_NULL && !op->is_commutative())) {
- smpi_datatype_copy(
+ Datatype::copy(
(char*)sendtmpbuf, original_count, datatype,
(char*)accumbuf, original_count, datatype);
}
* Determine number of segments and number of elements
* sent per operation
*/
- typelng = smpi_datatype_size( datatype);
+ typelng = datatype->size();
COLL_TUNED_COMPUTED_SEGCOUNT( segsize, typelng, segcount );
const double b2 = 9.7128;
const double a4 = 0.0033 / 1024.0; /* [1/B] */
const double b4 = 1.6761;
- typelng= smpi_datatype_size( datatype);
+ typelng= datatype->size();
int communicator_size = comm->size();
size_t message_size = typelng * count;
* Determine number of segments and number of elements
* sent per operation
*/
- typelng=smpi_datatype_size( datatype );
+ typelng=datatype->size();
// Binary_32K
segsize = 32*1024;
* Determine number of segments and number of elements
* sent per operation
*/
- typelng= smpi_datatype_size( datatype);
+ typelng= datatype->size();
int communicator_size = comm->size();
size_t message_size = typelng * count;
if (((communicator_size < 8) && (message_size < 20480)) ||
* Determine number of segments and number of elements
* sent per operation
*/
- typelng=smpi_datatype_size( datatype);
+ typelng=datatype->size();
COLL_TUNED_COMPUTED_SEGCOUNT( segsize, typelng, segcount );
/* An in-order binary tree must use root (size-1) to preserve the order of
ptrdiff_t text, ext;
char *tmpbuf = NULL;
- ext=smpi_datatype_get_extent(datatype);
- text=smpi_datatype_get_extent(datatype);
+ ext=datatype->get_extent();
+ text=datatype->get_extent();
if ((root == rank) && (MPI_IN_PLACE == sendbuf)) {
tmpbuf = (char *) smpi_get_tmp_sendbuffer(text + (count - 1) * ext);
if (NULL == tmpbuf) {
return MPI_ERR_INTERN;
}
- smpi_datatype_copy (
+ Datatype::copy (
(char*)recvbuf, count, datatype,
(char*)tmpbuf, count, datatype);
use_this_sendbuf = tmpbuf;
extent and true extent */
/* for reducing buffer allocation lengths.... */
- smpi_datatype_extent(dtype, &lb, &extent);
- true_extent = smpi_datatype_get_extent(dtype);
+ dtype->extent(&lb, &extent);
+ true_extent = dtype->get_extent();
if (MPI_IN_PLACE == sbuf) {
sbuf = rbuf;
/* Initialize the receive buffer. */
if (rank == (size - 1)) {
- smpi_datatype_copy((char*)sbuf, count, dtype,(char*)rbuf, count, dtype);
+ Datatype::copy((char*)sbuf, count, dtype,(char*)rbuf, count, dtype);
} else {
Request::recv(rbuf, count, dtype, size - 1,
COLL_TAG_REDUCE, comm,
}
if (NULL != inplace_temp) {
- smpi_datatype_copy(inplace_temp, count, dtype,(char*)sbuf
+ Datatype::copy(inplace_temp, count, dtype,(char*)sbuf
,count , dtype);
smpi_free_tmp_buffer(inplace_temp);
}
- extent = smpi_datatype_get_extent(datatype);
+ extent = datatype->get_extent();
/* If I'm not the root, then my recvbuf may not be valid, therefore
I have to allocate a temporary one */
if (rank != root && !recvbuf) {
comm_size = comm->size();
rank = comm->rank();
- extent =smpi_datatype_get_extent(datatype);
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
+ extent =datatype->get_extent();
+ datatype->extent(&true_lb, &true_extent);
if (op->is_commutative()) {
is_commutative = 1;
if (sendbuf != MPI_IN_PLACE) {
/* copy local data into recvbuf */
- smpi_datatype_copy(((char *)sendbuf+disps[rank]*extent),
+ Datatype::copy(((char *)sendbuf+disps[rank]*extent),
recvcounts[rank], datatype, recvbuf,
recvcounts[rank], datatype);
}
if(op!=MPI_OP_NULL) op->apply(
recvbuf, tmp_recvbuf, &recvcounts[rank], datatype);
/* copy result back into recvbuf */
- mpi_errno = smpi_datatype_copy(tmp_recvbuf, recvcounts[rank],
+ mpi_errno = Datatype::copy(tmp_recvbuf, recvcounts[rank],
datatype, recvbuf,
recvcounts[rank], datatype);
if (mpi_errno) return(mpi_errno);
((char *)recvbuf+disps[rank]*extent),
tmp_recvbuf, &recvcounts[rank], datatype);
/* copy result back into recvbuf */
- mpi_errno = smpi_datatype_copy(tmp_recvbuf, recvcounts[rank],
+ mpi_errno = Datatype::copy(tmp_recvbuf, recvcounts[rank],
datatype,
((char *)recvbuf +
disps[rank]*extent),
/* if MPI_IN_PLACE, move output data to the beginning of
recvbuf. already done for rank 0. */
if ((sendbuf == MPI_IN_PLACE) && (rank != 0)) {
- mpi_errno = smpi_datatype_copy(((char *)recvbuf +
+ mpi_errno = Datatype::copy(((char *)recvbuf +
disps[rank]*extent),
recvcounts[rank], datatype,
recvbuf,
void *tmp_buf1;
void *result_ptr;
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
+ datatype->extent(&true_lb, &true_extent);
pof2 = 1;
log2_comm_size = 0;
/* Copy our send data to tmp_buf0. We do this one block at a time and
permute the blocks as we go according to the mirror permutation. */
for (i = 0; i < comm_size; ++i) {
- mpi_errno = smpi_datatype_copy((char *)(sendbuf == MPI_IN_PLACE ? recvbuf : sendbuf) + (i * true_extent * block_size), block_size, datatype,
+ mpi_errno = Datatype::copy((char *)(sendbuf == MPI_IN_PLACE ? recvbuf : sendbuf) + (i * true_extent * block_size), block_size, datatype,
(char *)tmp_buf0 + (MPIU_Mirror_permutation(i, log2_comm_size) * true_extent * block_size), block_size, datatype);
if (mpi_errno) return(mpi_errno);
}
/* copy the reduced data to the recvbuf */
result_ptr = (char *)(buf0_was_inout ? tmp_buf0 : tmp_buf1) + recv_offset * true_extent;
- mpi_errno = smpi_datatype_copy(result_ptr, size, datatype,
+ mpi_errno = Datatype::copy(result_ptr, size, datatype,
recvbuf, size, datatype);
smpi_free_tmp_buffer(tmp_buf0_save);
smpi_free_tmp_buffer(tmp_buf1_save);
comm_size = comm->size();
rank = comm->rank();
- extent =smpi_datatype_get_extent(datatype);
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
+ extent =datatype->get_extent();
+ datatype->extent(&true_lb, &true_extent);
if ((op==MPI_OP_NULL) || op->is_commutative()) {
is_commutative = 1;
/* copy sendbuf into tmp_results */
if (sendbuf != MPI_IN_PLACE)
- mpi_errno = smpi_datatype_copy(sendbuf, total_count, datatype,
+ mpi_errno = Datatype::copy(sendbuf, total_count, datatype,
tmp_results, total_count, datatype);
else
- mpi_errno = smpi_datatype_copy(recvbuf, total_count, datatype,
+ mpi_errno = Datatype::copy(recvbuf, total_count, datatype,
tmp_results, total_count, datatype);
if (mpi_errno) return(mpi_errno);
for (j=my_tree_root; (j<my_tree_root+mask) && (j<comm_size); j++)
dis[1] += recvcounts[j];
- mpi_errno = smpi_datatype_indexed(2, blklens, dis, datatype, &sendtype);
+ mpi_errno = Datatype::create_indexed(2, blklens, dis, datatype, &sendtype);
if (mpi_errno) return(mpi_errno);
- smpi_datatype_commit(&sendtype);
+ sendtype->commit();
/* calculate recvtype */
blklens[0] = blklens[1] = 0;
for (j=dst_tree_root; (j<dst_tree_root+mask) && (j<comm_size); j++)
dis[1] += recvcounts[j];
- mpi_errno = smpi_datatype_indexed(2, blklens, dis, datatype, &recvtype);
+ mpi_errno = Datatype::create_indexed(2, blklens, dis, datatype, &recvtype);
if (mpi_errno) return(mpi_errno);
- smpi_datatype_commit(&recvtype);
+ recvtype->commit();
received = 0;
if (dst < comm_size) {
&blklens[1], datatype);
}
/* copy result back into tmp_results */
- mpi_errno = smpi_datatype_copy(tmp_recvbuf, 1, recvtype,
+ mpi_errno = Datatype::copy(tmp_recvbuf, 1, recvtype,
tmp_results, 1, recvtype);
if (mpi_errno) return(mpi_errno);
}
}
- smpi_datatype_unuse(sendtype);
- smpi_datatype_unuse(recvtype);
+ sendtype->unuse();
+ recvtype->unuse();
mask <<= 1;
i++;
}
/* now copy final results from tmp_results to recvbuf */
- mpi_errno = smpi_datatype_copy(((char *)tmp_results+disps[rank]*extent),
+ mpi_errno = Datatype::copy(((char *)tmp_results+disps[rank]*extent),
recvcounts[rank], datatype, recvbuf,
recvcounts[rank], datatype);
if (mpi_errno) return(mpi_errno);
}
/* get datatype information */
- smpi_datatype_extent(dtype, &lb, &extent);
- smpi_datatype_extent(dtype, &true_lb, &true_extent);
+ dtype->extent(&lb, &extent);
+ dtype->extent(&true_lb, &true_extent);
buf_size = true_extent + (ptrdiff_t)(count - 1) * extent;
/* Handle MPI_IN_PLACE */
result_buf = result_buf_free - lb;
/* copy local buffer into the temporary results */
- err =smpi_datatype_copy(sbuf, count, dtype, result_buf, count, dtype);
+ err =Datatype::copy(sbuf, count, dtype, result_buf, count, dtype);
if (MPI_SUCCESS != err) goto cleanup;
/* figure out power of two mapping: grow until larger than
/* copy local results from results buffer into real receive buffer */
if (0 != rcounts[rank]) {
- err = smpi_datatype_copy(result_buf + disps[rank] * extent,
+ err = Datatype::copy(result_buf + disps[rank] * extent,
rcounts[rank], dtype,
rbuf, rcounts[rank], dtype);
if (MPI_SUCCESS != err) {
/* Special case for size == 1 */
if (1 == size) {
if (MPI_IN_PLACE != sbuf) {
- ret = smpi_datatype_copy((char*)sbuf, total_count, dtype, (char*)rbuf, total_count, dtype);
+ ret = Datatype::copy((char*)sbuf, total_count, dtype, (char*)rbuf, total_count, dtype);
if (ret < 0) { line = __LINE__; goto error_hndl; }
}
xbt_free(displs);
rbuf can be of rcounts[rank] size.
- up to two temporary buffers used for communication/computation overlap.
*/
- smpi_datatype_extent(dtype, &lb, &extent);
- smpi_datatype_extent(dtype, &true_lb, &true_extent);
+ dtype->extent(&lb, &extent);
+ dtype->extent(&true_lb, &true_extent);
max_real_segsize = true_extent + (ptrdiff_t)(max_block_count - 1) * extent;
sbuf = rbuf;
}
- ret = smpi_datatype_copy((char*)sbuf, total_count, dtype, accumbuf, total_count, dtype);
+ ret = Datatype::copy((char*)sbuf, total_count, dtype, accumbuf, total_count, dtype);
if (ret < 0) { line = __LINE__; goto error_hndl; }
/* Computation loop */
if(op!=MPI_OP_NULL) op->apply( inbuf[inbi], tmprecv, &(rcounts[rank]), dtype);
/* Copy result from tmprecv to rbuf */
- ret = smpi_datatype_copy(tmprecv, rcounts[rank], dtype, (char*)rbuf, rcounts[rank], dtype);
+ ret = Datatype::copy(tmprecv, rcounts[rank], dtype, (char*)rbuf, rcounts[rank], dtype);
if (ret < 0) { line = __LINE__; goto error_hndl; }
if (NULL != displs) xbt_free(displs);
root, comm);
} else {
- recvtype_size=smpi_datatype_size(recvtype);
- sendtype_size=smpi_datatype_size(sendtype);
+ recvtype_size=recvtype->size();
+ sendtype_size=sendtype->size();
if (rank == root) {
nbytes = sendcnt * sendtype_size;
root, comm);
} else {
- recvtype_size=smpi_datatype_size(recvtype);
- sendtype_size=smpi_datatype_size(sendtype);
+ recvtype_size=recvtype->size();
+ sendtype_size=sendtype->size();
if (rank == root) {
nbytes = sendcnt * sendtype_size;
// COLL_TUNED_UPDATE_IN_ORDER_BMTREE( comm, tuned_module, root );
bmtree = ompi_coll_tuned_topo_build_in_order_bmtree( comm, root);//ompi_ data->cached_in_order_bmtree;
- smpi_datatype_extent(sdtype, &slb, &sextent);
- smpi_datatype_extent(sdtype, &strue_lb, &strue_extent);
- smpi_datatype_extent(rdtype, &rlb, &rextent);
- smpi_datatype_extent(rdtype, &rtrue_lb, &rtrue_extent);
+ sdtype->extent(&slb, &sextent);
+ sdtype->extent(&strue_lb, &strue_extent);
+ rdtype->extent(&rlb, &rextent);
+ rdtype->extent(&rtrue_lb, &rtrue_extent);
vrank = (rank - root + size) % size;
ptmp = (char *) sbuf;
if (rbuf != MPI_IN_PLACE) {
/* local copy to rbuf */
- err = smpi_datatype_copy(sbuf, scount, sdtype,
+ err = Datatype::copy(sbuf, scount, sdtype,
rbuf, rcount, rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
}
ptmp = tempbuf - slb;
/* and rotate data so they will eventually in the right place */
- err = smpi_datatype_copy((char *) sbuf + sextent*root*scount, scount*(size-root), sdtype,
+ err = Datatype::copy((char *) sbuf + sextent*root*scount, scount*(size-root), sdtype,
ptmp, scount*(size-root), sdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
- err = smpi_datatype_copy((char*)sbuf, scount*root, sdtype,
+ err = Datatype::copy((char*)sbuf, scount*root, sdtype,
ptmp + sextent*scount*(size - root), scount*root, sdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
if (rbuf != MPI_IN_PLACE) {
/* local copy to rbuf */
- err = smpi_datatype_copy(ptmp, scount, sdtype,
+ err = Datatype::copy(ptmp, scount, sdtype,
rbuf, rcount, rdtype);
if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
}
Request::recv(ptmp, rcount*size, rdtype, bmtree->tree_prev,
COLL_TAG_SCATTER, comm, &status);
/* local copy to rbuf */
- smpi_datatype_copy(ptmp, scount, sdtype, rbuf, rcount, rdtype);
+ Datatype::copy(ptmp, scount, sdtype, rbuf, rcount, rdtype);
}
/* send to children on all non-leaf */
for (i = 0; i < bmtree->tree_nextsize; i++) {
/* I am the root, loop sending data. */
- err = smpi_datatype_extent(sdtype, &lb, &incr);
+ err = sdtype->extent(&lb, &incr);
if (MPI_SUCCESS != err) {
return MPI_ERR_OTHER;
}
if (i == rank) {
if (MPI_IN_PLACE != rbuf) {
err =
- smpi_datatype_copy(ptmp, scount, sdtype, rbuf, rcount,
+ Datatype::copy(ptmp, scount, sdtype, rbuf, rcount,
rdtype);
}
} else {
for (i = 0; i < comm_size; i++) { \
total_message_size += rcounts[i];\
}\
- size_t block_dsize = total_message_size*smpi_datatype_size(dtype);\
+ size_t block_dsize = total_message_size*dtype->size();\
#define SIZECOMP_allreduce\
- size_t block_dsize =rcount * smpi_datatype_size(dtype);
+ size_t block_dsize =rcount * dtype->size();
#define SIZECOMP_alltoall\
- size_t block_dsize =send_count * smpi_datatype_size(send_type);
+ size_t block_dsize =send_count * send_type->size();
#define SIZECOMP_bcast\
- size_t block_dsize =count * smpi_datatype_size(datatype);
+ size_t block_dsize =count * datatype->size();
#define SIZECOMP_reduce\
- size_t block_dsize =count * smpi_datatype_size(datatype);
+ size_t block_dsize =count * datatype->size();
#define SIZECOMP_barrier\
size_t block_dsize = 1;
#define SIZECOMP_allgather\
- size_t block_dsize =recv_count * smpi_datatype_size(recv_type);
+ size_t block_dsize =recv_count * recv_type->size();
#define SIZECOMP_allgatherv\
int total_message_size = 0;\
for (i = 0; i < comm_size; i++) { \
total_message_size += recv_count[i];\
}\
- size_t block_dsize = total_message_size*smpi_datatype_size(recv_type);
+ size_t block_dsize = total_message_size*recv_type->size();
#define SIZECOMP_gather\
int rank = comm->rank();\
size_t block_dsize = (send_buff == MPI_IN_PLACE || rank ==root) ?\
- recv_count * smpi_datatype_size(recv_type) :\
- send_count * smpi_datatype_size(send_type);
+ recv_count * recv_type->size() :\
+ send_count * send_type->size();
#define SIZECOMP_scatter\
int rank = comm->rank();\
size_t block_dsize = (sendbuf == MPI_IN_PLACE || rank !=root ) ?\
- recvcount * smpi_datatype_size(recvtype) :\
- sendcount * smpi_datatype_size(sendtype);
+ recvcount * recvtype->size() :\
+ sendcount * sendtype->size();
#define SIZECOMP_alltoallv\
size_t block_dsize = 1;
int comm_size = comm->size();
const size_t large_message = 2048; //MPIR_PARAM_ALLREDUCE_SHORT_MSG_SIZE
- dsize = smpi_datatype_size(dtype);
+ dsize = dtype->size();
block_dsize = dsize * count;
// and sends to (rank+i).
- dsize = smpi_datatype_size(sdtype);
+ dsize = sdtype->size();
block_dsize = dsize * scount;
if ((block_dsize < short_size) && (communicator_size >= 8)) {
communicator_size = comm->size();
/* else we need data size for decision function */
- dsize = smpi_datatype_size(datatype);
+ dsize = datatype->size();
message_size = dsize * (unsigned long)count; /* needed for decision */
/* Handle messages of small and intermediate size, and
communicator_size = comm->size();
/* need data size for decision function */
- dsize=smpi_datatype_size(datatype);
+ dsize=datatype->size();
message_size = dsize * count; /* needed for decision */
int pof2 = 1;
communicator_size = comm->size();
/* Determine complete data size */
- dsize=smpi_datatype_size(sdtype);
+ dsize=sdtype->size();
total_dsize = dsize * scount * communicator_size;
for (pow2_size = 1; pow2_size < communicator_size; pow2_size <<=1);
)
{
if(comm->rank()!=root){
- sbuf=xbt_malloc(rcount*smpi_datatype_get_extent(rdtype));
+ sbuf=xbt_malloc(rcount*rdtype->get_extent());
scount=rcount;
sdtype=rdtype;
}
int conf_index = 0;
comm_size = comm->size();
- sendtype_size=smpi_datatype_size(sendtype);
- recvtype_size=smpi_datatype_size(recvtype);
+ sendtype_size=sendtype->size();
+ recvtype_size=recvtype->size();
long nbytes = sendtype_size * sendcount;
/* check if safe to use partial subscription mode */
||nbytes > mv2_alltoall_thresholds_table[conf_index][range].in_place_algo_table[range_threshold].max
) {
tmp_buf = (char *)smpi_get_tmp_sendbuffer( comm_size * recvcount * recvtype_size );
- mpi_errno = smpi_datatype_copy((char *)recvbuf,
+ mpi_errno = Datatype::copy((char *)recvbuf,
comm_size*recvcount, recvtype,
(char *)tmp_buf,
comm_size*recvcount, recvtype);
//MPI_Comm *shmem_commptr=NULL;
/* Get the size of the communicator */
comm_size = comm->size();
- recvtype_size=smpi_datatype_size(recvtype);
+ recvtype_size=recvtype->size();
nbytes = recvtype_size * recvcount;
if(mv2_allgather_table_ppn_conf==NULL)
rank = comm->rank();
if (rank == root) {
- recvtype_size=smpi_datatype_size(recvtype);
+ recvtype_size=recvtype->size();
nbytes = recvcnt * recvtype_size;
} else {
- sendtype_size=smpi_datatype_size(sendtype);
+ sendtype_size=sendtype->size();
nbytes = sendcnt * sendtype_size;
}
for (i = 0; i < comm_size; i++)
total_count += recvcounts[i];
- recvtype_size=smpi_datatype_size(recvtype);
+ recvtype_size=recvtype->size();
nbytes = total_count * recvtype_size;
/* Search for the corresponding system size inside the tuning table */
int is_commutative = 0;
MPI_Aint true_lb, true_extent;
- sendtype_size=smpi_datatype_size(datatype);
+ sendtype_size=datatype->size();
nbytes = count * sendtype_size;
- smpi_datatype_extent(datatype, &true_lb, &true_extent);
+ datatype->extent(&true_lb, &true_extent);
//MPI_Op *op_ptr;
//is_commutative = op->is_commutative();
* possible, and MPI_Pack_size() in other places.
*/
//if (is_homogeneous) {
- type_size=smpi_datatype_size(datatype);
+ type_size=datatype->size();
/* } else {
MPIR_Pack_size_impl(1, datatype, &type_size);
int is_two_level = 0;
comm_size = comm->size();
- sendtype_size=smpi_datatype_size(datatype);
+ sendtype_size=datatype->size();
nbytes = count * sendtype_size;
if (count == 0)
total_count += recvcnts[i];
}
- type_size=smpi_datatype_size(datatype);
+ type_size=datatype->size();
nbytes = total_count * type_size;
if (is_commutative) {
rank = comm->rank();
if (rank == root) {
- sendtype_size=smpi_datatype_size(sendtype);
+ sendtype_size=sendtype->size();
nbytes = sendcnt * sendtype_size;
} else {
- recvtype_size=smpi_datatype_size(recvtype);
+ recvtype_size=recvtype->size();
nbytes = recvcnt * recvtype_size;
}
* can handle both commutative and non-commutative operations.
* Ring algorithm does not support non-commutative operations.
*/
- dsize = smpi_datatype_size(dtype);
+ dsize = dtype->size();
block_dsize = dsize * count;
if (block_dsize < intermediate_message) {
the University of Tennessee (2GB MX) up to 64 nodes.
Has better performance for messages of intermediate sizes than the old one */
/* determine block size */
- dsize = smpi_datatype_size(sdtype);
+ dsize = sdtype->size();
block_dsize = dsize * scount;
if ((block_dsize < 200) && (communicator_size > 12)) {
communicator_size = comm->size();
/* else we need data size for decision function */
- dsize = smpi_datatype_size(datatype);
+ dsize = datatype->size();
message_size = dsize * (unsigned long)count; /* needed for decision */
/* Handle messages of small and intermediate size, and
communicator_size = comm->size();
/* need data size for decision function */
- dsize=smpi_datatype_size(datatype);
+ dsize=datatype->size();
message_size = dsize * count; /* needed for decision */
/**
comm_size = comm->size();
// We need data size for decision function
- dsize=smpi_datatype_size(dtype);
+ dsize=dtype->size();
total_message_size = 0;
for (i = 0; i < comm_size; i++) {
total_message_size += rcounts[i];
}
/* Determine complete data size */
- dsize=smpi_datatype_size(sdtype);
+ dsize=sdtype->size();
total_dsize = dsize * scount * communicator_size;
for (pow2_size = 1; pow2_size < communicator_size; pow2_size <<=1);
}
/* Determine complete data size */
- dsize=smpi_datatype_size(sdtype);
+ dsize=sdtype->size();
total_dsize = 0;
for (i = 0; i < communicator_size; i++) {
total_dsize += dsize * rcounts[i];
// Determine block size
if (rank == root) {
- dsize = smpi_datatype_size(rdtype);
+ dsize = rdtype->size();
block_size = dsize * rcount;
} else {
- dsize = smpi_datatype_size(sdtype);
+ dsize = sdtype->size();
block_size = dsize * scount;
}
rank = comm->rank();
// Determine block size
if (root == rank) {
- dsize=smpi_datatype_size(sdtype);
+ dsize=sdtype->size();
block_size = dsize * scount;
} else {
- dsize=smpi_datatype_size(rdtype);
+ dsize=rdtype->size();
block_size = dsize * rcount;
}
if ((communicator_size > small_comm_size) &&
(block_size < small_block_size)) {
if(rank!=root){
- sbuf=xbt_malloc(rcount*smpi_datatype_get_extent(rdtype));
+ sbuf=xbt_malloc(rcount*rdtype->get_extent());
scount=rcount;
sdtype=rdtype;
}
XBT_PRIVATE double smpi_mpi_wtime();
XBT_PRIVATE void smpi_mpi_init();
-XBT_PRIVATE bool is_datatype_valid(MPI_Datatype datatype);
-
-XBT_PRIVATE size_t smpi_datatype_size(MPI_Datatype datatype);
-XBT_PRIVATE MPI_Aint smpi_datatype_lb(MPI_Datatype datatype);
-XBT_PRIVATE MPI_Aint smpi_datatype_ub(MPI_Datatype datatype);
-XBT_PRIVATE int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t);
-XBT_PRIVATE int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent);
-XBT_PRIVATE MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype);
-XBT_PRIVATE void smpi_datatype_get_name(MPI_Datatype datatype, char* name, int* length);
-XBT_PRIVATE void smpi_datatype_set_name(MPI_Datatype datatype, char* name);
-XBT_PRIVATE int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount,
- MPI_Datatype recvtype);
-XBT_PRIVATE void smpi_datatype_use(MPI_Datatype type);
-XBT_PRIVATE void smpi_datatype_unuse(MPI_Datatype type);
-
-XBT_PRIVATE int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type, MPI_Aint lb);
-XBT_PRIVATE int smpi_datatype_vector(int count, int blocklen, int stride, MPI_Datatype old_type,
- MPI_Datatype* new_type);
-
-XBT_PRIVATE int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride,MPI_Datatype old_type,
- MPI_Datatype* new_type);
-XBT_PRIVATE int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type,
- MPI_Datatype* new_type);
-XBT_PRIVATE int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type,
- MPI_Datatype* new_type);
-XBT_PRIVATE int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types,
- MPI_Datatype* new_type);
-
-XBT_PRIVATE void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int sizeof_substruct,
- void *struct_type, int flags);
-
-XBT_PRIVATE void smpi_datatype_free(MPI_Datatype* type);
-XBT_PRIVATE void smpi_datatype_commit(MPI_Datatype* datatype);
-
-XBT_PRIVATE int smpi_mpi_unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type,
- MPI_Comm comm);
-XBT_PRIVATE int smpi_mpi_pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position,
- MPI_Comm comm);
-
XBT_PRIVATE void smpi_empty_status(MPI_Status * status);
XBT_PRIVATE int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
// Send buffer to root
Request::send(sendbuf, sendcount, sendtype, root, system_tag, comm);
} else {
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ recvtype->extent(&lb, &recvext);
// Local copy from root
- smpi_datatype_copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + root * recvcount * recvext,
+ Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + root * recvcount * recvext,
recvcount, recvtype);
// Receive buffers from senders
MPI_Request *requests = xbt_new(MPI_Request, size - 1);
displs[i] = count;
count += recvcounts[i];
}
- void *tmpbuf = static_cast<void*>(smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype)));
+ void *tmpbuf = static_cast<void*>(smpi_get_tmp_sendbuffer(count*datatype->get_extent()));
mpi_coll_reduce_fun(sendbuf, tmpbuf, count, datatype, op, 0, comm);
smpi_mpi_scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm);
// Send buffer to root
Request::send(sendbuf, sendcount, sendtype, root, system_tag, comm);
} else {
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ recvtype->extent(&lb, &recvext);
// Local copy from root
- smpi_datatype_copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + displs[root] * recvext,
+ Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + displs[root] * recvext,
recvcounts[root], recvtype);
// Receive buffers from senders
MPI_Request *requests = xbt_new(MPI_Request, size - 1);
int rank = comm->rank();
int size = comm->size();
// FIXME: check for errors
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ recvtype->extent(&lb, &recvext);
// Local copy from self
- smpi_datatype_copy(sendbuf, sendcount, sendtype, static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount,
+ Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount,
recvtype);
// Send/Recv buffers to/from others;
requests = xbt_new(MPI_Request, 2 * (size - 1));
int rank = comm->rank();
int size = comm->size();
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ recvtype->extent(&lb, &recvext);
// Local copy from self
- smpi_datatype_copy(sendbuf, sendcount, sendtype,
+ Datatype::copy(sendbuf, sendcount, sendtype,
static_cast<char *>(recvbuf) + displs[rank] * recvext,recvcounts[rank], recvtype);
// Send buffers to others;
MPI_Request *requests = xbt_new(MPI_Request, 2 * (size - 1));
// Recv buffer from root
Request::recv(recvbuf, recvcount, recvtype, root, system_tag, comm, MPI_STATUS_IGNORE);
} else {
- smpi_datatype_extent(sendtype, &lb, &sendext);
+ sendtype->extent(&lb, &sendext);
// Local copy from root
if(recvbuf!=MPI_IN_PLACE){
- smpi_datatype_copy(static_cast<char *>(sendbuf) + root * sendcount * sendext,
+ Datatype::copy(static_cast<char *>(sendbuf) + root * sendcount * sendext,
sendcount, sendtype, recvbuf, recvcount, recvtype);
}
// Send buffers to receivers
// Recv buffer from root
Request::recv(recvbuf, recvcount, recvtype, root, system_tag, comm, MPI_STATUS_IGNORE);
} else {
- smpi_datatype_extent(sendtype, &lb, &sendext);
+ sendtype->extent(&lb, &sendext);
// Local copy from root
if(recvbuf!=MPI_IN_PLACE){
- smpi_datatype_copy(static_cast<char *>(sendbuf) + displs[root] * sendext, sendcounts[root],
+ Datatype::copy(static_cast<char *>(sendbuf) + displs[root] * sendext, sendcounts[root],
sendtype, recvbuf, recvcount, recvtype);
}
// Send buffers to receivers
}
if( sendbuf == MPI_IN_PLACE ) {
- sendtmpbuf = static_cast<char *>(smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype)));
- smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
+ sendtmpbuf = static_cast<char *>(smpi_get_tmp_sendbuffer(count*datatype->get_extent()));
+ Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
}
if(rank != root) {
// Send buffer to root
Request::send(sendtmpbuf, count, datatype, root, system_tag, comm);
} else {
- smpi_datatype_extent(datatype, &lb, &dataext);
+ datatype->extent(&lb, &dataext);
// Local copy from root
if (sendtmpbuf != nullptr && recvbuf != nullptr)
- smpi_datatype_copy(sendtmpbuf, count, datatype, recvbuf, count, datatype);
+ Datatype::copy(sendtmpbuf, count, datatype, recvbuf, count, datatype);
// Receive buffers from senders
MPI_Request *requests = xbt_new(MPI_Request, size - 1);
void **tmpbufs = xbt_new(void *, size - 1);
int rank = comm->rank();
int size = comm->size();
- smpi_datatype_extent(datatype, &lb, &dataext);
+ datatype->extent(&lb, &dataext);
// Local copy from self
- smpi_datatype_copy(sendbuf, count, datatype, recvbuf, count, datatype);
+ Datatype::copy(sendbuf, count, datatype, recvbuf, count, datatype);
// Send/Recv buffers to/from others;
MPI_Request *requests = xbt_new(MPI_Request, size - 1);
int rank = comm->rank();
int size = comm->size();
- smpi_datatype_extent(datatype, &lb, &dataext);
+ datatype->extent(&lb, &dataext);
// Send/Recv buffers to/from others;
MPI_Request *requests = xbt_new(MPI_Request, size - 1);
}
if(index < rank) {
if(recvbuf_is_empty){
- smpi_datatype_copy(tmpbufs[index], count, datatype, recvbuf, count, datatype);
+ Datatype::copy(tmpbufs[index], count, datatype, recvbuf, count, datatype);
recvbuf_is_empty=0;
} else
// #Request is below rank: it's a irecv
Request::wait(&(requests[other]), MPI_STATUS_IGNORE);
if(index < rank) {
if (recvbuf_is_empty) {
- smpi_datatype_copy(tmpbufs[other], count, datatype, recvbuf, count, datatype);
+ Datatype::copy(tmpbufs[other], count, datatype, recvbuf, count, datatype);
recvbuf_is_empty = 0;
} else
if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, datatype);
int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype)
{
- return status->count / smpi_datatype_size(datatype);
+ return status->count / datatype->size();
}
int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
{
int size = comm->size();
- int sendsize = smpi_datatype_size(sendtype) * sendcount;
+ int sendsize = sendtype->size() * sendcount;
if (sendsize < 200 && size > 12) {
return smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
} else if (sendsize < 3000) {
int rank = comm->rank();
int size = comm->size();
XBT_DEBUG("<%d> algorithm alltoall_bruck() called.", rank);
- smpi_datatype_extent(sendtype, &lb, &sendext);
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ sendtype->extent(&lb, &sendext);
+ recvtype->extent(&lb, &recvext);
/* Local copy from self */
- int err = smpi_datatype_copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, sendcount, sendtype,
+ int err = Datatype::copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, sendcount, sendtype,
static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount, recvtype);
if (err == MPI_SUCCESS && size > 1) {
/* Initiate all send/recv to/from others. */
int rank = comm->rank();
int size = comm->size();
XBT_DEBUG("<%d> algorithm alltoall_basic_linear() called.", rank);
- smpi_datatype_extent(sendtype, &lb, &sendext);
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ sendtype->extent(&lb, &sendext);
+ recvtype->extent(&lb, &recvext);
/* simple optimization */
- int err = smpi_datatype_copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, sendcount, sendtype,
+ int err = Datatype::copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, sendcount, sendtype,
static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount, recvtype);
if (err == MPI_SUCCESS && size > 1) {
/* Initiate all send/recv to/from others. */
int rank = comm->rank();
int size = comm->size();
XBT_DEBUG("<%d> algorithm basic_alltoallv() called.", rank);
- smpi_datatype_extent(sendtype, &lb, &sendext);
- smpi_datatype_extent(recvtype, &lb, &recvext);
+ sendtype->extent(&lb, &sendext);
+ recvtype->extent(&lb, &recvext);
/* Local copy from self */
- int err = smpi_datatype_copy(static_cast<char *>(sendbuf) + senddisps[rank] * sendext, sendcounts[rank], sendtype,
+ int err = Datatype::copy(static_cast<char *>(sendbuf) + senddisps[rank] * sendext, sendcounts[rank], sendtype,
static_cast<char *>(recvbuf) + recvdisps[rank] * recvext, recvcounts[rank], recvtype);
if (err == MPI_SUCCESS && size > 1) {
/* Initiate all send/recv to/from others. */
#include <simgrid/s4u/host.hpp>
#include "private.h"
-#include "smpi_mpi_dt_private.h"
#include "src/simix/smx_private.h"
#include "colls/colls.h"
#include "mc/mc.h"
#include "private.h"
#include "simgrid/modelchecker.h"
-#include "smpi_mpi_dt_private.h"
#include "xbt/replay.h"
#include <limits.h>
#include <stdio.h>
//TODO : subtypes ?
-Datatype::Datatype(Datatype &datatype) : lb_(datatype.lb_), ub_(datatype.ub_), flags_(datatype.flags_), in_use_(1)
+Datatype::Datatype(Datatype *datatype) : lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_), in_use_(1)
{
flags_ &= ~DT_FLAG_PREDEFINED;
- if(datatype.name_)
- name_ = xbt_strdup(datatype.name_);
- if(datatype.attributes_ !=nullptr){
+ if(datatype->name_)
+ name_ = xbt_strdup(datatype->name_);
+ if(datatype->attributes_ !=nullptr){
attributes_ = xbt_dict_new_homogeneous(nullptr);
xbt_dict_cursor_t cursor = nullptr;
char* key;
int flag;
void* value_in;
void* value_out;
- xbt_dict_foreach (datatype.attributes_, cursor, key, value_in) {
+ xbt_dict_foreach (datatype->attributes_, cursor, key, value_in) {
smpi_type_key_elem elem =
static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, key, sizeof(int)));
if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
- int ret = elem->copy_fn(&datatype, atoi(key), nullptr, value_in, &value_out, &flag);
+ int ret = elem->copy_fn(datatype, atoi(key), nullptr, value_in, &value_out, &flag);
if (ret != MPI_SUCCESS) {
// smpi_datatype_unuse(*new_t);
// *new_t = MPI_DATATYPE_NULL;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
void * value = nullptr;
int flag;
- if(smpi_type_attr_get(this, keyval, &value, &flag)==MPI_SUCCESS){
+ if(this->attr_get(keyval, &value, &flag)==MPI_SUCCESS){
int ret = elem->delete_fn(this, keyval, value, &flag);
if(ret!=MPI_SUCCESS)
return ret;
return MPI_ERR_ARG;
int flag;
void* value = nullptr;
- smpi_type_attr_get(this, keyval, &value, &flag);
+ this->attr_get(keyval, &value, &flag);
if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){
int ret = elem->delete_fn(this, keyval, value, &flag);
if(ret!=MPI_SUCCESS)
// }
// else if (sendtype->sizeof_substruct == 0)
// {
-// s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(recvtype->substruct);
-// subtype->unserialize( sendbuf, recvbuf, recvcount/smpi_datatype_size(recvtype), subtype, MPI_REPLACE);
+// s_smpi_subtype_t *subtype = recvtype->substruct);
+// subtype->unserialize( sendbuf, recvbuf, recvcount/recvtype->size(), subtype, MPI_REPLACE);
// }
// else if (recvtype->sizeof_substruct == 0)
// {
-// s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(sendtype->substruct);
-// subtype->serialize(sendbuf, recvbuf, sendcount/smpi_datatype_size(sendtype), subtype);
+// s_smpi_subtype_t *subtype = sendtype->substruct);
+// subtype->serialize(sendbuf, recvbuf, sendcount/sendtype->size(), subtype);
// }else{
-// s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(sendtype->substruct);
+// s_smpi_subtype_t *subtype = sendtype->substruct);
// void * buf_tmp = xbt_malloc(count);
-// subtype->serialize( sendbuf, buf_tmp,count/smpi_datatype_size(sendtype), subtype);
-// subtype = static_cast<s_smpi_subtype_t*>(recvtype->substruct);
-// subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype, MPI_REPLACE);
+// subtype->serialize( sendbuf, buf_tmp,count/sendtype->size(), subtype);
+// subtype = recvtype->substruct);
+// subtype->unserialize( buf_tmp, recvbuf,count/recvtype->size(), subtype, MPI_REPLACE);
// xbt_free(buf_tmp);
// }
}
//Default serialization method : memcpy.
-void Datatype::serialize( void* noncontiguous, void *contiguous, int count, void *type){
- char* contiguous_char = static_cast<char*>(contiguous);
- char* noncontiguous_char = static_cast<char*>(noncontiguous)+lb_;
- memcpy(contiguous_char, noncontiguous_char, count*size_);
+void Datatype::serialize( void* noncontiguous_buf, void *contiguous_buf, int count){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, count*size_);
}
-void Datatype::unserialize( void* contiguous, void *noncontiguous, int count, void *type, MPI_Op op){
- char* contiguous_char = static_cast<char*>(contiguous);
- char* noncontiguous_char = static_cast<char*>(noncontiguous)+lb_;
+void Datatype::unserialize( void* contiguous_buf, void *noncontiguous_buf, int count, MPI_Op op){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
int n=count;
if(op!=MPI_OP_NULL)
- op->apply( contiguous_char, noncontiguous_char, &n, this);
+ op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, this);
}
+int Datatype::create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type){
+ if(old_type->flags_ & DT_FLAG_DERIVED){
+ //handle this case as a hvector with stride equals to the extent of the datatype
+ return create_hvector(count, 1, old_type->get_extent(), old_type, new_type);
+ }
+ if(count>0)
+ *new_type = new Type_Contiguous(count * old_type->size(), lb, lb + count * old_type->size(),
+ DT_FLAG_DERIVED, count, old_type);
+ else
+ *new_type = new Datatype(count * old_type->size(), lb, lb + count * old_type->size(),0);
+ return MPI_SUCCESS;
+}
+
+int Datatype::create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type)
+{
+ int retval;
+ if (blocklen<0)
+ return MPI_ERR_ARG;
+ MPI_Aint lb = 0;
+ MPI_Aint ub = 0;
+ if(count>0){
+ lb=old_type->lb();
+ ub=((count-1)*stride+blocklen-1)*old_type->get_extent()+old_type->ub();
+ }
+ if(old_type->flags() & DT_FLAG_DERIVED || stride != blocklen){
+ *new_type = new Type_Vector(count * (blocklen) * old_type->size(), lb, ub,
+ DT_FLAG_DERIVED, count, blocklen, stride, old_type);
+ retval=MPI_SUCCESS;
+ }else{
+ /* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/
+ *new_type = new Datatype(count * blocklen * old_type->size(), 0, ((count -1) * stride + blocklen)*
+ old_type->size(), DT_FLAG_CONTIGUOUS);
+ retval=MPI_SUCCESS;
+ }
+ return retval;
+}
+
+
+int Datatype::create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type)
+{
+ int retval;
+ if (blocklen<0)
+ return MPI_ERR_ARG;
+ MPI_Aint lb = 0;
+ MPI_Aint ub = 0;
+ if(count>0){
+ lb=old_type->lb();
+ ub=((count-1)*stride+blocklen-1)*old_type->get_extent()+old_type->ub();
+ }
+ if(old_type->flags() & DT_FLAG_DERIVED || stride != blocklen*old_type->get_extent()){
+ *new_type = new Type_Hvector(count * (blocklen) * old_type->size(), lb, ub,
+ DT_FLAG_DERIVED, count, blocklen, stride, old_type);
+ retval=MPI_SUCCESS;
+ }else{
+ /* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/
+ *new_type = new Datatype(count * blocklen * old_type->size(), 0, count * blocklen * old_type->size(), DT_FLAG_CONTIGUOUS);
+ retval=MPI_SUCCESS;
+ }
+ return retval;
+}
+
+int Datatype::create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type){
+ int size = 0;
+ bool contiguous=true;
+ MPI_Aint lb = 0;
+ MPI_Aint ub = 0;
+ if(count>0){
+ lb=indices[0]*old_type->get_extent();
+ ub=indices[0]*old_type->get_extent() + blocklens[0]*old_type->ub();
+ }
+
+ for (int i = 0; i < count; i++) {
+ if (blocklens[i] < 0)
+ return MPI_ERR_ARG;
+ size += blocklens[i];
+
+ if(indices[i]*old_type->get_extent()+old_type->lb()<lb)
+ lb = indices[i]*old_type->get_extent()+old_type->lb();
+ if(indices[i]*old_type->get_extent()+blocklens[i]*old_type->ub()>ub)
+ ub = indices[i]*old_type->get_extent()+blocklens[i]*old_type->ub();
+
+ if ( (i< count -1) && (indices[i]+blocklens[i] != indices[i+1]) )
+ contiguous=false;
+ }
+ if(old_type->flags_ & DT_FLAG_DERIVED)
+ contiguous=false;
+
+ if(!contiguous){
+ *new_type = new Type_Indexed(size * old_type->size(),lb,ub,
+ DT_FLAG_DERIVED|DT_FLAG_DATA, count, blocklens, indices, old_type);
+ }else{
+ *new_type = new Type_Contiguous(size * old_type->size(), lb, ub,
+ DT_FLAG_DERIVED|DT_FLAG_CONTIGUOUS, size, old_type);
+ }
+ return MPI_SUCCESS;
+}
+
+int Datatype::create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type){
+ int size = 0;
+ bool contiguous=true;
+ MPI_Aint lb = 0;
+ MPI_Aint ub = 0;
+ if(count>0){
+ lb=indices[0] + old_type->lb();
+ ub=indices[0] + blocklens[0]*old_type->ub();
+ }
+ for (int i = 0; i < count; i++) {
+ if (blocklens[i] < 0)
+ return MPI_ERR_ARG;
+ size += blocklens[i];
+
+ if(indices[i]+old_type->lb()<lb)
+ lb = indices[i]+old_type->lb();
+ if(indices[i]+blocklens[i]*old_type->ub()>ub)
+ ub = indices[i]+blocklens[i]*old_type->ub();
+
+ if ( (i< count -1) && (indices[i]+blocklens[i]*(static_cast<int>(old_type->size())) != indices[i+1]) )
+ contiguous=false;
+ }
+ if (old_type->flags_ & DT_FLAG_DERIVED || lb!=0)
+ contiguous=false;
+
+ if(!contiguous){
+ *new_type = new Type_Hindexed(size * old_type->size(),lb,ub,
+ DT_FLAG_DERIVED|DT_FLAG_DATA, count, blocklens, indices, old_type);
+ }else{
+ *new_type = new Type_Contiguous(size * old_type->size(), lb, ub,
+ DT_FLAG_DERIVED|DT_FLAG_CONTIGUOUS, size, old_type);
+ }
+ return MPI_SUCCESS;
+}
+
+int Datatype::create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type){
+ size_t size = 0;
+ bool contiguous=true;
+ size = 0;
+ MPI_Aint lb = 0;
+ MPI_Aint ub = 0;
+ if(count>0){
+ lb=indices[0] + old_types[0]->lb();
+ ub=indices[0] + blocklens[0]*old_types[0]->ub();
+ }
+ bool forced_lb=false;
+ bool forced_ub=false;
+ for (int i = 0; i < count; i++) {
+ if (blocklens[i]<0)
+ return MPI_ERR_ARG;
+ if (old_types[i]->flags_ & DT_FLAG_DERIVED)
+ contiguous=false;
+
+ size += blocklens[i]*old_types[i]->size();
+ if (old_types[i]==MPI_LB){
+ lb=indices[i];
+ forced_lb=true;
+ }
+ if (old_types[i]==MPI_UB){
+ ub=indices[i];
+ forced_ub=true;
+ }
+
+ if(!forced_lb && indices[i]+old_types[i]->lb()<lb)
+ lb = indices[i];
+ if(!forced_ub && indices[i]+blocklens[i]*old_types[i]->ub()>ub)
+ ub = indices[i]+blocklens[i]*old_types[i]->ub();
+
+ if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast<int>(old_types[i]->size()) != indices[i+1]) )
+ contiguous=false;
+ }
+ if(!contiguous){
+ *new_type = new Type_Struct(size, lb,ub, DT_FLAG_DERIVED|DT_FLAG_DATA,
+ count, blocklens, indices, old_types);
+ }else{
+ *new_type = new Type_Contiguous(size, lb, ub,
+ DT_FLAG_DERIVED|DT_FLAG_CONTIGUOUS, size, MPI_CHAR);
+ }
+ return MPI_SUCCESS;
+}
+
+
+
+Type_Contiguous::Type_Contiguous(int size, int lb, int ub, int flags, int block_count, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(block_count), old_type_(old_type){
+ old_type_->use();
+}
+
+Type_Contiguous::~Type_Contiguous(){
+ old_type_->unuse();
+}
+
+void Type_Contiguous::use(){
+ old_type_->use();
+};
+
+void Type_Contiguous::serialize( void* noncontiguous_buf, void *contiguous_buf,
+ int count){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, count * block_count_ * old_type_->size());
+}
+void Type_Contiguous::unserialize( void* contiguous_buf, void *noncontiguous_buf,
+ int count, MPI_Op op){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+ int n= count*block_count_;
+ if(op!=MPI_OP_NULL)
+ op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, old_type_);
+}
+
+
+
+
+Type_Vector::Type_Vector(int size,int lb, int ub, int flags, int count, int blocklen, int stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(blocklen),block_stride_(stride), old_type_(old_type){
+old_type_->use();
+}
+
+Type_Vector::~Type_Vector(){
+ old_type_->unuse();
+}
+
+void Type_Vector::use(){
+ old_type_->use();
+}
+
+
+void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf,
+ int count){
+ int i;
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
+
+ for (i = 0; i < block_count_ * count; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED))
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size());
+ else
+ old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char, block_length_);
+ contiguous_buf_char += block_length_*old_type_->size();
+ if((i+1)%block_count_ ==0)
+ noncontiguous_buf_char += block_length_*old_type_->get_extent();
+ else
+ noncontiguous_buf_char += block_stride_*old_type_->get_extent();
+ }
+}
+
+void Type_Vector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
+ int count, MPI_Op op){
+ int i;
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
+
+ for (i = 0; i < block_count_ * count; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED)){
+ if(op != MPI_OP_NULL)
+ op->apply(contiguous_buf_char, noncontiguous_buf_char, &block_length_,
+ old_type_);
+ }else
+ old_type_->unserialize(contiguous_buf_char, noncontiguous_buf_char, block_length_, op);
+
+ contiguous_buf_char += block_length_*old_type_->size();
+ if((i+1)%block_count_ ==0)
+ noncontiguous_buf_char += block_length_*old_type_->get_extent();
+ else
+ noncontiguous_buf_char += block_stride_*old_type_->get_extent();
+ }
+}
+
+Type_Hvector::Type_Hvector(int size,int lb, int ub, int flags, int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(blocklen), block_stride_(stride), old_type_(old_type){
+ old_type->use();
+}
+Type_Hvector::~Type_Hvector(){
+ old_type_->unuse();
+}
+void Type_Hvector::use(){
+ old_type_->use();
+}
+
+void Type_Hvector::serialize( void* noncontiguous_buf, void *contiguous_buf,
+ int count){
+ int i;
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
+
+ for (i = 0; i < block_count_ * count; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED))
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size());
+ else
+ old_type_->serialize( noncontiguous_buf_char, contiguous_buf_char, block_length_);
+
+ contiguous_buf_char += block_length_*old_type_->size();
+ if((i+1)%block_count_ ==0)
+ noncontiguous_buf_char += block_length_*old_type_->size();
+ else
+ noncontiguous_buf_char += block_stride_;
+ }
+}
+
+
+void Type_Hvector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
+ int count, MPI_Op op){
+ int i;
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
+
+ for (i = 0; i < block_count_ * count; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED)){
+ if(op!=MPI_OP_NULL)
+ op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_length_, old_type_);
+ }else
+ old_type_->unserialize( contiguous_buf_char, noncontiguous_buf_char, block_length_, op);
+ contiguous_buf_char += block_length_*old_type_->size();
+ if((i+1)%block_count_ ==0)
+ noncontiguous_buf_char += block_length_*old_type_->size();
+ else
+ noncontiguous_buf_char += block_stride_;
+ }
+}
+
+Type_Indexed::Type_Indexed(int size,int lb, int ub, int flags, int count, int* blocklens, int* indices, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_lengths_(blocklens), block_indices_(indices), old_type_(old_type){
+ old_type->use();
+}
+
+Type_Indexed::~Type_Indexed(){
+ old_type_->unuse();
+ if(in_use_==0){
+ xbt_free(block_lengths_);
+ xbt_free(block_indices_);
+ }
+}
+
+void Type_Indexed::use(){
+ old_type_->use();
+}
+
+void Type_Indexed::serialize( void* noncontiguous_buf, void *contiguous_buf,
+ int count){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+block_indices_[0] * old_type_->size();
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < block_count_; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED))
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_type_->size());
+ else
+ old_type_->serialize( noncontiguous_buf_char, contiguous_buf_char, block_lengths_[i]);
+
+ contiguous_buf_char += block_lengths_[i]*old_type_->size();
+ if (i<block_count_-1)
+ noncontiguous_buf_char =
+ static_cast<char*>(noncontiguous_buf) + block_indices_[i+1]*old_type_->get_extent();
+ else
+ noncontiguous_buf_char += block_lengths_[i]*old_type_->get_extent();
+ }
+ noncontiguous_buf=static_cast< void*>(noncontiguous_buf_char);
+ }
+}
+
+
+void Type_Indexed::unserialize( void* contiguous_buf, void *noncontiguous_buf,
+ int count, MPI_Op op){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char =
+ static_cast<char*>(noncontiguous_buf)+block_indices_[0]*old_type_->get_extent();
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < block_count_; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED)){
+ if(op!=MPI_OP_NULL)
+ op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i],
+ old_type_);
+ }else
+ old_type_->unserialize( contiguous_buf_char,noncontiguous_buf_char,block_lengths_[i], op);
+
+ contiguous_buf_char += block_lengths_[i]*old_type_->size();
+ if (i<block_count_-1)
+ noncontiguous_buf_char =
+ static_cast<char*>(noncontiguous_buf) + block_indices_[i+1]*old_type_->get_extent();
+ else
+ noncontiguous_buf_char += block_lengths_[i]*old_type_->get_extent();
+ }
+ noncontiguous_buf=static_cast<void*>(noncontiguous_buf_char);
+ }
+}
+
+Type_Hindexed::Type_Hindexed(int size,int lb, int ub, int flags, int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_lengths_(blocklens), block_indices_(indices), old_type_(old_type){
+ old_type_->use();
+}
+
+ Type_Hindexed::~Type_Hindexed(){
+ old_type_->unuse();
+ if(in_use_==0){
+ xbt_free(block_lengths_);
+ xbt_free(block_indices_);
+ }
+}
+
+void Type_Hindexed::use(){
+ old_type_->use();
+}
+void Type_Hindexed::serialize( void* noncontiguous_buf, void *contiguous_buf,
+ int count){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+ block_indices_[0];
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < block_count_; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED))
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_type_->size());
+ else
+ old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char,block_lengths_[i]);
+
+ contiguous_buf_char += block_lengths_[i]*old_type_->size();
+ if (i<block_count_-1)
+ noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf) + block_indices_[i+1];
+ else
+ noncontiguous_buf_char += block_lengths_[i]*old_type_->get_extent();
+ }
+ noncontiguous_buf=static_cast<void*>(noncontiguous_buf_char);
+ }
+}
+
+void Type_Hindexed::unserialize( void* contiguous_buf, void *noncontiguous_buf,
+ int count, MPI_Op op){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+ block_indices_[0];
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < block_count_; i++) {
+ if (!(old_type_->flags() & DT_FLAG_DERIVED)){
+ if(op!=MPI_OP_NULL)
+ op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i],
+ old_type_);
+ }else
+ old_type_->unserialize( contiguous_buf_char,noncontiguous_buf_char,block_lengths_[i], op);
+
+ contiguous_buf_char += block_lengths_[i]*old_type_->size();
+ if (i<block_count_-1)
+ noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf) + block_indices_[i+1];
+ else
+ noncontiguous_buf_char += block_lengths_[i]*old_type_->get_extent();
+ }
+ noncontiguous_buf=static_cast<void*>(noncontiguous_buf_char);
+ }
+}
+
+Type_Struct::Type_Struct(int size,int lb, int ub, int flags, int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types): Datatype(size, lb, ub, flags), block_count_(count), block_lengths_(blocklens), block_indices_(indices), old_types_(old_types){
+ for (int i = 0; i < count; i++) {
+ old_types_[i]->use();
+ }
+}
+
+Type_Struct::~Type_Struct(){
+ for (int i = 0; i < block_count_; i++) {
+ old_types_[i]->unuse();
+ }
+ if(in_use_==0){
+ xbt_free(block_lengths_);
+ xbt_free(block_indices_);
+ xbt_free(old_types_);
+ }
+}
+
+void Type_Struct::use(){
+ for (int i = 0; i < block_count_; i++) {
+ old_types_[i]->use();
+ }
+}
+
+void Type_Struct::serialize( void* noncontiguous_buf, void *contiguous_buf,
+ int count){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+ block_indices_[0];
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < block_count_; i++) {
+ if (!(old_types_[i]->flags() & DT_FLAG_DERIVED))
+ memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_types_[i]->size());
+ else
+ old_types_[i]->serialize( noncontiguous_buf_char,contiguous_buf_char,block_lengths_[i]);
+
+
+ contiguous_buf_char += block_lengths_[i]*old_types_[i]->size();
+ if (i<block_count_-1)
+ noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf) + block_indices_[i+1];
+ else //let's hope this is MPI_UB ?
+ noncontiguous_buf_char += block_lengths_[i]*old_types_[i]->get_extent();
+ }
+ noncontiguous_buf=static_cast<void*>(noncontiguous_buf_char);
+ }
+}
+
+void Type_Struct::unserialize( void* contiguous_buf, void *noncontiguous_buf,
+ int count, MPI_Op op){
+ char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
+ char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+ block_indices_[0];
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < block_count_; i++) {
+ if (!(old_types_[i]->flags() & DT_FLAG_DERIVED)){
+ if(op!=MPI_OP_NULL)
+ op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i], old_types_[i]);
+ }else
+ old_types_[i]->unserialize( contiguous_buf_char, noncontiguous_buf_char,block_lengths_[i], op);
+
+ contiguous_buf_char += block_lengths_[i]*old_types_[i]->size();
+ if (i<block_count_-1)
+ noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf) + block_indices_[i+1];
+ else
+ noncontiguous_buf_char += block_lengths_[i]*old_types_[i]->get_extent();
+ }
+ noncontiguous_buf=reinterpret_cast<void*>(noncontiguous_buf_char);
+ }
+}
}
}
#define DT_FLAG_DATA 0x0100 /**< data or control structure */
#define DT_FLAG_ONE_SIDED 0x0200 /**< datatype can be used for one sided operations */
#define DT_FLAG_UNAVAILABLE 0x0400 /**< datatypes unavailable on the build (OS or compiler dependant) */
-#define DT_FLAG_VECTOR 0x0800 /**< valid only for loops. The loop contain only one element
- **< without extent. It correspond to the vector type. */
+#define DT_FLAG_DERIVED 0x0800 /**< is the datatype derived ? */
/*
* We should make the difference here between the predefined contiguous and non contiguous
* datatypes. The DT_FLAG_BASIC is held by all predefined contiguous datatypes.
*/
#define DT_FLAG_BASIC (DT_FLAG_PREDEFINED | DT_FLAG_CONTIGUOUS | DT_FLAG_NO_GAPS | DT_FLAG_DATA | DT_FLAG_COMMITED)
+extern const MPI_Datatype MPI_PTR;
+
+//The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
+typedef struct {
+ float value;
+ int index;
+} float_int;
+typedef struct {
+ float value;
+ float index;
+} float_float;
+typedef struct {
+ long value;
+ long index;
+} long_long;
+typedef struct {
+ double value;
+ double index;
+} double_double;
+typedef struct {
+ long value;
+ int index;
+} long_int;
+typedef struct {
+ double value;
+ int index;
+} double_int;
+typedef struct {
+ short value;
+ int index;
+} short_int;
+typedef struct {
+ int value;
+ int index;
+} int_int;
+typedef struct {
+ long double value;
+ int index;
+} long_double_int;
+typedef struct {
+ int64_t value;
+ int64_t index;
+} integer128_t;
+
+
namespace simgrid{
namespace smpi{
public:
Datatype(int size,int lb, int ub, int flags);
Datatype(char* name, int size,int lb, int ub, int flags);
- Datatype(Datatype &datatype);
- ~Datatype();
+ Datatype(Datatype *datatype);
+ virtual ~Datatype();
void use();
void unuse();
void commit();
void set_name(char* name);
static int copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype);
- virtual void serialize( void* noncontiguous_vector, void *contiguous_vector,
- int count, void *type);
- virtual void unserialize( void* contiguous_vector, void *noncontiguous_vector,
- int count, void *type, MPI_Op op);
+ virtual void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ virtual void unserialize( void* contiguous, void *noncontiguous,
+ int count, MPI_Op op);
int attr_delete(int keyval);
int attr_get(int keyval, void* attr_value, int* flag);
int attr_put(int keyval, void* attr_value);
static int keyval_free(int* keyval);
int pack(void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm comm);
int unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm comm);
+
+
+ static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
+ static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
+ static int create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type);
+ static int create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type);
+ static int create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type);
+ static int create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type);
};
-class Type_Contiguous:Datatype{
+class Type_Contiguous: public Datatype{
+ private:
+ int block_count_;
+ MPI_Datatype old_type_;
+ public:
+ Type_Contiguous(int size, int lb, int ub, int flags, int block_count, MPI_Datatype old_type);
+ ~Type_Contiguous();
+ void use();
+ void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ void unserialize( void* contiguous_vector, void *noncontiguous_vector,
+ int count, MPI_Op op);
};
-class Type_Vector:Datatype{
+class Type_Vector: public Datatype{
+ private:
+ int block_count_;
+ int block_length_;
+ int block_stride_;
+ MPI_Datatype old_type_;
+ public:
+ Type_Vector(int size,int lb, int ub, int flags, int count, int blocklen, int stride, MPI_Datatype old_type);
+ ~Type_Vector();
+ void use();
+ void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ void unserialize( void* contiguous_vector, void *noncontiguous_vector,
+ int count, MPI_Op op);
};
-class Type_Hvector:Datatype{
+class Type_Hvector: public Datatype{
+ private:
+ int block_count_;
+ int block_length_;
+ MPI_Aint block_stride_;
+ MPI_Datatype old_type_;
+ public:
+ Type_Hvector(int size,int lb, int ub, int flags, int block_count, int block_length, MPI_Aint block_stride, MPI_Datatype old_type);
+ ~Type_Hvector();
+ void use();
+ void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ void unserialize( void* contiguous_vector, void *noncontiguous_vector,
+ int count, MPI_Op op);
};
-class Type_Indexed:Datatype{
+class Type_Indexed: public Datatype{
+ private:
+ int block_count_;
+ int* block_lengths_;
+ int* block_indices_;
+ MPI_Datatype old_type_;
+ public:
+ Type_Indexed(int size,int lb, int ub, int flags, int block_count, int* block_lengths, int* block_indices, MPI_Datatype old_type);
+ ~Type_Indexed();
+ void use();
+ void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ void unserialize( void* contiguous_vector, void *noncontiguous_vector,
+ int count, MPI_Op op);
};
-class Type_Hindexed:Datatype{
+class Type_Hindexed: public Datatype{
+ private:
+ int block_count_;
+ int* block_lengths_;
+ MPI_Aint* block_indices_;
+ MPI_Datatype old_type_;
+ public:
+ Type_Hindexed(int size,int lb, int ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype old_type);
+ ~Type_Hindexed();
+ void use();
+ void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ void unserialize( void* contiguous_vector, void *noncontiguous_vector,
+ int count, MPI_Op op);
};
-class Type_Struct:Datatype{
+class Type_Struct: public Datatype{
+ private:
+ int block_count_;
+ int* block_lengths_;
+ MPI_Aint* block_indices_;
+ MPI_Datatype* old_types_;
+ public:
+ Type_Struct(int size,int lb, int ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype* old_types);
+ ~Type_Struct();
+ void use();
+ void serialize( void* noncontiguous, void *contiguous,
+ int count);
+ void unserialize( void* contiguous_vector, void *noncontiguous_vector,
+ int count, MPI_Op op);
};
#include <limits.h>
#include <stdio.h>
-#include "smpi_mpi_dt_private.h"
#include "private.h"
#include "xbt.h"
#include "private.hpp"
#include "simgrid/s4u/Mailbox.hpp"
#include "simgrid/sg_config.h"
-#include "smpi_mpi_dt_private.h"
#include "src/kernel/activity/SynchroComm.hpp"
#include "src/mc/mc_record.h"
#include "src/mc/mc_replay.h"
+++ /dev/null
-/* smpi_mpi_dt.c -- MPI primitives to handle datatypes */
-/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "mc/mc.h"
-#include "private.h"
-#include "simgrid/modelchecker.h"
-#include "smpi_mpi_dt_private.h"
-#include "xbt/replay.h"
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <string>
-#include <xbt/ex.hpp>
-
-//XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi, "Logging specific to SMPI (datatype)");
-
-//xbt_dict_t smpi_type_keyvals = nullptr;
-//int type_keyval_id=0;//avoid collisions
-
-
-/** Check if the datatype is usable for communications */
-bool is_datatype_valid(MPI_Datatype datatype) {
- return datatype != MPI_DATATYPE_NULL && ((datatype->flags_ & DT_FLAG_COMMITED) != 0);
-}
-
-size_t smpi_datatype_size(MPI_Datatype datatype)
-{
- return datatype->size_;
-}
-
-MPI_Aint smpi_datatype_lb(MPI_Datatype datatype)
-{
- return datatype->lb_;
-}
-
-MPI_Aint smpi_datatype_ub(MPI_Datatype datatype)
-{
- return datatype->ub_;
-}
-
-int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t)
-{
- int ret=MPI_SUCCESS;
- return ret;
-}
-
-int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
-{
- return MPI_SUCCESS;
-}
-
-MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype){
- if(datatype == MPI_DATATYPE_NULL){
- return 0;
- }
- return datatype->ub_ - datatype->lb_;
-}
-
-void smpi_datatype_get_name(MPI_Datatype datatype, char* name, int* length){
- *length = strlen(datatype->name_);
- strncpy(name, datatype->name_, *length+1);
-}
-
-void smpi_datatype_set_name(MPI_Datatype datatype, char* name){
- if(datatype->name_!=nullptr && (datatype->flags_ & DT_FLAG_PREDEFINED) == 0)
- xbt_free(datatype->name_);
- datatype->name_ = xbt_strdup(name);
-}
-
-int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
- void *recvbuf, int recvcount, MPI_Datatype recvtype)
-{
-
- return sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
-}
-
-/*
- * Copies noncontiguous data into contiguous memory.
- * @param contiguous_vector - output vector
- * @param noncontiguous_vector - input vector
- * @param type - pointer containing :
- * - stride - stride of between noncontiguous data
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void serialize_vector( void* noncontiguous_vector, void *contiguous_vector, int count, void *type)
-{
-// s_smpi_mpi_vector_t* type_c = reinterpret_cast<s_smpi_mpi_vector_t*>(type);
-// int i;
-// char* contiguous_vector_char = static_cast<char*>(contiguous_vector);
-// char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector);
-
-// for (i = 0; i < type_c->block_count * count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0)
-// memcpy(contiguous_vector_char, noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
-// else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
-// contiguous_vector_char,
-// type_c->block_length, type_c->old_type->substruct);
-
-// contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
-// if((i+1)%type_c->block_count ==0)
-// noncontiguous_vector_char += type_c->block_length*smpi_datatype_get_extent(type_c->old_type);
-// else
-// noncontiguous_vector_char += type_c->block_stride*smpi_datatype_get_extent(type_c->old_type);
-// }
-}
-
-/*
- * Copies contiguous data into noncontiguous memory.
- * @param noncontiguous_vector - output vector
- * @param contiguous_vector - input vector
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void unserialize_vector( void* contiguous_vector, void *noncontiguous_vector, int count, void *type, MPI_Op op)
-{
-// s_smpi_mpi_vector_t* type_c = reinterpret_cast<s_smpi_mpi_vector_t*>(type);
-// int i;
-
-// char* contiguous_vector_char = static_cast<char*>(contiguous_vector);
-// char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector);
-
-// for (i = 0; i < type_c->block_count * count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0){
-// if(op!=MPI_OP_NULL)
-// op->apply( contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length,
-// &type_c->old_type);
-// }else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize(contiguous_vector_char, noncontiguous_vector_char,
-// type_c->block_length,type_c->old_type->substruct,
-// op);
-// contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
-// if((i+1)%type_c->block_count ==0)
-// noncontiguous_vector_char += type_c->block_length*smpi_datatype_get_extent(type_c->old_type);
-// else
-// noncontiguous_vector_char += type_c->block_stride*smpi_datatype_get_extent(type_c->old_type);
-// }
-}
-
-/* Create a Sub type vector to be able to serialize and unserialize it the structure s_smpi_mpi_vector_t is derived
- * from s_smpi_subtype which required the functions unserialize and serialize */
-s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride, int block_length, int block_count,
- MPI_Datatype old_type, int size_oldtype){
- s_smpi_mpi_vector_t *new_t= xbt_new(s_smpi_mpi_vector_t,1);
- new_t->base.serialize = &serialize_vector;
- new_t->base.unserialize = &unserialize_vector;
- new_t->base.subtype_free = &free_vector;
- new_t->base.subtype_use = &use_vector;
- new_t->block_stride = block_stride;
- new_t->block_length = block_length;
- new_t->block_count = block_count;
- smpi_datatype_use(old_type);
- new_t->old_type = old_type;
- new_t->size_oldtype = size_oldtype;
- return new_t;
-}
-
-void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int sizeof_substruct, void *struct_type,
- int flags){
-// MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1);
-// new_t->name = nullptr;
-// new_t->size = size;
-// new_t->sizeof_substruct = size>0? sizeof_substruct:0;
-// new_t->lb = lb;
-// new_t->ub = ub;
-// new_t->flags = flags;
-// new_t->substruct = struct_type;
-// new_t->in_use=1;
-// new_t->attributes=nullptr;
-// *new_type = new_t;
-
-//#if HAVE_MC
-// if(MC_is_active())
-// MC_ignore(&(new_t->in_use), sizeof(new_t->in_use));
-//#endif
-}
-
-void smpi_datatype_free(MPI_Datatype* type){
-// xbt_assert((*type)->in_use_ >= 0);
-
-// if((*type)->flags & DT_FLAG_PREDEFINED)
-// return;
-
-// //if still used, mark for deletion
-// if((*type)->in_use_!=0){
-// (*type)->flags_ |=DT_FLAG_DESTROYED;
-// return;
-// }
-
-// if((*type)->attributes_ !=nullptr){
-// xbt_dict_cursor_t cursor = nullptr;
-// char* key;
-// void * value;
-// int flag;
-// xbt_dict_foreach((*type)->attributes, cursor, key, value){
-// smpi_type_key_elem elem =
-// static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, key, sizeof(int)));
-// if(elem!=nullptr && elem->delete_fn!=nullptr)
-// elem->delete_fn(*type,*key, value, &flag);
-// }
-// xbt_dict_free(&(*type)->attributes);
-// }
-
-// if ((*type)->sizeof_substruct != 0){
-// //((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
-// xbt_free((*type)->substruct);
-// }
-// xbt_free((*type)->name);
-// xbt_free(*type);
-// *type = MPI_DATATYPE_NULL;
-}
-
-void smpi_datatype_use(MPI_Datatype type){
-
-// if(type == MPI_DATATYPE_NULL)
-// return;
-// type->in_use++;
-
-// if(type->sizeof_substruct!=0){
-// static_cast<s_smpi_subtype_t *>((type)->substruct)->subtype_use(&type);
-// }
-//#if HAVE_MC
-// if(MC_is_active())
-// MC_ignore(&(type->in_use), sizeof(type->in_use));
-//#endif
-}
-
-void smpi_datatype_unuse(MPI_Datatype type)
-{
-// if (type == MPI_DATATYPE_NULL)
-// return;
-
-// if (type->in_use > 0)
-// type->in_use--;
-
-// if(type->sizeof_substruct!=0){
-// static_cast<s_smpi_subtype_t *>((type)->substruct)->subtype_free(&type);
-// }
-
-// if (type->in_use == 0)
-// smpi_datatype_free(&type);
-
-//#if HAVE_MC
-// if(MC_is_active())
-// MC_ignore(&(type->in_use), sizeof(type->in_use));
-//#endif
-}
-
-/*Contiguous Implementation*/
-
-/* Copies noncontiguous data into contiguous memory.
- * @param contiguous_hvector - output hvector
- * @param noncontiguous_hvector - input hvector
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data, in bytes
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void serialize_contiguous( void* noncontiguous_hvector, void *contiguous_hvector, int count, void *type)
-{
- s_smpi_mpi_contiguous_t* type_c = reinterpret_cast<s_smpi_mpi_contiguous_t*>(type);
- char* contiguous_vector_char = static_cast<char*>(contiguous_hvector);
- char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_hvector)+type_c->lb;
- memcpy(contiguous_vector_char, noncontiguous_vector_char, count* type_c->block_count * type_c->size_oldtype);
-}
-/* Copies contiguous data into noncontiguous memory.
- * @param noncontiguous_vector - output hvector
- * @param contiguous_vector - input hvector
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data, in bytes
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void unserialize_contiguous(void* contiguous_vector, void *noncontiguous_vector, int count, void *type, MPI_Op op)
-{
-// s_smpi_mpi_contiguous_t* type_c = reinterpret_cast<s_smpi_mpi_contiguous_t*>(type);
-// char* contiguous_vector_char = static_cast<char*>(contiguous_vector);
-// char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector)+type_c->lb;
-// int n= count* type_c->block_count;
-// if(op!=MPI_OP_NULL)
-// op->apply( contiguous_vector_char, noncontiguous_vector_char, &n, &type_c->old_type);
-}
-
-void free_contiguous(MPI_Datatype* d){
-// smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_contiguous_t*>((*d)->substruct)->old_type);
-}
-
-void use_contiguous(MPI_Datatype* d){
-// smpi_datatype_use(reinterpret_cast<s_smpi_mpi_contiguous_t*>((*d)->substruct)->old_type);
-}
-
-/* Create a Sub type contiguous to be able to serialize and unserialize it the structure s_smpi_mpi_contiguous_t is
- * derived from s_smpi_subtype which required the functions unserialize and serialize */
-s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block_count, MPI_Datatype old_type,
- int size_oldtype){
- if(block_count==0)
- return nullptr;
- s_smpi_mpi_contiguous_t *new_t= xbt_new(s_smpi_mpi_contiguous_t,1);
- new_t->base.serialize = &serialize_contiguous;
- new_t->base.unserialize = &unserialize_contiguous;
- new_t->base.subtype_free = &free_contiguous;
- new_t->base.subtype_use = &use_contiguous;
- new_t->lb = lb;
- new_t->block_count = block_count;
- new_t->old_type = old_type;
- smpi_datatype_use(old_type);
- new_t->size_oldtype = size_oldtype;
- smpi_datatype_use(old_type);
- return new_t;
-}
-
-int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type, MPI_Aint lb)
-{
- int retval;
-// if(old_type->sizeof_substruct){
-// //handle this case as a hvector with stride equals to the extent of the datatype
-// return smpi_datatype_hvector(count, 1, smpi_datatype_get_extent(old_type), old_type, new_type);
-// }
-//
-// s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create( lb, count, old_type,smpi_datatype_size(old_type));
-
-// smpi_datatype_create(new_type, count * smpi_datatype_size(old_type),lb,lb + count * smpi_datatype_size(old_type),
-// sizeof(s_smpi_mpi_contiguous_t),subtype, DT_FLAG_CONTIGUOUS);
- retval=MPI_SUCCESS;
- return retval;
-}
-
-int smpi_datatype_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type)
-{
- int retval;
-// if (blocklen<0)
-// return MPI_ERR_ARG;
-// MPI_Aint lb = 0;
-// MPI_Aint ub = 0;
-// if(count>0){
-// lb=smpi_datatype_lb(old_type);
-// ub=((count-1)*stride+blocklen-1)*smpi_datatype_get_extent(old_type)+smpi_datatype_ub(old_type);
-// }
-// if(old_type->sizeof_substruct != 0 || stride != blocklen){
-
-// s_smpi_mpi_vector_t* subtype = smpi_datatype_vector_create(stride, blocklen, count, old_type,
-// smpi_datatype_size(old_type));
-// smpi_datatype_create(new_type, count * (blocklen) * smpi_datatype_size(old_type), lb, ub, sizeof(s_smpi_mpi_vector_t), subtype,
-// DT_FLAG_VECTOR);
-// retval=MPI_SUCCESS;
-// }else{
-// /* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/
-// smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type), 0, ((count -1) * stride + blocklen)*
-// smpi_datatype_size(old_type), 0, nullptr, DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS);
- retval=MPI_SUCCESS;
-// }
- return retval;
-}
-
-void free_vector(MPI_Datatype* d){
-// smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_indexed_t*>((*d)->substruct)->old_type);
-}
-
-void use_vector(MPI_Datatype* d){
-// smpi_datatype_use(reinterpret_cast<s_smpi_mpi_indexed_t*>((*d)->substruct)->old_type);
-}
-
-/* Hvector Implementation - Vector with stride in bytes */
-
-/* Copies noncontiguous data into contiguous memory.
- * @param contiguous_hvector - output hvector
- * @param noncontiguous_hvector - input hvector
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data, in bytes
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void serialize_hvector( void* noncontiguous_hvector, void *contiguous_hvector, int count, void *type)
-{
-// s_smpi_mpi_hvector_t* type_c = reinterpret_cast<s_smpi_mpi_hvector_t*>(type);
-// int i;
-// char* contiguous_vector_char = static_cast<char*>(contiguous_hvector);
-// char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_hvector);
-
-// for (i = 0; i < type_c->block_count * count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0)
-// memcpy(contiguous_vector_char, noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
-// else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
-// contiguous_vector_char,
-// type_c->block_length, type_c->old_type->substruct);
-
-// contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
-// if((i+1)%type_c->block_count ==0)
-// noncontiguous_vector_char += type_c->block_length*type_c->size_oldtype;
-// else
-// noncontiguous_vector_char += type_c->block_stride;
-// }
-}
-/* Copies contiguous data into noncontiguous memory.
- * @param noncontiguous_vector - output hvector
- * @param contiguous_vector - input hvector
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data, in bytes
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void unserialize_hvector( void* contiguous_vector, void *noncontiguous_vector, int count, void *type, MPI_Op op)
-{
-// s_smpi_mpi_hvector_t* type_c = reinterpret_cast<s_smpi_mpi_hvector_t*>(type);
-// int i;
-
-// char* contiguous_vector_char = static_cast<char*>(contiguous_vector);
-// char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector);
-
-// for (i = 0; i < type_c->block_count * count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0){
-// if(op!=MPI_OP_NULL)
-// op->apply( contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length, &type_c->old_type);
-// }else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize( contiguous_vector_char, noncontiguous_vector_char,
-// type_c->block_length, type_c->old_type->substruct,
-// op);
-// contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
-// if((i+1)%type_c->block_count ==0)
-// noncontiguous_vector_char += type_c->block_length*type_c->size_oldtype;
-// else
-// noncontiguous_vector_char += type_c->block_stride;
-// }
-}
-
-/* Create a Sub type vector to be able to serialize and unserialize it the structure s_smpi_mpi_vector_t is derived
- * from s_smpi_subtype which required the functions unserialize and serialize
- *
- */
-s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride, int block_length, int block_count,
- MPI_Datatype old_type, int size_oldtype){
- s_smpi_mpi_hvector_t *new_t= xbt_new(s_smpi_mpi_hvector_t,1);
- new_t->base.serialize = &serialize_hvector;
- new_t->base.unserialize = &unserialize_hvector;
- new_t->base.subtype_free = &free_hvector;
- new_t->base.subtype_use = &use_hvector;
- new_t->block_stride = block_stride;
- new_t->block_length = block_length;
- new_t->block_count = block_count;
- new_t->old_type = old_type;
- new_t->size_oldtype = size_oldtype;
- smpi_datatype_use(old_type);
- return new_t;
-}
-
-//do nothing for vector types
-void free_hvector(MPI_Datatype* d){
-// smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_hvector_t*>((*d)->substruct)->old_type);
-}
-
-void use_hvector(MPI_Datatype* d){
-// smpi_datatype_use(reinterpret_cast<s_smpi_mpi_hvector_t*>((*d)->substruct)->old_type);
-}
-
-int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type)
-{
- int retval;
-// if (blocklen<0)
-// return MPI_ERR_ARG;
-// MPI_Aint lb = 0;
-// MPI_Aint ub = 0;
-// if(count>0){
-// lb=smpi_datatype_lb(old_type);
-// ub=((count-1)*stride)+(blocklen-1)*smpi_datatype_get_extent(old_type)+smpi_datatype_ub(old_type);
-// }
-// if(old_type->sizeof_substruct != 0 || stride != blocklen*smpi_datatype_get_extent(old_type)){
-// s_smpi_mpi_hvector_t* subtype = smpi_datatype_hvector_create( stride, blocklen, count, old_type,
-// smpi_datatype_size(old_type));
-
-// smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type), lb,ub, sizeof(s_smpi_mpi_hvector_t), subtype, DT_FLAG_VECTOR);
-// retval=MPI_SUCCESS;
-// }else{
-// smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type),0,count * blocklen *
-// smpi_datatype_size(old_type), 0, nullptr, DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS);
- retval=MPI_SUCCESS;
-// }
- return retval;
-}
-
-/* Indexed Implementation */
-
-/* Copies noncontiguous data into contiguous memory.
- * @param contiguous_indexed - output indexed
- * @param noncontiguous_indexed - input indexed
- * @param type - pointer contening :
- * - block_lengths - the width or height of blocked matrix
- * - block_indices - indices of each data, in element
- * - count - the number of rows of matrix
- */
-void serialize_indexed( void* noncontiguous_indexed, void *contiguous_indexed, int count, void *type)
-{
-// s_smpi_mpi_indexed_t* type_c = reinterpret_cast<s_smpi_mpi_indexed_t*>(type);
-// char* contiguous_indexed_char = static_cast<char*>(contiguous_indexed);
-// char* noncontiguous_indexed_char = static_cast<char*>(noncontiguous_indexed)+type_c->block_indices[0] * type_c->size_oldtype;
-// for (int j = 0; j < count; j++) {
-// for (int i = 0; i < type_c->block_count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0)
-// memcpy(contiguous_indexed_char, noncontiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
-// else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_indexed_char,
-// contiguous_indexed_char,
-// type_c->block_lengths[i],
-// type_c->old_type->substruct);
-
-// contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
-// if (i<type_c->block_count-1)
-// noncontiguous_indexed_char =
-// static_cast<char*>(noncontiguous_indexed) + type_c->block_indices[i+1]*smpi_datatype_get_extent(type_c->old_type);
-// else
-// noncontiguous_indexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
-// }
-// noncontiguous_indexed=static_cast< void*>(noncontiguous_indexed_char);
-// }
-}
-/* Copies contiguous data into noncontiguous memory.
- * @param noncontiguous_indexed - output indexed
- * @param contiguous_indexed - input indexed
- * @param type - pointer contening :
- * - block_lengths - the width or height of blocked matrix
- * - block_indices - indices of each data, in element
- * - count - the number of rows of matrix
- */
-void unserialize_indexed( void* contiguous_indexed, void *noncontiguous_indexed, int count, void *type, MPI_Op op)
-{
-// s_smpi_mpi_indexed_t* type_c = reinterpret_cast<s_smpi_mpi_indexed_t*>(type);
-// char* contiguous_indexed_char = static_cast<char*>(contiguous_indexed);
-// char* noncontiguous_indexed_char =
-// static_cast<char*>(noncontiguous_indexed)+type_c->block_indices[0]*smpi_datatype_get_extent(type_c->old_type);
-// for (int j = 0; j < count; j++) {
-// for (int i = 0; i < type_c->block_count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0){
-// if(op!=MPI_OP_NULL)
-// op->apply( contiguous_indexed_char, noncontiguous_indexed_char, &type_c->block_lengths[i],
-// &type_c->old_type);
-// }else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize( contiguous_indexed_char,
-// noncontiguous_indexed_char,
-// type_c->block_lengths[i],
-// type_c->old_type->substruct, op);
-
-// contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
-// if (i<type_c->block_count-1)
-// noncontiguous_indexed_char =
-// static_cast<char*>(noncontiguous_indexed) + type_c->block_indices[i+1]*smpi_datatype_get_extent(type_c->old_type);
-// else
-// noncontiguous_indexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
-// }
-// noncontiguous_indexed=static_cast<void*>(noncontiguous_indexed_char);
-// }
-}
-
-void free_indexed(MPI_Datatype* type){
-// if((*type)->in_use==0){
-// xbt_free(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->block_lengths);
-// xbt_free(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->block_indices);
-// }
-// smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->old_type);
-}
-
-void use_indexed(MPI_Datatype* type){
-// smpi_datatype_use(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->old_type);
-}
-
-
-/* Create a Sub type indexed to be able to serialize and unserialize it the structure s_smpi_mpi_indexed_t is derived
- * from s_smpi_subtype which required the functions unserialize and serialize */
-s_smpi_mpi_indexed_t* smpi_datatype_indexed_create( int* block_lengths, int* block_indices, int block_count,
- MPI_Datatype old_type, int size_oldtype){
- s_smpi_mpi_indexed_t *new_t= xbt_new(s_smpi_mpi_indexed_t,1);
- new_t->base.serialize = &serialize_indexed;
- new_t->base.unserialize = &unserialize_indexed;
- new_t->base.subtype_free = &free_indexed;
- new_t->base.subtype_use = &use_indexed;
- new_t->block_lengths= xbt_new(int, block_count);
- new_t->block_indices= xbt_new(int, block_count);
- for (int i = 0; i < block_count; i++) {
- new_t->block_lengths[i]=block_lengths[i];
- new_t->block_indices[i]=block_indices[i];
- }
- new_t->block_count = block_count;
- smpi_datatype_use(old_type);
- new_t->old_type = old_type;
- new_t->size_oldtype = size_oldtype;
- return new_t;
-}
-
-int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type)
-{
-// int size = 0;
-// bool contiguous=true;
-// MPI_Aint lb = 0;
-// MPI_Aint ub = 0;
-// if(count>0){
-// lb=indices[0]*smpi_datatype_get_extent(old_type);
-// ub=indices[0]*smpi_datatype_get_extent(old_type) + blocklens[0]*smpi_datatype_ub(old_type);
-// }
-
-// for (int i = 0; i < count; i++) {
-// if (blocklens[i] < 0)
-// return MPI_ERR_ARG;
-// size += blocklens[i];
-
-// if(indices[i]*smpi_datatype_get_extent(old_type)+smpi_datatype_lb(old_type)<lb)
-// lb = indices[i]*smpi_datatype_get_extent(old_type)+smpi_datatype_lb(old_type);
-// if(indices[i]*smpi_datatype_get_extent(old_type)+blocklens[i]*smpi_datatype_ub(old_type)>ub)
-// ub = indices[i]*smpi_datatype_get_extent(old_type)+blocklens[i]*smpi_datatype_ub(old_type);
-
-// if ( (i< count -1) && (indices[i]+blocklens[i] != indices[i+1]) )
-// contiguous=false;
-// }
-// if (old_type->sizeof_substruct != 0)
-// contiguous=false;
-
-// if(!contiguous){
-// s_smpi_mpi_indexed_t* subtype = smpi_datatype_indexed_create( blocklens, indices, count, old_type,
-// smpi_datatype_size(old_type));
-// smpi_datatype_create(new_type, size * smpi_datatype_size(old_type),lb,ub,sizeof(s_smpi_mpi_indexed_t), subtype, DT_FLAG_DATA);
-// }else{
-// s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create( lb, size, old_type,
-// smpi_datatype_size(old_type));
-// smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub, sizeof(s_smpi_mpi_contiguous_t), subtype,
-// DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
-// }
- return MPI_SUCCESS;
-}
-/* Hindexed Implementation - Indexed with indices in bytes */
-
-/* Copies noncontiguous data into contiguous memory.
- * @param contiguous_hindexed - output hindexed
- * @param noncontiguous_hindexed - input hindexed
- * @param type - pointer contening :
- * - block_lengths - the width or height of blocked matrix
- * - block_indices - indices of each data, in bytes
- * - count - the number of rows of matrix
- */
-void serialize_hindexed( void* noncontiguous_hindexed, void *contiguous_hindexed, int count, void *type)
-{
-// s_smpi_mpi_hindexed_t* type_c = reinterpret_cast<s_smpi_mpi_hindexed_t*>(type);
-// char* contiguous_hindexed_char = static_cast<char*>(contiguous_hindexed);
-// char* noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed)+ type_c->block_indices[0];
-// for (int j = 0; j < count; j++) {
-// for (int i = 0; i < type_c->block_count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0)
-// memcpy(contiguous_hindexed_char, noncontiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
-// else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_hindexed_char,
-// contiguous_hindexed_char,
-// type_c->block_lengths[i],
-// type_c->old_type->substruct);
-
-// contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
-// if (i<type_c->block_count-1)
-// noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed) + type_c->block_indices[i+1];
-// else
-// noncontiguous_hindexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
-// }
-// noncontiguous_hindexed=static_cast<void*>(noncontiguous_hindexed_char);
-// }
-}
-/* Copies contiguous data into noncontiguous memory.
- * @param noncontiguous_hindexed - output hindexed
- * @param contiguous_hindexed - input hindexed
- * @param type - pointer contening :
- * - block_lengths - the width or height of blocked matrix
- * - block_indices - indices of each data, in bytes
- * - count - the number of rows of matrix
- */
-void unserialize_hindexed( void* contiguous_hindexed, void *noncontiguous_hindexed, int count, void *type,
- MPI_Op op)
-{
-// s_smpi_mpi_hindexed_t* type_c = reinterpret_cast<s_smpi_mpi_hindexed_t*>(type);
-
-// char* contiguous_hindexed_char = static_cast<char*>(contiguous_hindexed);
-// char* noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed)+ type_c->block_indices[0];
-// for (int j = 0; j < count; j++) {
-// for (int i = 0; i < type_c->block_count; i++) {
-// if (type_c->old_type->sizeof_substruct == 0){
-// if(op!=MPI_OP_NULL)
-// op->apply( contiguous_hindexed_char, noncontiguous_hindexed_char, &type_c->block_lengths[i],
-// &type_c->old_type);
-// }else
-// static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize( contiguous_hindexed_char,
-// noncontiguous_hindexed_char,
-// type_c->block_lengths[i],
-// type_c->old_type->substruct, op);
-
-// contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
-// if (i<type_c->block_count-1)
-// noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed) + type_c->block_indices[i+1];
-// else
-// noncontiguous_hindexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
-// }
-// noncontiguous_hindexed=static_cast<void*>(noncontiguous_hindexed_char);
-// }
-}
-
-void free_hindexed(MPI_Datatype* type){
-// if((*type)->in_use==0){
-// xbt_free(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->block_lengths);
-// xbt_free(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->block_indices);
-// }
-// smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->old_type);
-}
-
-void use_hindexed(MPI_Datatype* type){
-// smpi_datatype_use(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->old_type);
-}
-
-/* Create a Sub type hindexed to be able to serialize and unserialize it the structure s_smpi_mpi_hindexed_t is derived
- * from s_smpi_subtype which required the functions unserialize and serialize
- */
-s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create( int* block_lengths, MPI_Aint* block_indices, int block_count,
- MPI_Datatype old_type, int size_oldtype){
- s_smpi_mpi_hindexed_t *new_t= xbt_new(s_smpi_mpi_hindexed_t,1);
- new_t->base.serialize = &serialize_hindexed;
- new_t->base.unserialize = &unserialize_hindexed;
- new_t->base.subtype_free = &free_hindexed;
- new_t->base.subtype_use = &use_hindexed;
- new_t->block_lengths= xbt_new(int, block_count);
- new_t->block_indices= xbt_new(MPI_Aint, block_count);
- for(int i=0;i<block_count;i++){
- new_t->block_lengths[i]=block_lengths[i];
- new_t->block_indices[i]=block_indices[i];
- }
- new_t->block_count = block_count;
- new_t->old_type = old_type;
- smpi_datatype_use(old_type);
- new_t->size_oldtype = size_oldtype;
- return new_t;
-}
-
-int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type)
-{
-// int size = 0;
-// bool contiguous=true;
-// MPI_Aint lb = 0;
-// MPI_Aint ub = 0;
-// if(count>0){
-// lb=indices[0] + smpi_datatype_lb(old_type);
-// ub=indices[0] + blocklens[0]*smpi_datatype_ub(old_type);
-// }
-// for (int i = 0; i < count; i++) {
-// if (blocklens[i] < 0)
-// return MPI_ERR_ARG;
-// size += blocklens[i];
-
-// if(indices[i]+smpi_datatype_lb(old_type)<lb)
-// lb = indices[i]+smpi_datatype_lb(old_type);
-// if(indices[i]+blocklens[i]*smpi_datatype_ub(old_type)>ub)
-// ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_type);
-
-// if ( (i< count -1) && (indices[i]+blocklens[i]*(static_cast<int>(smpi_datatype_size(old_type))) != indices[i+1]) )
-// contiguous=false;
-// }
-// if (old_type->sizeof_substruct != 0 || lb!=0)
-// contiguous=false;
-
-// if(!contiguous){
-// s_smpi_mpi_hindexed_t* subtype = smpi_datatype_hindexed_create( blocklens, indices, count, old_type,
-// smpi_datatype_size(old_type));
-// smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub ,sizeof(s_smpi_mpi_hindexed_t), subtype, DT_FLAG_DATA);
-// }else{
-// s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create(lb,size, old_type, smpi_datatype_size(old_type));
-// smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), 0,size * smpi_datatype_size(old_type),
-// 1, subtype, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
-// }
- return MPI_SUCCESS;
-}
-
-/* struct Implementation - Indexed with indices in bytes */
-
-/* Copies noncontiguous data into contiguous memory.
- * @param contiguous_struct - output struct
- * @param noncontiguous_struct - input struct
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void serialize_struct( void* noncontiguous_struct, void *contiguous_struct, int count, void *type)
-{
-// s_smpi_mpi_struct_t* type_c = reinterpret_cast<s_smpi_mpi_struct_t*>(type);
-// char* contiguous_struct_char = static_cast<char*>(contiguous_struct);
-// char* noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct)+ type_c->block_indices[0];
-// for (int j = 0; j < count; j++) {
-// for (int i = 0; i < type_c->block_count; i++) {
-// if (type_c->old_types[i]->sizeof_substruct == 0)
-// memcpy(contiguous_struct_char, noncontiguous_struct_char,
-// type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
-// else
-// static_cast<s_smpi_subtype_t*>(type_c->old_types[i]->substruct)->serialize( noncontiguous_struct_char,
-// contiguous_struct_char,
-// type_c->block_lengths[i],
-// type_c->old_types[i]->substruct);
-
-
-// contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
-// if (i<type_c->block_count-1)
-// noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct) + type_c->block_indices[i+1];
-// else //let's hope this is MPI_UB ?
-// noncontiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_types[i]);
-// }
-// noncontiguous_struct=static_cast<void*>(noncontiguous_struct_char);
-// }
-}
-
-/* Copies contiguous data into noncontiguous memory.
- * @param noncontiguous_struct - output struct
- * @param contiguous_struct - input struct
- * @param type - pointer contening :
- * - stride - stride of between noncontiguous data
- * - block_length - the width or height of blocked matrix
- * - count - the number of rows of matrix
- */
-void unserialize_struct( void* contiguous_struct, void *noncontiguous_struct, int count, void *type, MPI_Op op)
-{
-// s_smpi_mpi_struct_t* type_c = reinterpret_cast<s_smpi_mpi_struct_t*>(type);
-
-// char* contiguous_struct_char = static_cast<char*>(contiguous_struct);
-// char* noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct)+ type_c->block_indices[0];
-// for (int j = 0; j < count; j++) {
-// for (int i = 0; i < type_c->block_count; i++) {
-// if (type_c->old_types[i]->sizeof_substruct == 0){
-// if(op!=MPI_OP_NULL)
-// op->apply( contiguous_struct_char, noncontiguous_struct_char, &type_c->block_lengths[i],
-// & type_c->old_types[i]);
-// }else
-// static_cast<s_smpi_subtype_t*>(type_c->old_types[i]->substruct)->unserialize( contiguous_struct_char,
-// noncontiguous_struct_char,
-// type_c->block_lengths[i],
-// type_c->old_types[i]->substruct, op);
-
-// contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
-// if (i<type_c->block_count-1)
-// noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct) + type_c->block_indices[i+1];
-// else
-// noncontiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_types[i]);
-// }
-// noncontiguous_struct=reinterpret_cast<void*>(noncontiguous_struct_char);
-// }
-}
-
-void free_struct(MPI_Datatype* type){
-// for (int i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
-// smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types[i]);
-// if((*type)->in_use==0){
-// xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_lengths);
-// xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_indices);
-// xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types);
-// }
-}
-
-void use_struct(MPI_Datatype* type){
-// for (int i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
-// smpi_datatype_use(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types[i]);
-}
-
-/* Create a Sub type struct to be able to serialize and unserialize it the structure s_smpi_mpi_struct_t is derived
- * from s_smpi_subtype which required the functions unserialize and serialize
- */
-s_smpi_mpi_struct_t* smpi_datatype_struct_create( int* block_lengths, MPI_Aint* block_indices, int block_count,
- MPI_Datatype* old_types){
- s_smpi_mpi_struct_t *new_t= xbt_new(s_smpi_mpi_struct_t,1);
- new_t->base.serialize = &serialize_struct;
- new_t->base.unserialize = &unserialize_struct;
- new_t->base.subtype_free = &free_struct;
- new_t->base.subtype_use = &use_struct;
- new_t->block_lengths= xbt_new(int, block_count);
- new_t->block_indices= xbt_new(MPI_Aint, block_count);
- new_t->old_types= xbt_new(MPI_Datatype, block_count);
- for (int i = 0; i < block_count; i++) {
- new_t->block_lengths[i]=block_lengths[i];
- new_t->block_indices[i]=block_indices[i];
- new_t->old_types[i]=old_types[i];
- smpi_datatype_use(new_t->old_types[i]);
- }
- new_t->block_count = block_count;
- return new_t;
-}
-
-int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type)
-{
-// size_t size = 0;
-// bool contiguous=true;
-// size = 0;
-// MPI_Aint lb = 0;
-// MPI_Aint ub = 0;
-// if(count>0){
-// lb=indices[0] + smpi_datatype_lb(old_types[0]);
-// ub=indices[0] + blocklens[0]*smpi_datatype_ub(old_types[0]);
-// }
-// bool forced_lb=false;
-// bool forced_ub=false;
-// for (int i = 0; i < count; i++) {
-// if (blocklens[i]<0)
-// return MPI_ERR_ARG;
-// if (old_types[i]->sizeof_substruct != 0)
-// contiguous=false;
-
-// size += blocklens[i]*smpi_datatype_size(old_types[i]);
-// if (old_types[i]==MPI_LB){
-// lb=indices[i];
-// forced_lb=true;
-// }
-// if (old_types[i]==MPI_UB){
-// ub=indices[i];
-// forced_ub=true;
-// }
-
-// if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])<lb)
-// lb = indices[i];
-// if(!forced_ub && indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i])>ub)
-// ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i]);
-
-// if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast<int>(smpi_datatype_size(old_types[i])) != indices[i+1]) )
-// contiguous=false;
-// }
-
-// if(!contiguous){
-// s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocklens, indices, count, old_types);
-
-// smpi_datatype_create(new_type, size, lb, ub,sizeof(s_smpi_mpi_struct_t), subtype, DT_FLAG_DATA);
-// }else{
-// s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create( lb, size, MPI_CHAR, 1);
-// smpi_datatype_create(new_type, size, lb, ub,1, subtype, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
-// }
- return MPI_SUCCESS;
-}
-
-void smpi_datatype_commit(MPI_Datatype *datatype)
-{
-// (*datatype)->flags= ((*datatype)->flags | DT_FLAG_COMMITED);
-}
-
-
-int smpi_type_attr_delete(MPI_Datatype type, int keyval){
-// smpi_type_key_elem elem =
-// static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
-// if(elem==nullptr)
-// return MPI_ERR_ARG;
-// if(elem->delete_fn!=MPI_NULL_DELETE_FN){
-// void * value = nullptr;
-// int flag;
-// if(smpi_type_attr_get(type, keyval, &value, &flag)==MPI_SUCCESS){
-// int ret = elem->delete_fn(type, keyval, value, &flag);
-// if(ret!=MPI_SUCCESS)
-// return ret;
-// }
-// }
-// if(type->attributes==nullptr)
-// return MPI_ERR_ARG;
-
-// xbt_dict_remove_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
- return MPI_SUCCESS;
-}
-
-int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* flag){
-// smpi_type_key_elem elem =
-// static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
-// if(elem==nullptr)
-// return MPI_ERR_ARG;
-// if(type->attributes==nullptr){
-// *flag=0;
-// return MPI_SUCCESS;
-// }
-// try {
-// *static_cast<void**>(attr_value) = xbt_dict_get_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
-// *flag=1;
-// }
-// catch (xbt_ex& ex) {
-// *flag=0;
-// }
- return MPI_SUCCESS;
-}
-
-int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){
-// if(smpi_type_keyvals==nullptr)
-// smpi_type_keyvals = xbt_dict_new_homogeneous(nullptr);
-// smpi_type_key_elem elem =
-// static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
-// if(elem==nullptr)
-// return MPI_ERR_ARG;
-// int flag;
-// void* value = nullptr;
-// smpi_type_attr_get(type, keyval, &value, &flag);
-// if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){
-// int ret = elem->delete_fn(type, keyval, value, &flag);
-// if(ret!=MPI_SUCCESS)
-// return ret;
-// }
-// if(type->attributes==nullptr)
-// type->attributes = xbt_dict_new_homogeneous(nullptr);
-
-// xbt_dict_set_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int), attr_value, nullptr);
- return MPI_SUCCESS;
-}
-
-int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
- void* extra_state){
-// if(smpi_type_keyvals==nullptr)
-// smpi_type_keyvals = xbt_dict_new_homogeneous(nullptr);
-
-// smpi_type_key_elem value = (smpi_type_key_elem) xbt_new0(s_smpi_mpi_type_key_elem_t,1);
-
-// value->copy_fn=copy_fn;
-// value->delete_fn=delete_fn;
-
-// *keyval = type_keyval_id;
-// xbt_dict_set_ext(smpi_type_keyvals,reinterpret_cast<const char*>(keyval), sizeof(int),reinterpret_cast<void*>(value), nullptr);
-// type_keyval_id++;
- return MPI_SUCCESS;
-}
-
-int smpi_type_keyval_free(int* keyval){
-// smpi_type_key_elem elem =
-// static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int)));
-// if(elem==0){
-// return MPI_ERR_ARG;
-// }
-// xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int));
-// xbt_free(elem);
- return MPI_SUCCESS;
-}
-
-int smpi_mpi_pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position,MPI_Comm comm){
- size_t size = smpi_datatype_size(type);
- if (outcount - *position < incount*static_cast<int>(size))
- return MPI_ERR_BUFFER;
- smpi_datatype_copy(inbuf, incount, type, static_cast<char*>(outbuf) + *position, outcount, MPI_CHAR);
- *position += incount * size;
- return MPI_SUCCESS;
-}
-
-int smpi_mpi_unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type,MPI_Comm comm){
- int size = static_cast<int>(smpi_datatype_size(type));
- if (outcount*size> insize)
- return MPI_ERR_BUFFER;
- smpi_datatype_copy(static_cast<char*>(inbuf) + *position, insize, MPI_CHAR, outbuf, outcount, type);
- *position += outcount * size;
- return MPI_SUCCESS;
-}
+++ /dev/null
-/* smpi_mpi_dt_private.h -- functions of smpi_mpi_dt.c that are exported to other SMPI modules. */
-
-/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef SMPI_DT_PRIVATE_H
-#define SMPI_DT_PRIVATE_H
-
-#include <xbt/base.h>
-
-#include "private.h"
-
-SG_BEGIN_DECL()
-
-#define DT_FLAG_DESTROYED 0x0001 /**< user destroyed but some other layers still have a reference */
-#define DT_FLAG_COMMITED 0x0002 /**< ready to be used for a send/recv operation */
-#define DT_FLAG_CONTIGUOUS 0x0004 /**< contiguous datatype */
-#define DT_FLAG_OVERLAP 0x0008 /**< datatype is unpropper for a recv operation */
-#define DT_FLAG_USER_LB 0x0010 /**< has a user defined LB */
-#define DT_FLAG_USER_UB 0x0020 /**< has a user defined UB */
-#define DT_FLAG_PREDEFINED 0x0040 /**< cannot be removed: initial and predefined datatypes */
-#define DT_FLAG_NO_GAPS 0x0080 /**< no gaps around the datatype */
-#define DT_FLAG_DATA 0x0100 /**< data or control structure */
-#define DT_FLAG_ONE_SIDED 0x0200 /**< datatype can be used for one sided operations */
-#define DT_FLAG_UNAVAILABLE 0x0400 /**< datatypes unavailable on the build (OS or compiler dependant) */
-#define DT_FLAG_VECTOR 0x0800 /**< valid only for loops. The loop contain only one element
- **< without extent. It correspond to the vector type. */
-/*
- * We should make the difference here between the predefined contiguous and non contiguous
- * datatypes. The DT_FLAG_BASIC is held by all predefined contiguous datatypes.
- */
-#define DT_FLAG_BASIC (DT_FLAG_PREDEFINED | DT_FLAG_CONTIGUOUS | DT_FLAG_NO_GAPS | DT_FLAG_DATA | DT_FLAG_COMMITED)
-
-extern const MPI_Datatype MPI_PTR;
-
-/* Structures that handle complex data type information, used for serialization/unserialization of messages */
-typedef struct s_smpi_mpi_contiguous{
- s_smpi_subtype_t base;
- MPI_Datatype old_type;
- MPI_Aint lb;
- size_t size_oldtype;
- int block_count;
-} s_smpi_mpi_contiguous_t;
-
-typedef struct s_smpi_mpi_vector{
- s_smpi_subtype_t base;
- MPI_Datatype old_type;
- size_t size_oldtype;
- int block_stride;
- int block_length;
- int block_count;
-} s_smpi_mpi_vector_t;
-
-typedef struct s_smpi_mpi_hvector{
- s_smpi_subtype_t base;
- MPI_Datatype old_type;
- size_t size_oldtype;
- MPI_Aint block_stride;
- int block_length;
- int block_count;
-} s_smpi_mpi_hvector_t;
-
-typedef struct s_smpi_mpi_indexed{
- s_smpi_subtype_t base;
- MPI_Datatype old_type;
- size_t size_oldtype;
- int* block_lengths;
- int* block_indices;
- int block_count;
-} s_smpi_mpi_indexed_t;
-
-typedef struct s_smpi_mpi_hindexed{
- s_smpi_subtype_t base;
- MPI_Datatype old_type;
- size_t size_oldtype;
- int* block_lengths;
- MPI_Aint* block_indices;
- int block_count;
-} s_smpi_mpi_hindexed_t;
-
-typedef struct s_smpi_mpi_struct{
- s_smpi_subtype_t base;
- MPI_Datatype old_type;
- size_t size_oldtype;
- int* block_lengths;
- MPI_Aint* block_indices;
- int block_count;
- MPI_Datatype* old_types;
-} s_smpi_mpi_struct_t;
-
-//The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
-typedef struct {
- float value;
- int index;
-} float_int;
-typedef struct {
- float value;
- float index;
-} float_float;
-typedef struct {
- long value;
- long index;
-} long_long;
-typedef struct {
- double value;
- double index;
-} double_double;
-typedef struct {
- long value;
- int index;
-} long_int;
-typedef struct {
- double value;
- int index;
-} double_int;
-typedef struct {
- short value;
- int index;
-} short_int;
-typedef struct {
- int value;
- int index;
-} int_int;
-typedef struct {
- long double value;
- int index;
-} long_double_int;
-typedef struct {
- int64_t value;
- int64_t index;
-} integer128_t;
-
-
-/*
- Functions to handle serialization/unserialization of messages, 3 for each type of MPI_Type
- One for creating the substructure to handle, one for serialization, one for unserialization
-*/
-XBT_PRIVATE void unserialize_contiguous( void *contiguous_vector, void *noncontiguous_vector, int count,
- void *type, MPI_Op op);
-XBT_PRIVATE void serialize_contiguous( void *noncontiguous_vector, void *contiguous_vector, int count,void *type);
-XBT_PRIVATE void free_contiguous(MPI_Datatype* type);
-XBT_PRIVATE void use_contiguous(MPI_Datatype* type);
-XBT_PRIVATE s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block_count,
- MPI_Datatype old_type, int size_oldtype);
-
-XBT_PRIVATE void unserialize_vector( void *contiguous_vector, void *noncontiguous_vector, int count,void *type,
- MPI_Op op);
-XBT_PRIVATE void serialize_vector( void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
-XBT_PRIVATE void free_vector(MPI_Datatype* type);
-XBT_PRIVATE void use_vector(MPI_Datatype* type);
-XBT_PRIVATE s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride, int block_length, int block_count,
- MPI_Datatype old_type, int size_oldtype);
-
-XBT_PRIVATE void unserialize_hvector( void *contiguous_vector, void *noncontiguous_vector, int count, void *type,
- MPI_Op op);
-XBT_PRIVATE void serialize_hvector( void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
-XBT_PRIVATE void free_hvector(MPI_Datatype* type);
-XBT_PRIVATE void use_hvector(MPI_Datatype* type);
-XBT_PRIVATE s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride, int block_length,
- int block_count, MPI_Datatype old_type, int size_oldtype);
-
-XBT_PRIVATE void unserialize_indexed( void *contiguous_indexed, void *noncontiguous_indexed, int count,
- void *type, MPI_Op op);
-XBT_PRIVATE void serialize_indexed( void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
-XBT_PRIVATE void free_indexed(MPI_Datatype* type);
-XBT_PRIVATE void use_indexed(MPI_Datatype* type);
-XBT_PRIVATE s_smpi_mpi_indexed_t* smpi_datatype_indexed_create(int* block_lengths, int* block_indices,
- int block_count, MPI_Datatype old_type, int size_oldtype);
-
-XBT_PRIVATE void unserialize_hindexed( void *contiguous_indexed, void *noncontiguous_indexed, int count,
- void *type, MPI_Op op);
-XBT_PRIVATE void serialize_hindexed( void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
-XBT_PRIVATE void free_hindexed(MPI_Datatype* type);
-XBT_PRIVATE void use_hindexed(MPI_Datatype* type);
-XBT_PRIVATE s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create(int* block_lengths, MPI_Aint* block_indices,
- int block_count, MPI_Datatype old_type, int size_oldtype);
-
-XBT_PRIVATE void unserialize_struct( void *contiguous_indexed, void *noncontiguous_indexed, int count, void *type,
- MPI_Op op);
-XBT_PRIVATE void serialize_struct( void *noncontiguous_vector, void *contiguous_vector, int count, void *type);
-XBT_PRIVATE void free_struct(MPI_Datatype* type);
-XBT_PRIVATE void use_struct(MPI_Datatype* type);
-XBT_PRIVATE s_smpi_mpi_struct_t* smpi_datatype_struct_create(int* block_lengths, MPI_Aint* block_indices,
- int block_count, MPI_Datatype* old_types);
-
-SG_END_DECL()
-#endif
#include "mc/mc.h"
#include "private.h"
-#include "smpi_mpi_dt_private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)");
static void replace_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
- memcpy(b, a, *length * smpi_datatype_size(*datatype));
+ memcpy(b, a, *length * (*datatype)->size());
}
#define CREATE_MPI_OP(name, func) \
#include <xbt/ex.hpp>
#include "private.h"
-#include "smpi_mpi_dt_private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_pmpi, smpi, "Logging specific to SMPI (pmpi)");
if (*datatype == MPI_DATATYPE_NULL) {
return MPI_ERR_ARG;
} else {
- smpi_datatype_unuse(*datatype);
+ (*datatype)->unuse();
return MPI_SUCCESS;
}
}
} else if (size == nullptr) {
return MPI_ERR_ARG;
} else {
- *size = static_cast<int>(smpi_datatype_size(datatype));
+ *size = static_cast<int>(datatype->size());
return MPI_SUCCESS;
}
}
} else if (size == nullptr) {
return MPI_ERR_ARG;
} else {
- *size = static_cast<MPI_Count>(smpi_datatype_size(datatype));
+ *size = static_cast<MPI_Count>(datatype->size());
return MPI_SUCCESS;
}
}
} else if (lb == nullptr || extent == nullptr) {
return MPI_ERR_ARG;
} else {
- return smpi_datatype_extent(datatype, lb, extent);
+ return datatype->extent(lb, extent);
}
}
} else if (extent == nullptr) {
return MPI_ERR_ARG;
} else {
- *extent = smpi_datatype_get_extent(datatype);
+ *extent = datatype->get_extent();
return MPI_SUCCESS;
}
}
} else if (disp == nullptr) {
return MPI_ERR_ARG;
} else {
- *disp = smpi_datatype_lb(datatype);
+ *disp = datatype->lb();
return MPI_SUCCESS;
}
}
} else if (disp == nullptr) {
return MPI_ERR_ARG;
} else {
- *disp = smpi_datatype_ub(datatype);
+ *disp = datatype->ub();
return MPI_SUCCESS;
}
}
if (datatype == MPI_DATATYPE_NULL) {
return MPI_ERR_TYPE;
} else {
- return smpi_datatype_dup(datatype, newtype);
+ *newtype = new Datatype(datatype);
+ return MPI_SUCCESS;
}
}
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (dst == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (src == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (dst == MPI_PROC_NULL) {
retval = MPI_SUCCESS;
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if(known==0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if(known==0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
- TRACE_smpi_send(rank, rank, dst_traced, tag, count*smpi_datatype_size(datatype));
+ TRACE_smpi_send(rank, rank, dst_traced, tag, count*datatype->size());
*request = Request::isend(buf, count, datatype, dst, tag, comm);
retval = MPI_SUCCESS;
retval = MPI_ERR_RANK;
} else if ((count < 0)|| (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if(known==0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
- TRACE_smpi_send(rank, rank, dst_traced, tag, count*smpi_datatype_size(datatype));
+ TRACE_smpi_send(rank, rank, dst_traced, tag, count*datatype->size());
*request = Request::issend(buf, count, datatype, dst, tag, comm);
retval = MPI_SUCCESS;
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count * dt_size_send;
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf == nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if(tag < 0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0) {
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
}
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
if (!TRACE_smpi_view_internals()) {
- TRACE_smpi_send(rank, rank, dst_traced, tag,count*smpi_datatype_size(datatype));
+ TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size());
}
Request::send(buf, count, datatype, dst, tag, comm);
retval = MPI_ERR_RANK;
} else if ((count < 0) || (buf==nullptr && count > 0)) {
retval = MPI_ERR_COUNT;
- } else if (!is_datatype_valid(datatype)){
+ } else if (!datatype->is_valid()){
retval = MPI_ERR_TYPE;
} else if(tag<0 && tag != MPI_ANY_TAG){
retval = MPI_ERR_TAG;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if(known == 0) {
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
}
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
- TRACE_smpi_send(rank, rank, dst_traced, tag,count*smpi_datatype_size(datatype));
+ TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size());
Request::ssend(buf, count, datatype, dst, tag, comm);
retval = MPI_SUCCESS;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(sendtype) || !is_datatype_valid(recvtype)) {
+ } else if (!sendtype->is_valid() || !recvtype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
smpi_empty_status(status);
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
if(known==0)
- dt_size_send = smpi_datatype_size(sendtype);
+ dt_size_send = sendtype->size();
extra->send_size = sendcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if(known==0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
extra->recv_size = recvcount*dt_size_recv;
TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
- TRACE_smpi_send(rank, rank, dst_traced, sendtag,sendcount*smpi_datatype_size(sendtype));
+ TRACE_smpi_send(rank, rank, dst_traced, sendtag,sendcount*sendtype->size());
Request::sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src, recvtag, comm,
status);
MPI_Comm comm, MPI_Status* status)
{
int retval = 0;
- if (!is_datatype_valid(datatype)) {
+ if (!datatype->is_valid()) {
return MPI_ERR_TYPE;
} else if (count < 0) {
return MPI_ERR_COUNT;
} else {
- int size = smpi_datatype_get_extent(datatype) * count;
+ int size = datatype->get_extent() * count;
void* recvbuf = xbt_new0(char, size);
retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
if(retval==MPI_SUCCESS){
- smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
+ Datatype::copy(recvbuf, count, datatype, buf, count, datatype);
}
xbt_free(recvbuf);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_ARG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count * dt_size_send;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
if (comm->size() > 1)
extra->datatype1 = encode_datatype(sendtmptype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(sendtmptype);
+ dt_size_send = sendtmptype->size();
extra->send_size = sendtmpcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if ((comm->rank() == root) && known == 0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
extra->recv_size = recvcount * dt_size_recv;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
extra->datatype1 = encode_datatype(sendtmptype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(sendtype);
+ dt_size_send = sendtype->size();
extra->send_size = sendtmpcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if (known == 0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
if ((comm->rank() == root)) {
extra->recvcounts = xbt_new(int, size);
for (i = 0; i < size; i++) // copy data to avoid bad free
retval = MPI_ERR_COUNT;
} else {
if(sendbuf == MPI_IN_PLACE) {
- sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*comm->rank();
+ sendbuf=static_cast<char*>(recvbuf)+recvtype->get_extent()*recvcount*comm->rank();
sendcount=recvcount;
sendtype=recvtype;
}
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(sendtype);
+ dt_size_send = sendtype->size();
extra->send_size = sendcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if (known == 0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
extra->recv_size = recvcount * dt_size_recv;
TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
} else {
if(sendbuf == MPI_IN_PLACE) {
- sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*displs[comm->rank()];
+ sendbuf=static_cast<char*>(recvbuf)+recvtype->get_extent()*displs[comm->rank()];
sendcount=recvcounts[comm->rank()];
sendtype=recvtype;
}
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(sendtype);
+ dt_size_send = sendtype->size();
extra->send_size = sendcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if (known == 0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
extra->recvcounts = xbt_new(int, size);
for (i = 0; i < size; i++) // copy data to avoid bad free
extra->recvcounts[i] = recvcounts[i] * dt_size_recv;
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (((comm->rank() == root) && (!is_datatype_valid(sendtype))) ||
- ((recvbuf != MPI_IN_PLACE) && (!is_datatype_valid(recvtype)))) {
+ } else if (((comm->rank() == root) && (!sendtype->is_valid())) ||
+ ((recvbuf != MPI_IN_PLACE) && (!recvtype->is_valid()))) {
retval = MPI_ERR_TYPE;
} else if ((sendbuf == recvbuf) ||
((comm->rank()==root) && sendcount>0 && (sendbuf == nullptr))){
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
if ((comm->rank() == root) && known == 0)
- dt_size_send = smpi_datatype_size(sendtype);
+ dt_size_send = sendtype->size();
extra->send_size = sendcount * dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if (known == 0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
extra->recv_size = recvcount * dt_size_recv;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(sendtype);
+ dt_size_send = sendtype->size();
if ((comm->rank() == root)) {
extra->sendcounts = xbt_new(int, size);
for (i = 0; i < size; i++) // copy data to avoid bad free
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
if (known == 0)
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
extra->recv_size = recvcount * dt_size_recv;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
+ } else if (!datatype->is_valid() || op == MPI_OP_NULL) {
retval = MPI_ERR_ARG;
} else {
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count * dt_size_send;
extra->root = root_traced;
int retval = 0;
smpi_bench_end();
- if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
+ if (!datatype->is_valid() || op == MPI_OP_NULL) {
retval = MPI_ERR_ARG;
} else {
if(op!=MPI_OP_NULL) op->apply( inbuf, inoutbuf, &count, datatype);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
char* sendtmpbuf = static_cast<char*>(sendbuf);
if( sendbuf == MPI_IN_PLACE ) {
- sendtmpbuf = static_cast<char*>(xbt_malloc(count*smpi_datatype_get_extent(datatype)));
- smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
+ sendtmpbuf = static_cast<char*>(xbt_malloc(count*datatype->get_extent()));
+ Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count * dt_size_send;
TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count * dt_size_send;
TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = count * dt_size_send;
void* sendtmpbuf = sendbuf;
if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(count * smpi_datatype_size(datatype)));
- memcpy(sendtmpbuf, recvbuf, count * smpi_datatype_size(datatype));
+ sendtmpbuf = static_cast<void*>(xbt_malloc(count * datatype->size()));
+ memcpy(sendtmpbuf, recvbuf, count * datatype->size());
}
TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = 0;
extra->recvcounts = xbt_new(int, size);
int totalcount = 0;
}
void* sendtmpbuf = sendbuf;
if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(totalcount * smpi_datatype_size(datatype)));
- memcpy(sendtmpbuf, recvbuf, totalcount * smpi_datatype_size(datatype));
+ sendtmpbuf = static_cast<void*>(xbt_malloc(totalcount * datatype->size()));
+ memcpy(sendtmpbuf, recvbuf, totalcount * datatype->size());
}
TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
if (known == 0)
- dt_size_send = smpi_datatype_size(datatype);
+ dt_size_send = datatype->size();
extra->send_size = 0;
extra->recvcounts = xbt_new(int, count);
for (int i = 0; i < count; i++) // copy data to avoid bad free
extra->recvcounts[i] = recvcount * dt_size_send;
void* sendtmpbuf = sendbuf;
if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * count * smpi_datatype_size(datatype)));
- memcpy(sendtmpbuf, recvbuf, recvcount * count * smpi_datatype_size(datatype));
+ sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * count * datatype->size()));
+ memcpy(sendtmpbuf, recvbuf, recvcount * count * datatype->size());
}
TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
int sendtmpcount = sendcount;
MPI_Datatype sendtmptype = sendtype;
if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * comm->size() * smpi_datatype_size(recvtype)));
- memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * smpi_datatype_size(recvtype));
+ sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * comm->size() * recvtype->size()));
+ memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * recvtype->size());
sendtmpcount = recvcount;
sendtmptype = recvtype;
}
int known = 0;
extra->datatype1 = encode_datatype(sendtmptype, &known);
if (known == 0)
- extra->send_size = sendtmpcount * smpi_datatype_size(sendtmptype);
+ extra->send_size = sendtmpcount * sendtmptype->size();
else
extra->send_size = sendtmpcount;
extra->datatype2 = encode_datatype(recvtype, &known);
if (known == 0)
- extra->recv_size = recvcount * smpi_datatype_size(recvtype);
+ extra->recv_size = recvcount * recvtype->size();
else
extra->recv_size = recvcount;
int known = 0;
int dt_size_recv = 1;
extra->datatype2 = encode_datatype(recvtype, &known);
- dt_size_recv = smpi_datatype_size(recvtype);
+ dt_size_recv = recvtype->size();
void* sendtmpbuf = static_cast<char*>(sendbuf);
int* sendtmpcounts = sendcounts;
extra->datatype1 = encode_datatype(sendtmptype, &known);
int dt_size_send = 1;
- dt_size_send = smpi_datatype_size(sendtmptype);
+ dt_size_send = sendtmptype->size();
for (i = 0; i < size; i++) { // copy data to avoid bad free
extra->send_size += sendtmpcounts[i] * dt_size_send;
{
if (status == nullptr || count == nullptr) {
return MPI_ERR_ARG;
- } else if (!is_datatype_valid(datatype)) {
+ } else if (!datatype->is_valid()) {
return MPI_ERR_TYPE;
} else {
- size_t size = smpi_datatype_size(datatype);
+ size_t size = datatype->size();
if (size == 0) {
*count = 0;
return MPI_SUCCESS;
} else if (count<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_contiguous(count, old_type, new_type, 0);
+ return Datatype::create_contiguous(count, old_type, 0, new_type);
}
}
if (datatype == nullptr || *datatype == MPI_DATATYPE_NULL) {
return MPI_ERR_TYPE;
} else {
- smpi_datatype_commit(datatype);
+ (*datatype)->commit();
return MPI_SUCCESS;
}
}
} else if (count<0 || blocklen<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
+ return Datatype::create_vector(count, blocklen, stride, old_type, new_type);
}
}
} else if (count<0 || blocklen<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
+ return Datatype::create_hvector(count, blocklen, stride, old_type, new_type);
}
}
} else if (count<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
+ return Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
}
}
} else if (count<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
+ return Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
}
}
int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count*sizeof(int)));
for (int i = 0; i < count; i++)
blocklens[i]=blocklength;
- int retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
+ int retval = Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
xbt_free(blocklens);
return retval;
}
} else if (count<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
+ return Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
}
}
int* blocklens=(int*)xbt_malloc(blocklength*count*sizeof(int));
for (int i = 0; i < count; i++)
blocklens[i] = blocklength;
- int retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
+ int retval = Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
xbt_free(blocklens);
return retval;
}
if (count<0){
return MPI_ERR_COUNT;
} else {
- return smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
+ return Datatype::create_struct(count, blocklens, indices, old_types, new_type);
}
}
MPI_Aint disps[3] = {lb, 0, lb + extent};
MPI_Datatype types[3] = {MPI_LB, oldtype, MPI_UB};
- s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create(blocks, disps, 3, types);
- smpi_datatype_create(newtype, oldtype->size(), lb, lb + extent, sizeof(s_smpi_mpi_struct_t), subtype, DT_FLAG_VECTOR);
+ *newtype = new Type_Struct(oldtype->size(), lb, lb + extent, DT_FLAG_DERIVED, 3, blocks, disps, types);
(*newtype)->addflag(~DT_FLAG_COMMITED);
return MPI_SUCCESS;
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) {
+ } else if ((!origin_datatype->is_valid()) || (!target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else {
int rank = smpi_process_index();
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) {
+ } else if ((!origin_datatype->is_valid()) || (!target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else {
int rank = smpi_process_index();
win->get_group(&group);
int dst_traced = group->index(target_rank);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, nullptr);
- TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*smpi_datatype_size(origin_datatype));
+ TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*origin_datatype->size());
retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
target_datatype);
} else if ((origin_count < 0 || target_count < 0) ||
(origin_addr==nullptr && origin_count > 0)){
retval = MPI_ERR_COUNT;
- } else if ((!is_datatype_valid(origin_datatype)) ||
- (!is_datatype_valid(target_datatype))) {
+ } else if ((!origin_datatype->is_valid()) ||
+ (!target_datatype->is_valid())) {
retval = MPI_ERR_TYPE;
} else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
} else if (name == nullptr) {
return MPI_ERR_ARG;
} else {
- smpi_datatype_set_name(datatype, name);
+ datatype->set_name(name);
return MPI_SUCCESS;
}
}
} else if (name == nullptr) {
return MPI_ERR_ARG;
} else {
- smpi_datatype_get_name(datatype, name, len);
+ datatype->get_name(name, len);
return MPI_SUCCESS;
}
}
if (type==MPI_DATATYPE_NULL)
return MPI_ERR_TYPE;
else
- return smpi_type_attr_get(type, type_keyval, attribute_val, flag);
+ return type->attr_get(type_keyval, attribute_val, flag);
}
int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
if (type==MPI_DATATYPE_NULL)
return MPI_ERR_TYPE;
else
- return smpi_type_attr_put(type, type_keyval, attribute_val);
+ return type->attr_put(type_keyval, attribute_val);
}
int PMPI_Type_delete_attr (MPI_Datatype type, int type_keyval)
if (type==MPI_DATATYPE_NULL)
return MPI_ERR_TYPE;
else
- return smpi_type_attr_delete(type, type_keyval);
+ return type->attr_delete(type_keyval);
}
int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
void* extra_state)
{
- return smpi_type_keyval_create(copy_fn, delete_fn, keyval, extra_state);
+ return Datatype::keyval_create(copy_fn, delete_fn, keyval, extra_state);
}
int PMPI_Type_free_keyval(int* keyval) {
- return smpi_type_keyval_free(keyval);
+ return Datatype::keyval_free(keyval);
}
int PMPI_Info_create( MPI_Info *info){
int PMPI_Unpack(void* inbuf, int incount, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
if(incount<0 || outcount < 0 || inbuf==nullptr || outbuf==nullptr)
return MPI_ERR_ARG;
- if(!is_datatype_valid(type))
+ if(!type->is_valid())
return MPI_ERR_TYPE;
if(comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
- return smpi_mpi_unpack(inbuf, incount, position, outbuf,outcount,type, comm);
+ return type->unpack(inbuf, incount, position, outbuf,outcount, comm);
}
int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
if(incount<0 || outcount < 0|| inbuf==nullptr || outbuf==nullptr)
return MPI_ERR_ARG;
- if(!is_datatype_valid(type))
+ if(!type->is_valid())
return MPI_ERR_TYPE;
if(comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
- return smpi_mpi_pack(inbuf, incount, type, outbuf,outcount,position, comm);
+ return type->pack(inbuf, incount, outbuf,outcount,position, comm);
}
int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
if(incount<0)
return MPI_ERR_ARG;
- if(!is_datatype_valid(datatype))
+ if(!datatype->is_valid())
return MPI_ERR_TYPE;
if(comm==MPI_COMM_NULL)
return MPI_ERR_COMM;
- *size=incount*smpi_datatype_size(datatype);
+ *size=incount*datatype->size();
return MPI_SUCCESS;
}
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
if (!TRACE_smpi_view_internals())
- TRACE_smpi_send(rank, rank, dst_traced, 0, size*smpi_datatype_size(MPI_CURRENT_TYPE));
+ TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size());
Request::send(nullptr, size, MPI_CURRENT_TYPE, to , 0, MPI_COMM_WORLD);
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
if (!TRACE_smpi_view_internals())
- TRACE_smpi_send(rank, rank, dst_traced, 0, size*smpi_datatype_size(MPI_CURRENT_TYPE));
+ TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size());
MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD);
extra->root = root_traced;
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
- void *sendbuf = smpi_get_tmp_sendbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
mpi_coll_bcast_fun(sendbuf, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD);
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
- void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE));
- void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
+ void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
mpi_coll_reduce_fun(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD);
smpi_execute_flops(comp_size);
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
- void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE));
- void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
+ void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
mpi_coll_allreduce_fun(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD);
smpi_execute_flops(comp_size);
else
MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
- void *send = smpi_get_tmp_sendbuffer(send_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE));
- void *recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2));
+ void *send = smpi_get_tmp_sendbuffer(send_size*comm_size* MPI_CURRENT_TYPE->size());
+ void *recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
int rank = smpi_process_index();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
} else {
MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
}
- void *send = smpi_get_tmp_sendbuffer(send_size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *send = smpi_get_tmp_sendbuffer(send_size* MPI_CURRENT_TYPE->size());
void *recv = nullptr;
int root=0;
if(action[4])
int rank = MPI_COMM_WORLD->rank();
if(rank==root)
- recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2));
+ recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_GATHER;
} else
MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
- void *send = smpi_get_tmp_sendbuffer(send_size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *send = smpi_get_tmp_sendbuffer(send_size* MPI_CURRENT_TYPE->size());
void *recv = nullptr;
for(int i=0;i<comm_size;i++) {
recvcounts[i] = atoi(action[i+3]);
int rank = MPI_COMM_WORLD->rank();
if(rank==root)
- recv = smpi_get_tmp_recvbuffer(recv_sum* smpi_datatype_size(MPI_CURRENT_TYPE2));
+ recv = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_GATHERV;
TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
- void *sendbuf = smpi_get_tmp_sendbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE));
- void *recvbuf = smpi_get_tmp_recvbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
+ void *recvbuf = smpi_get_tmp_recvbuffer(size* MPI_CURRENT_TYPE->size());
mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD);
smpi_execute_flops(comp_size);
} else
MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
- void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* smpi_datatype_size(MPI_CURRENT_TYPE));
- void *recvbuf = smpi_get_tmp_recvbuffer(recvcount* smpi_datatype_size(MPI_CURRENT_TYPE2));
+ void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* MPI_CURRENT_TYPE->size());
+ void *recvbuf = smpi_get_tmp_recvbuffer(recvcount* MPI_CURRENT_TYPE2->size());
int rank = smpi_process_index();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
} else
MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
- void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* MPI_CURRENT_TYPE->size());
for(int i=0;i<comm_size;i++) {
recvcounts[i] = atoi(action[i+3]);
recv_sum=recv_sum+recvcounts[i];
disps[i] = 0;
}
- void *recvbuf = smpi_get_tmp_recvbuffer(recv_sum* smpi_datatype_size(MPI_CURRENT_TYPE2));
+ void *recvbuf = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
int rank = smpi_process_index();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
else
MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
- void *sendbuf = smpi_get_tmp_sendbuffer(send_buf_size* smpi_datatype_size(MPI_CURRENT_TYPE));
- void *recvbuf = smpi_get_tmp_recvbuffer(recv_buf_size* smpi_datatype_size(MPI_CURRENT_TYPE2));
+ void *sendbuf = smpi_get_tmp_sendbuffer(send_buf_size* MPI_CURRENT_TYPE->size());
+ void *recvbuf = smpi_get_tmp_recvbuffer(recv_buf_size* MPI_CURRENT_TYPE2->size());
for(int i=0;i<comm_size;i++) {
sendcounts[i] = atoi(action[i+3]);
// if((((flags & RECV) != 0) && ((flags & ACCUMULATE) !=0)) || (datatype->sizeof_substruct != 0)){
// // This part handles the problem of non-contiguous memory
// old_buf = buf;
-// buf_ = count==0 ? nullptr : xbt_malloc(count*smpi_datatype_size(datatype));
+// buf_ = count==0 ? nullptr : xbt_malloc(count*datatype->size());
// if ((datatype->sizeof_substruct != 0) && ((flags & SEND) != 0)) {
// subtype->serialize(old_buf, buf_, count, datatype->substruct);
// }
// }
// This part handles the problem of non-contiguous memory (for the unserialisation at the reception)
old_buf_ = old_buf;
- size_ = smpi_datatype_size(datatype) * count;
- smpi_datatype_use(datatype);
+ size_ = datatype->size() * count;
+ datatype->use();
comm_->use();
action_ = nullptr;
detached_ = 0;
if((*request)->refcount_<0) xbt_die("wrong refcount");
if((*request)->refcount_==0){
- smpi_datatype_unuse((*request)->old_type_);
+ (*request)->old_type_->unuse();
(*request)->comm_->unuse();
(*request)->print_request("Destroying");
delete *request;
MPI_Status stats[2];
int myid=smpi_process_index();
if ((comm->group()->index(dst) == myid) && (comm->group()->index(src) == myid)){
- smpi_datatype_copy(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype);
+ Datatype::copy(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype);
return;
}
requests[0] = isend_init(sendbuf, sendcount, sendtype, dst, sendtag, comm);
// // This part handles the problem of non-contignous memory the unserialization at the reception
// s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(datatype->substruct);
// if(req->flags_ & RECV)
-// subtype->unserialize(req->buf_, req->old_buf_, req->real_size_/smpi_datatype_size(datatype) ,
+// subtype->unserialize(req->buf_, req->old_buf_, req->real_size_/datatype->size() ,
// datatype->substruct, req->op_);
// xbt_free(req->buf_);
// }else
if(req->flags_ & RECV){//apply op on contiguous buffer for accumulate
- int n =req->real_size_/smpi_datatype_size(datatype);
+ int n =req->real_size_/datatype->size();
req->op_->apply(req->buf_, req->old_buf_, &n, datatype);
xbt_free(req->buf_);
}
//get receiver pointer
MPI_Win recv_win = connected_wins_[target_rank];
- if(target_count*smpi_datatype_get_extent(target_datatype)>recv_win->size_)
+ if(target_count*target_datatype->get_extent()>recv_win->size_)
return MPI_ERR_ARG;
void* recv_addr = static_cast<void*> ( static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_);
requests_->push_back(sreq);
xbt_mutex_release(mut_);
}else{
- smpi_datatype_copy(origin_addr, origin_count, origin_datatype, recv_addr, target_count, target_datatype);
+ Datatype::copy(origin_addr, origin_count, origin_datatype, recv_addr, target_count, target_datatype);
}
return MPI_SUCCESS;
//get sender pointer
MPI_Win send_win = connected_wins_[target_rank];
- if(target_count*smpi_datatype_get_extent(target_datatype)>send_win->size_)
+ if(target_count*target_datatype->get_extent()>send_win->size_)
return MPI_ERR_ARG;
void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
requests_->push_back(rreq);
xbt_mutex_release(mut_);
}else{
- smpi_datatype_copy(send_addr, target_count, target_datatype, origin_addr, origin_count, origin_datatype);
+ Datatype::copy(send_addr, target_count, target_datatype, origin_addr, origin_count, origin_datatype);
}
return MPI_SUCCESS;
//get receiver pointer
MPI_Win recv_win = connected_wins_[target_rank];
- if(target_count*smpi_datatype_get_extent(target_datatype)>recv_win->size_)
+ if(target_count*target_datatype->get_extent()>recv_win->size_)
return MPI_ERR_ARG;
void* recv_addr = static_cast<void*>(static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_);
src/smpi/colls/smpi_mvapich2_selector_stampede.h
src/smpi/private.h
src/smpi/private.hpp
- src/smpi/smpi_mpi_dt_private.h
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.hpp
src/smpi/smpi_group.cpp
src/smpi/smpi_group.hpp
src/smpi/smpi_mpi.cpp
- src/smpi/smpi_mpi_dt.cpp
src/smpi/smpi_datatype.cpp
src/smpi/smpi_datatype.hpp
src/smpi/smpi_op.cpp