From 29aa074252888a50d97e3069f51ffb8e6cf99101 Mon Sep 17 00:00:00 2001 From: degomme Date: Wed, 8 Mar 2017 17:47:27 +0100 Subject: [PATCH] First works on the datatypes. Still missing a lot. --- include/smpi/forward.hpp | 3 + include/smpi/smpi.h | 4 +- src/smpi/colls/allreduce-lr.cpp | 2 +- src/smpi/colls/allreduce-mvapich-rs.cpp | 8 +- .../colls/allreduce-ompi-ring-segmented.cpp | 4 +- src/smpi/colls/allreduce-rab-rdb.cpp | 4 +- src/smpi/colls/allreduce-rab1.cpp | 4 +- src/smpi/colls/allreduce-rab2.cpp | 4 +- src/smpi/colls/allreduce-rdb.cpp | 6 +- .../colls/allreduce-smp-binomial-pipeline.cpp | 4 +- src/smpi/colls/allreduce-smp-binomial.cpp | 4 +- src/smpi/colls/allreduce-smp-rdb.cpp | 6 +- src/smpi/colls/allreduce-smp-rsag-lr.cpp | 4 +- src/smpi/colls/allreduce-smp-rsag-rab.cpp | 4 +- src/smpi/colls/allreduce-smp-rsag.cpp | 4 +- .../colls/bcast-scatter-rdb-allgather.cpp | 2 +- src/smpi/colls/reduce-NTSL.cpp | 8 +- .../colls/reduce-arrival-pattern-aware.cpp | 8 +- src/smpi/colls/reduce-binomial.cpp | 4 +- src/smpi/colls/reduce-flat-tree.cpp | 2 +- src/smpi/colls/reduce-mvapich-knomial.cpp | 2 +- src/smpi/colls/reduce-ompi.cpp | 6 +- src/smpi/colls/reduce-scatter-gather.cpp | 8 +- src/smpi/colls/reduce_scatter-mpich.cpp | 20 +- src/smpi/colls/reduce_scatter-ompi.cpp | 8 +- src/smpi/private.h | 3 +- src/smpi/smpi_base.cpp | 10 +- src/smpi/smpi_datatype.cpp | 436 ++++++ src/smpi/smpi_datatype.hpp | 103 ++ src/smpi/smpi_mpi_dt.cpp | 1296 +++++++---------- src/smpi/smpi_op.cpp | 8 +- src/smpi/smpi_op.hpp | 2 +- src/smpi/smpi_pmpi.cpp | 6 +- src/smpi/smpi_request.cpp | 71 +- tools/cmake/DefinePackages.cmake | 2 + 35 files changed, 1224 insertions(+), 846 deletions(-) create mode 100644 src/smpi/smpi_datatype.cpp create mode 100644 src/smpi/smpi_datatype.hpp diff --git a/include/smpi/forward.hpp b/include/smpi/forward.hpp index 67e39d708a..1435748ee0 100644 --- a/include/smpi/forward.hpp +++ b/include/smpi/forward.hpp @@ -14,6 +14,7 @@ namespace simgrid { namespace smpi { class Comm; +class Datatype; class Group; class Op; class Request; @@ -29,6 +30,7 @@ class Win; } typedef simgrid::smpi::Comm SMPI_Comm; +typedef simgrid::smpi::Datatype SMPI_Datatype; typedef simgrid::smpi::Group SMPI_Group; typedef simgrid::smpi::Op SMPI_Op; typedef simgrid::smpi::Request SMPI_Request; @@ -41,6 +43,7 @@ typedef simgrid::smpi::Win SMPI_Win; #else typedef struct SMPI_Comm SMPI_Comm; +typedef struct SMPI_Datatype SMPI_Datatype; typedef struct SMPI_Group SMPI_Group; typedef struct SMPI_Op SMPI_Op; typedef struct SMPI_Request SMPI_Request; diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 589e9563cc..0c6d952ffb 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -238,8 +238,8 @@ typedef long long MPI_Offset; struct s_MPI_File; typedef struct s_MPI_File *MPI_File; -struct s_smpi_mpi_datatype; -typedef struct s_smpi_mpi_datatype *MPI_Datatype; + +typedef SMPI_Datatype *MPI_Datatype; typedef struct { int MPI_SOURCE; diff --git a/src/smpi/colls/allreduce-lr.cpp b/src/smpi/colls/allreduce-lr.cpp index 3148836c7f..52a3e7e1ba 100644 --- a/src/smpi/colls/allreduce-lr.cpp +++ b/src/smpi/colls/allreduce-lr.cpp @@ -82,7 +82,7 @@ smpi_coll_tuned_allreduce_lr(void *sbuf, void *rbuf, int rcount, // compute result to rbuf+recv_offset if(op!=MPI_OP_NULL) op->apply( (char *) sbuf + recv_offset, (char *) rbuf + recv_offset, - &count, &dtype); + &count, dtype); } // all-gather diff --git a/src/smpi/colls/allreduce-mvapich-rs.cpp b/src/smpi/colls/allreduce-mvapich-rs.cpp index bf8cba4d93..2bd21cea6e 100644 --- a/src/smpi/colls/allreduce-mvapich-rs.cpp +++ b/src/smpi/colls/allreduce-mvapich-rs.cpp @@ -94,7 +94,7 @@ int smpi_coll_tuned_allreduce_mvapich2_rs(void *sendbuf, /* do the reduction on received data. since the ordering is right, it doesn't matter whether the operation is commutative or not. */ - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, datatype); /* change the rank */ newrank = rank / 2; } @@ -132,10 +132,10 @@ int smpi_coll_tuned_allreduce_mvapich2_rs(void *sendbuf, if (is_commutative || (dst < rank)) { /* op is commutative OR the order is already right */ - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, datatype); } else { /* op is noncommutative and the order is not right */ - if(op!=MPI_OP_NULL) op->apply( recvbuf, tmp_buf, &count, &datatype); + 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, recvbuf, count, datatype); @@ -204,7 +204,7 @@ int smpi_coll_tuned_allreduce_mvapich2_rs(void *sendbuf, if(op!=MPI_OP_NULL) op->apply( (char *) tmp_buf + disps[recv_idx] * extent, (char *) recvbuf + disps[recv_idx] * extent, - &recv_cnt, &datatype); + &recv_cnt, datatype); /* update send_idx for next iteration */ send_idx = recv_idx; diff --git a/src/smpi/colls/allreduce-ompi-ring-segmented.cpp b/src/smpi/colls/allreduce-ompi-ring-segmented.cpp index 2130db4615..a7ae57b6fa 100644 --- a/src/smpi/colls/allreduce-ompi-ring-segmented.cpp +++ b/src/smpi/colls/allreduce-ompi-ring-segmented.cpp @@ -318,7 +318,7 @@ smpi_coll_tuned_allreduce_ompi_ring_segmented(void *sbuf, void *rbuf, int count, (phase * early_phase_segcount) : (phase * late_phase_segcount + split_phase)); tmprecv = ((char*)rbuf) + (block_offset + phase_offset) * extent; - if(op!=MPI_OP_NULL) op->apply( inbuf[inbi ^ 0x1], tmprecv, &phase_count, &dtype); + if(op!=MPI_OP_NULL) op->apply( inbuf[inbi ^ 0x1], tmprecv, &phase_count, dtype); /* send previous block to send_to */ Request::send(tmprecv, phase_count, dtype, send_to, 666, comm); @@ -344,7 +344,7 @@ smpi_coll_tuned_allreduce_ompi_ring_segmented(void *sbuf, void *rbuf, int count, (phase * early_phase_segcount) : (phase * late_phase_segcount + split_phase)); tmprecv = ((char*)rbuf) + (block_offset + phase_offset) * extent; - if(op!=MPI_OP_NULL) op->apply( inbuf[inbi], tmprecv, &phase_count, &dtype); + if(op!=MPI_OP_NULL) op->apply( inbuf[inbi], tmprecv, &phase_count, dtype); } /* Distribution loop - variation of ring allgather */ diff --git a/src/smpi/colls/allreduce-rab-rdb.cpp b/src/smpi/colls/allreduce-rab-rdb.cpp index cf36d06a26..34c0875bca 100644 --- a/src/smpi/colls/allreduce-rab-rdb.cpp +++ b/src/smpi/colls/allreduce-rab-rdb.cpp @@ -56,7 +56,7 @@ int smpi_coll_tuned_allreduce_rab_rdb(void *sbuff, void *rbuff, int count, // do the reduction on received data. since the // ordering is right, it doesn't matter whether // the operation is commutative or not. - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuff, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuff, &count, dtype); // change the rank newrank = rank / 2; @@ -126,7 +126,7 @@ int smpi_coll_tuned_allreduce_rab_rdb(void *sbuff, void *rbuff, int count, // This algorithm is used only for predefined ops // and predefined ops are always commutative. if(op!=MPI_OP_NULL) op->apply( (char *) tmp_buf + disps[recv_idx] * extent, - (char *) rbuff + disps[recv_idx] * extent, &recv_cnt, &dtype); + (char *) rbuff + disps[recv_idx] * extent, &recv_cnt, dtype); // update send_idx for next iteration send_idx = recv_idx; diff --git a/src/smpi/colls/allreduce-rab1.cpp b/src/smpi/colls/allreduce-rab1.cpp index 206ec1bee6..5741ab6acc 100644 --- a/src/smpi/colls/allreduce-rab1.cpp +++ b/src/smpi/colls/allreduce-rab1.cpp @@ -60,7 +60,7 @@ int smpi_coll_tuned_allreduce_rab1(void *sbuff, void *rbuff, tmp_buf, recv_cnt, dtype, dst, tag, comm, &status); if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *) recv + recv_idx * extent, &recv_cnt, - &dtype); + dtype); // update send_idx for next iteration send_idx = recv_idx; @@ -94,7 +94,7 @@ int smpi_coll_tuned_allreduce_rab1(void *sbuff, void *rbuff, tag, tmp_buf, recv_cnt, dtype, dst, tag, comm, &status); if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *) rbuff + recv_idx * extent, &recv_cnt, - &dtype); + dtype); // update send_idx for next iteration send_idx = recv_idx; diff --git a/src/smpi/colls/allreduce-rab2.cpp b/src/smpi/colls/allreduce-rab2.cpp index 7e239e3f39..04d10d8e6c 100644 --- a/src/smpi/colls/allreduce-rab2.cpp +++ b/src/smpi/colls/allreduce-rab2.cpp @@ -51,7 +51,7 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, memcpy(tmp, recv, nbytes); for (i = 1, s_offset = nbytes; i < nprocs; i++, s_offset = i * nbytes) - if(op!=MPI_OP_NULL) op->apply( (char *) recv + s_offset, tmp, &send_size, &dtype); + if(op!=MPI_OP_NULL) op->apply( (char *) recv + s_offset, tmp, &send_size, dtype); mpi_coll_allgather_fun(tmp, send_size, dtype, recv, send_size, dtype, comm); memcpy(rbuff, recv, count * s_extent); @@ -73,7 +73,7 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, for (i = 1, s_offset = nbytes; i < nprocs; i++, s_offset = i * nbytes) if(op!=MPI_OP_NULL) op->apply( (char *) recv + s_offset, (char *) rbuff + r_offset, - &send_size, &dtype); + &send_size, dtype); mpi_coll_allgather_fun((char *) rbuff + r_offset, send_size, dtype, rbuff, send_size, dtype, comm); diff --git a/src/smpi/colls/allreduce-rdb.cpp b/src/smpi/colls/allreduce-rdb.cpp index 8a6dafc460..8d52fc6d53 100644 --- a/src/smpi/colls/allreduce-rdb.cpp +++ b/src/smpi/colls/allreduce-rdb.cpp @@ -64,7 +64,7 @@ int smpi_coll_tuned_allreduce_rdb(void *sbuff, void *rbuff, int count, // do the reduction on received data. since the // ordering is right, it doesn't matter whether // the operation is commutative or not. - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuff, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuff, &count, dtype); // change the rank newrank = rank / 2; @@ -102,10 +102,10 @@ int smpi_coll_tuned_allreduce_rdb(void *sbuff, void *rbuff, int count, // we assume it is commuttive op // if (op -> op_commute || (dst < rank)) if ((dst < rank)) { - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuff, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuff, &count, dtype); } else // op is noncommutative and the order is not right { - if(op!=MPI_OP_NULL) op->apply( rbuff, tmp_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( rbuff, tmp_buf, &count, dtype); // copy result back into recvbuf Request::sendrecv(tmp_buf, count, dtype, rank, tag, rbuff, count, diff --git a/src/smpi/colls/allreduce-smp-binomial-pipeline.cpp b/src/smpi/colls/allreduce-smp-binomial-pipeline.cpp index 7c6ca812b0..701dd0ebae 100644 --- a/src/smpi/colls/allreduce-smp-binomial-pipeline.cpp +++ b/src/smpi/colls/allreduce-smp-binomial-pipeline.cpp @@ -99,7 +99,7 @@ int smpi_coll_tuned_allreduce_smp_binomial_pipeline(void *send_buf, if (src < comm_size) { recv_offset = phase * pcount * extent; Request::recv(tmp_buf, pcount, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *)recv_buf + recv_offset, &pcount, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *)recv_buf + recv_offset, &pcount, dtype); } } else { send_offset = phase * pcount * extent; @@ -123,7 +123,7 @@ int smpi_coll_tuned_allreduce_smp_binomial_pipeline(void *send_buf, if (src < comm_size) { recv_offset = (phase - 1) * pcount * extent; Request::recv(tmp_buf, pcount, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *)recv_buf + recv_offset, &pcount, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *)recv_buf + recv_offset, &pcount, dtype); } } else { dst = (inter_rank & (~mask)) * num_core; diff --git a/src/smpi/colls/allreduce-smp-binomial.cpp b/src/smpi/colls/allreduce-smp-binomial.cpp index 764e5365a9..865b276504 100644 --- a/src/smpi/colls/allreduce-smp-binomial.cpp +++ b/src/smpi/colls/allreduce-smp-binomial.cpp @@ -71,7 +71,7 @@ int smpi_coll_tuned_allreduce_smp_binomial(void *send_buf, void *recv_buf, src = (inter_rank * num_core) + (intra_rank | mask); if (src < comm_size) { Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); } } else { dst = (inter_rank * num_core) + (intra_rank & (~mask)); @@ -90,7 +90,7 @@ int smpi_coll_tuned_allreduce_smp_binomial(void *send_buf, void *recv_buf, src = (inter_rank | mask) * num_core; if (src < comm_size) { Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); } } else { dst = (inter_rank & (~mask)) * num_core; diff --git a/src/smpi/colls/allreduce-smp-rdb.cpp b/src/smpi/colls/allreduce-smp-rdb.cpp index 94490b6bec..b3036422b9 100644 --- a/src/smpi/colls/allreduce-smp-rdb.cpp +++ b/src/smpi/colls/allreduce-smp-rdb.cpp @@ -78,7 +78,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count, src = (inter_rank * num_core) + (intra_rank | mask); if (src < comm_size) { Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); } } else { dst = (inter_rank * num_core) + (intra_rank & (~mask)); @@ -115,7 +115,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count, } else { src = rank - num_core; Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); newrank = inter_rank / 2; } } else { @@ -141,7 +141,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count, /* exchange data in rdb manner */ Request::sendrecv(recv_buf, count, dtype, dst, tag, tmp_buf, count, dtype, dst, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); mask <<= 1; } } diff --git a/src/smpi/colls/allreduce-smp-rsag-lr.cpp b/src/smpi/colls/allreduce-smp-rsag-lr.cpp index 6f44f104ce..5ef7a768d6 100644 --- a/src/smpi/colls/allreduce-smp-rsag-lr.cpp +++ b/src/smpi/colls/allreduce-smp-rsag-lr.cpp @@ -72,7 +72,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_lr(void *send_buf, void *recv_buf, // if (src < ((inter_rank + 1) * num_core)) { if (src < comm_size) { Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); //printf("Node %d recv from node %d when mask is %d\n", rank, src, mask); } } else { @@ -131,7 +131,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_lr(void *send_buf, void *recv_buf, // result is in rbuf if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *) recv_buf + recv_offset, &recv_count, - &dtype); + dtype); } // INTER: allgather diff --git a/src/smpi/colls/allreduce-smp-rsag-rab.cpp b/src/smpi/colls/allreduce-smp-rsag-rab.cpp index eb1f9ece98..29eb8ccbaa 100644 --- a/src/smpi/colls/allreduce-smp-rsag-rab.cpp +++ b/src/smpi/colls/allreduce-smp-rsag-rab.cpp @@ -64,7 +64,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_rab(void *sbuf, void *rbuf, int count, // if (src < ((inter_rank + 1) * num_core)) { if (src < comm_size) { Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, dtype); //printf("Node %d recv from node %d when mask is %d\n", rank, src, mask); } } else { @@ -118,7 +118,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_rab(void *sbuf, void *rbuf, int count, tmp_buf, curr_count, dtype, (dst * num_core), tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *)rbuf + recv_offset, &curr_count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *)rbuf + recv_offset, &curr_count, dtype); mask *= 2; curr_count /= 2; diff --git a/src/smpi/colls/allreduce-smp-rsag.cpp b/src/smpi/colls/allreduce-smp-rsag.cpp index bee18b23b8..379d865962 100644 --- a/src/smpi/colls/allreduce-smp-rsag.cpp +++ b/src/smpi/colls/allreduce-smp-rsag.cpp @@ -71,7 +71,7 @@ int smpi_coll_tuned_allreduce_smp_rsag(void *send_buf, void *recv_buf, // if (src < ((inter_rank + 1) * num_core)) { if (src < comm_size) { Request::recv(tmp_buf, count, dtype, src, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype); //printf("Node %d recv from node %d when mask is %d\n", rank, src, mask); } } else { @@ -112,7 +112,7 @@ int smpi_coll_tuned_allreduce_smp_rsag(void *send_buf, void *recv_buf, // result is in rbuf if(op!=MPI_OP_NULL) op->apply( tmp_buf, (char *) recv_buf + recv_offset, &seg_count, - &dtype); + dtype); } // INTER: allgather diff --git a/src/smpi/colls/bcast-scatter-rdb-allgather.cpp b/src/smpi/colls/bcast-scatter-rdb-allgather.cpp index dd4e565465..4328434ebc 100644 --- a/src/smpi/colls/bcast-scatter-rdb-allgather.cpp +++ b/src/smpi/colls/bcast-scatter-rdb-allgather.cpp @@ -122,7 +122,7 @@ smpi_coll_tuned_bcast_scatter_rdb_allgather ( if (comm_size == 1) goto fn_exit; //if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN) - if(datatype->flags & DT_FLAG_CONTIGUOUS) + if(datatype->flags() & DT_FLAG_CONTIGUOUS) is_contig = 1; else { is_contig = 0; diff --git a/src/smpi/colls/reduce-NTSL.cpp b/src/smpi/colls/reduce-NTSL.cpp index 64d10191b3..f0af7519d8 100644 --- a/src/smpi/colls/reduce-NTSL.cpp +++ b/src/smpi/colls/reduce-NTSL.cpp @@ -72,12 +72,12 @@ int smpi_coll_tuned_reduce_NTSL(void *buf, void *rbuf, int count, if (count <= segment) { if (rank == root) { Request::recv(tmp_buf, count, datatype, from, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, datatype); } else if (rank == ((root - 1 + size) % size)) { Request::send(rbuf, count, datatype, to, tag, comm); } else { Request::recv(tmp_buf, count, datatype, from, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, datatype); Request::send(rbuf, count, datatype, to, tag, comm); } smpi_free_tmp_buffer(tmp_buf); @@ -104,7 +104,7 @@ int smpi_coll_tuned_reduce_NTSL(void *buf, void *rbuf, int count, for (i = 0; i < pipe_length; i++) { Request::wait(&recv_request_array[i], &status); if(op!=MPI_OP_NULL) op->apply( tmp_buf + (i * increment), (char *)rbuf + (i * increment), - &segment, &datatype); + &segment, datatype); } } @@ -126,7 +126,7 @@ int smpi_coll_tuned_reduce_NTSL(void *buf, void *rbuf, int count, for (i = 0; i < pipe_length; i++) { Request::wait(&recv_request_array[i], &status); if(op!=MPI_OP_NULL) op->apply( tmp_buf + (i * increment), (char *)rbuf + (i * increment), - &segment, &datatype); + &segment, datatype); send_request_array[i] = Request::isend((char *) rbuf + (i * increment), segment, datatype, to, (tag + i), comm); } diff --git a/src/smpi/colls/reduce-arrival-pattern-aware.cpp b/src/smpi/colls/reduce-arrival-pattern-aware.cpp index 51ac468a71..3486dfb5a1 100644 --- a/src/smpi/colls/reduce-arrival-pattern-aware.cpp +++ b/src/smpi/colls/reduce-arrival-pattern-aware.cpp @@ -129,7 +129,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, Request::send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm); Request::recv(tmp_buf, count, datatype, from, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, datatype); } } /* while loop */ } @@ -180,7 +180,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, } from = header_buf[myordering - 1]; Request::recv(tmp_buf, count, datatype, from, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, rbuf, &count, datatype); Request::send(rbuf, count, datatype, to, tag, comm); } } /* non-root */ @@ -257,7 +257,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, Request::recv(tmp_buf + (i * increment), segment, datatype, from, tag, comm, &status); if(op!=MPI_OP_NULL) op->apply( tmp_buf + (i * increment), - (char *)rbuf + (i * increment), &segment, &datatype); + (char *)rbuf + (i * increment), &segment, datatype); } } } /* while loop (sent_count < size-1 ) */ @@ -311,7 +311,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, for (i = 0; i < pipe_length; i++) { Request::wait(&recv_request_array[i], MPI_STATUS_IGNORE); if(op!=MPI_OP_NULL) op->apply( tmp_buf + (i * increment), (char *)rbuf + (i * increment), - &segment, &datatype); + &segment, datatype); send_request_array[i]=Request::isend((char *)rbuf + (i * increment), segment, datatype, to, tag, comm); } Request::waitall((pipe_length), send_request_array, send_status_array); diff --git a/src/smpi/colls/reduce-binomial.cpp b/src/smpi/colls/reduce-binomial.cpp index bf0a0782bb..53a802d389 100644 --- a/src/smpi/colls/reduce-binomial.cpp +++ b/src/smpi/colls/reduce-binomial.cpp @@ -62,9 +62,9 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, Request::recv(tmp_buf, count, datatype, source, tag, comm, &status); if (is_commutative) { - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, &datatype); + 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); + if(op!=MPI_OP_NULL) op->apply( recvbuf, tmp_buf, &count, datatype); smpi_datatype_copy(tmp_buf, count, datatype,recvbuf, count, datatype); } } diff --git a/src/smpi/colls/reduce-flat-tree.cpp b/src/smpi/colls/reduce-flat-tree.cpp index ebfabe49fc..b4c3635b32 100644 --- a/src/smpi/colls/reduce-flat-tree.cpp +++ b/src/smpi/colls/reduce-flat-tree.cpp @@ -56,7 +56,7 @@ smpi_coll_tuned_reduce_flat_tree(void *sbuf, void *rbuf, int count, } /* Call reduction function. */ - if(op!=MPI_OP_NULL) op->apply( inbuf, rbuf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( inbuf, rbuf, &count, dtype); } diff --git a/src/smpi/colls/reduce-mvapich-knomial.cpp b/src/smpi/colls/reduce-mvapich-knomial.cpp index f2fc5dadf7..f0183fefdb 100644 --- a/src/smpi/colls/reduce-mvapich-knomial.cpp +++ b/src/smpi/colls/reduce-mvapich-knomial.cpp @@ -195,7 +195,7 @@ int smpi_coll_tuned_reduce_mvapich2_knomial ( recv_iter++; if (is_commutative) { - if(op!=MPI_OP_NULL) op->apply( tmp_buf[index], recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf[index], recvbuf, &count, datatype); } } diff --git a/src/smpi/colls/reduce-ompi.cpp b/src/smpi/colls/reduce-ompi.cpp index 5c81b0c7fb..d71947c612 100644 --- a/src/smpi/colls/reduce-ompi.cpp +++ b/src/smpi/colls/reduce-ompi.cpp @@ -178,7 +178,7 @@ int smpi_coll_tuned_ompi_reduce_generic( void* sendbuf, void* recvbuf, int origi /* apply operation */ if(op!=MPI_OP_NULL) op->apply( local_op_buffer, accumbuf + segindex * segment_increment, - &recvcount, &datatype ); + &recvcount, datatype ); } else if ( segindex > 0 ) { void* accumulator = accumbuf + (segindex-1) * segment_increment; if( tree->tree_nextsize <= 1 ) { @@ -188,7 +188,7 @@ int smpi_coll_tuned_ompi_reduce_generic( void* sendbuf, void* recvbuf, int origi } } if(op!=MPI_OP_NULL) op->apply( local_op_buffer, accumulator, &prevcount, - &datatype ); + datatype ); /* all reduced on available data this step (i) complete, * pass to the next process unless you are the root. @@ -662,7 +662,7 @@ smpi_coll_tuned_reduce_ompi_basic_linear(void *sbuf, void *rbuf, int count, } /* Perform the reduction */ - if(op!=MPI_OP_NULL) op->apply( inbuf, rbuf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( inbuf, rbuf, &count, dtype); } if (NULL != inplace_temp) { diff --git a/src/smpi/colls/reduce-scatter-gather.cpp b/src/smpi/colls/reduce-scatter-gather.cpp index dbe4c18d5d..3f8709d47a 100644 --- a/src/smpi/colls/reduce-scatter-gather.cpp +++ b/src/smpi/colls/reduce-scatter-gather.cpp @@ -68,7 +68,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, newrank = -1; } else { Request::recv(tmp_buf, count, datatype, rank + 1, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_ptr, &new_count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_ptr, &new_count, datatype); newrank = rank / 2; } } else /* rank >= 2*rem */ @@ -123,7 +123,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, if(op!=MPI_OP_NULL) op->apply( (char *) tmp_buf + disps[recv_idx] * extent, (char *) recv_ptr + disps[recv_idx] * extent, - &recv_cnt, &datatype); + &recv_cnt, datatype); /* update send_idx for next iteration */ send_idx = recv_idx; @@ -245,7 +245,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, else { Request::recv(tmp_buf, count, datatype, rank + 1, tag, comm, &status); - if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, datatype); newrank = rank / 2; } } else /* rank >= 2*rem */ @@ -300,7 +300,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, if(op!=MPI_OP_NULL) op->apply( (char *) tmp_buf + disps[recv_idx] * extent, (char *) recvbuf + disps[recv_idx] * extent, - &recv_cnt, &datatype); + &recv_cnt, datatype); /* update send_idx for next iteration */ send_idx = recv_idx; diff --git a/src/smpi/colls/reduce_scatter-mpich.cpp b/src/smpi/colls/reduce_scatter-mpich.cpp index 878d311303..490620315e 100644 --- a/src/smpi/colls/reduce_scatter-mpich.cpp +++ b/src/smpi/colls/reduce_scatter-mpich.cpp @@ -92,12 +92,12 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int if (sendbuf != MPI_IN_PLACE) { if(op!=MPI_OP_NULL) op->apply( tmp_recvbuf, recvbuf, &recvcounts[rank], - &datatype); + datatype); } else { if(op!=MPI_OP_NULL) op->apply( tmp_recvbuf, ((char *)recvbuf+disps[rank]*extent), - &recvcounts[rank], &datatype); + &recvcounts[rank], datatype); /* we can't store the result at the beginning of recvbuf right here because there is useful data there that other process/processes need. at the @@ -108,7 +108,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int else { if (sendbuf != MPI_IN_PLACE) { if(op!=MPI_OP_NULL) op->apply( - recvbuf, tmp_recvbuf, &recvcounts[rank], &datatype); + recvbuf, tmp_recvbuf, &recvcounts[rank], datatype); /* copy result back into recvbuf */ mpi_errno = smpi_datatype_copy(tmp_recvbuf, recvcounts[rank], datatype, recvbuf, @@ -118,7 +118,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int else { if(op!=MPI_OP_NULL) op->apply( ((char *)recvbuf+disps[rank]*extent), - tmp_recvbuf, &recvcounts[rank], &datatype); + tmp_recvbuf, &recvcounts[rank], datatype); /* copy result back into recvbuf */ mpi_errno = smpi_datatype_copy(tmp_recvbuf, recvcounts[rank], datatype, @@ -235,7 +235,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_noncomm(void *sendbuf, void *recvbuf, i if(op!=MPI_OP_NULL) op->apply( incoming_data + recv_offset*true_extent, outgoing_data + recv_offset*true_extent, - &size, &datatype ); + &size, datatype ); /* buf0_was_inout = buf0_was_inout; */ } else { @@ -243,7 +243,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_noncomm(void *sendbuf, void *recvbuf, i if(op!=MPI_OP_NULL) op->apply( outgoing_data + recv_offset*true_extent, incoming_data + recv_offset*true_extent, - &size, &datatype); + &size, datatype); buf0_was_inout = !buf0_was_inout; } @@ -456,22 +456,22 @@ int smpi_coll_tuned_reduce_scatter_mpich_rdb(void *sendbuf, void *recvbuf, int r { if(op!=MPI_OP_NULL) op->apply( tmp_recvbuf, tmp_results, &blklens[0], - &datatype); + datatype); if(op!=MPI_OP_NULL) op->apply( ((char *)tmp_recvbuf + dis[1]*extent), ((char *)tmp_results + dis[1]*extent), - &blklens[1], &datatype); + &blklens[1], datatype); } } else { { if(op!=MPI_OP_NULL) op->apply( tmp_results, tmp_recvbuf, &blklens[0], - &datatype); + datatype); if(op!=MPI_OP_NULL) op->apply( ((char *)tmp_results + dis[1]*extent), ((char *)tmp_recvbuf + dis[1]*extent), - &blklens[1], &datatype); + &blklens[1], datatype); } /* copy result back into tmp_results */ mpi_errno = smpi_datatype_copy(tmp_recvbuf, 1, recvtype, diff --git a/src/smpi/colls/reduce_scatter-ompi.cpp b/src/smpi/colls/reduce_scatter-ompi.cpp index 1f37ef1074..30c272092b 100644 --- a/src/smpi/colls/reduce_scatter-ompi.cpp +++ b/src/smpi/colls/reduce_scatter-ompi.cpp @@ -132,7 +132,7 @@ smpi_coll_tuned_reduce_scatter_ompi_basic_recursivehalving(void *sbuf, comm, MPI_STATUS_IGNORE); /* integrate their results into our temp results */ - if(op!=MPI_OP_NULL) op->apply( recv_buf, result_buf, &count, &dtype); + if(op!=MPI_OP_NULL) op->apply( recv_buf, result_buf, &count, dtype); /* adjust rank to be the bottom "remain" ranks */ tmp_rank = rank / 2; @@ -246,7 +246,7 @@ smpi_coll_tuned_reduce_scatter_ompi_basic_recursivehalving(void *sbuf, if(op!=MPI_OP_NULL) op->apply( recv_buf + (ptrdiff_t)tmp_disps[recv_index] * extent, result_buf + (ptrdiff_t)tmp_disps[recv_index] * extent, - &recv_count, &dtype); + &recv_count, dtype); } /* update for next iteration */ @@ -482,7 +482,7 @@ smpi_coll_tuned_reduce_scatter_ompi_ring(void *sbuf, void *rbuf, int *rcounts, rbuf[prevblock] = inbuf[inbi ^ 0x1] (op) rbuf[prevblock] */ tmprecv = accumbuf + (ptrdiff_t)displs[prevblock] * extent; - if(op!=MPI_OP_NULL) op->apply( inbuf[inbi ^ 0x1], tmprecv, &(rcounts[prevblock]), &dtype); + if(op!=MPI_OP_NULL) op->apply( inbuf[inbi ^ 0x1], tmprecv, &(rcounts[prevblock]), dtype); /* send previous block to send_to */ Request::send(tmprecv, rcounts[prevblock], dtype, send_to, @@ -496,7 +496,7 @@ smpi_coll_tuned_reduce_scatter_ompi_ring(void *sbuf, void *rbuf, int *rcounts, /* Apply operation on the last block (my block) rbuf[rank] = inbuf[inbi] (op) rbuf[rank] */ tmprecv = accumbuf + (ptrdiff_t)displs[rank] * extent; - if(op!=MPI_OP_NULL) op->apply( inbuf[inbi], tmprecv, &(rcounts[rank]), &dtype); + 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); diff --git a/src/smpi/private.h b/src/smpi/private.h index 89908b34c6..81180ed9c3 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -18,6 +18,7 @@ #include "src/smpi/smpi_group.hpp" #include "src/smpi/smpi_comm.hpp" #include "src/smpi/smpi_op.hpp" +#include "src/smpi/smpi_datatype.hpp" #include "src/smpi/smpi_request.hpp" #include "src/smpi/smpi_topo.hpp" #include "src/smpi/smpi_win.hpp" @@ -150,8 +151,6 @@ XBT_PRIVATE void smpi_comm_copy_buffer_callback(smx_activity_t comm, void *buff, XBT_PRIVATE void smpi_comm_null_copy_buffer_callback(smx_activity_t comm, void *buff, size_t buff_size); -XBT_PRIVATE void print_request(const char *message, MPI_Request request); - XBT_PRIVATE int smpi_enabled(); XBT_PRIVATE void smpi_global_init(); XBT_PRIVATE void smpi_global_destroy(); diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index 94fa819b93..eb2f462b5e 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -367,7 +367,7 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat Request::unuse(&requests[index]); } if(op) /* op can be MPI_OP_NULL that does nothing */ - if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, datatype); } for(index = 0; index < size - 1; index++) { smpi_free_tmp_buffer(tmpbufs[index]); @@ -425,7 +425,7 @@ void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp } if(index < rank) { // #Request is below rank: it's a irecv - if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, datatype); } } }else{ @@ -433,7 +433,7 @@ void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp for (int other = 0; other < size - 1; other++) { Request::wait(&(requests[other]), MPI_STATUS_IGNORE); if(index < rank) { - if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, datatype); } } } @@ -486,7 +486,7 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat recvbuf_is_empty=0; } else // #Request is below rank: it's a irecv - if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, datatype); } } }else{ @@ -498,7 +498,7 @@ void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat smpi_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); + if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, datatype); } } } diff --git a/src/smpi/smpi_datatype.cpp b/src/smpi/smpi_datatype.cpp new file mode 100644 index 0000000000..3ff3f33bfe --- /dev/null +++ b/src/smpi/smpi_datatype.cpp @@ -0,0 +1,436 @@ +/* smpi_datatype.cpp -- MPI primitives to handle datatypes */ +/* Copyright (c) 2009-2015. 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 +#include +#include +#include +#include +#include + +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 + + +#define CREATE_MPI_DATATYPE(name, type) \ + static Datatype mpi_##name ( \ + (char*) # name, \ + sizeof(type), /* size */ \ + 0, /* lb */ \ + sizeof(type), /* ub = lb + size */ \ + DT_FLAG_BASIC /* flags */ \ + ); \ +const MPI_Datatype name = &mpi_##name; + +#define CREATE_MPI_DATATYPE_NULL(name) \ + static Datatype mpi_##name ( \ + (char*) # name, \ + 0, /* size */ \ + 0, /* lb */ \ + 0, /* ub = lb + size */ \ + DT_FLAG_BASIC /* flags */ \ + ); \ +const MPI_Datatype name = &mpi_##name; + +// Predefined data types +CREATE_MPI_DATATYPE(MPI_CHAR, char); +CREATE_MPI_DATATYPE(MPI_SHORT, short); +CREATE_MPI_DATATYPE(MPI_INT, int); +CREATE_MPI_DATATYPE(MPI_LONG, long); +CREATE_MPI_DATATYPE(MPI_LONG_LONG, long long); +CREATE_MPI_DATATYPE(MPI_SIGNED_CHAR, signed char); +CREATE_MPI_DATATYPE(MPI_UNSIGNED_CHAR, unsigned char); +CREATE_MPI_DATATYPE(MPI_UNSIGNED_SHORT, unsigned short); +CREATE_MPI_DATATYPE(MPI_UNSIGNED, unsigned int); +CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG, unsigned long); +CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG_LONG, unsigned long long); +CREATE_MPI_DATATYPE(MPI_FLOAT, float); +CREATE_MPI_DATATYPE(MPI_DOUBLE, double); +CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE, long double); +CREATE_MPI_DATATYPE(MPI_WCHAR, wchar_t); +CREATE_MPI_DATATYPE(MPI_C_BOOL, bool); +CREATE_MPI_DATATYPE(MPI_BYTE, int8_t); +CREATE_MPI_DATATYPE(MPI_INT8_T, int8_t); +CREATE_MPI_DATATYPE(MPI_INT16_T, int16_t); +CREATE_MPI_DATATYPE(MPI_INT32_T, int32_t); +CREATE_MPI_DATATYPE(MPI_INT64_T, int64_t); +CREATE_MPI_DATATYPE(MPI_UINT8_T, uint8_t); +CREATE_MPI_DATATYPE(MPI_UINT16_T, uint16_t); +CREATE_MPI_DATATYPE(MPI_UINT32_T, uint32_t); +CREATE_MPI_DATATYPE(MPI_UINT64_T, uint64_t); +CREATE_MPI_DATATYPE(MPI_C_FLOAT_COMPLEX, float _Complex); +CREATE_MPI_DATATYPE(MPI_C_DOUBLE_COMPLEX, double _Complex); +CREATE_MPI_DATATYPE(MPI_C_LONG_DOUBLE_COMPLEX, long double _Complex); +CREATE_MPI_DATATYPE(MPI_AINT, MPI_Aint); +CREATE_MPI_DATATYPE(MPI_OFFSET, MPI_Offset); + +CREATE_MPI_DATATYPE(MPI_FLOAT_INT, float_int); +CREATE_MPI_DATATYPE(MPI_LONG_INT, long_int); +CREATE_MPI_DATATYPE(MPI_DOUBLE_INT, double_int); +CREATE_MPI_DATATYPE(MPI_SHORT_INT, short_int); +CREATE_MPI_DATATYPE(MPI_2INT, int_int); +CREATE_MPI_DATATYPE(MPI_2FLOAT, float_float); +CREATE_MPI_DATATYPE(MPI_2DOUBLE, double_double); +CREATE_MPI_DATATYPE(MPI_2LONG, long_long); + +CREATE_MPI_DATATYPE(MPI_REAL, float); +CREATE_MPI_DATATYPE(MPI_REAL4, float); +CREATE_MPI_DATATYPE(MPI_REAL8, float); +CREATE_MPI_DATATYPE(MPI_REAL16, double); +CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX8); +CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX16); +CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX32); +CREATE_MPI_DATATYPE(MPI_INTEGER1, int); +CREATE_MPI_DATATYPE(MPI_INTEGER2, int16_t); +CREATE_MPI_DATATYPE(MPI_INTEGER4, int32_t); +CREATE_MPI_DATATYPE(MPI_INTEGER8, int64_t); +CREATE_MPI_DATATYPE(MPI_INTEGER16, integer128_t); + +CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE_INT, long_double_int); + +CREATE_MPI_DATATYPE_NULL(MPI_UB); +CREATE_MPI_DATATYPE_NULL(MPI_LB); +CREATE_MPI_DATATYPE(MPI_PACKED, char); +// Internal use only +CREATE_MPI_DATATYPE(MPI_PTR, void*); + +namespace simgrid{ +namespace smpi{ + +Datatype::Datatype(int size,int lb, int ub, int flags) : name_(nullptr), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), in_use_(1){ +#if HAVE_MC + if(MC_is_active()) + MC_ignore(&(in_use_), sizeof(in_use_)); +#endif +} + +//for predefined types, so in_use = 0. +Datatype::Datatype(char* name, int size,int lb, int ub, int flags) : name_(name), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), in_use_(0){ +#if HAVE_MC + if(MC_is_active()) + MC_ignore(&(in_use_), sizeof(in_use_)); +#endif +} + + +//TODO : subtypes ? +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){ + 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) { + smpi_type_key_elem elem = + static_cast(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); + if (ret != MPI_SUCCESS) { +// smpi_datatype_unuse(*new_t); +// *new_t = MPI_DATATYPE_NULL; + xbt_dict_cursor_free(&cursor); + } + if (flag) + xbt_dict_set_ext(attributes_, key, sizeof(int), value_out, nullptr); + } + } + } +} + +Datatype::~Datatype(){ + xbt_assert(in_use_ >= 0); + + if(flags_ & DT_FLAG_PREDEFINED) + return; + + //if still used, mark for deletion + if(in_use_!=0){ + flags_ |=DT_FLAG_DESTROYED; + return; + } + + if(attributes_ !=nullptr){ + xbt_dict_cursor_t cursor = nullptr; + char* key; + void * value; + int flag; + xbt_dict_foreach(attributes_, cursor, key, value){ + smpi_type_key_elem elem = + static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, key, sizeof(int))); + if(elem!=nullptr && elem->delete_fn!=nullptr) + elem->delete_fn(this,*key, value, &flag); + } + xbt_dict_free(&attributes_); + } + + xbt_free(name_); +} + + +void Datatype::use(){ + + in_use_++; + +#if HAVE_MC + if(MC_is_active()) + MC_ignore(&(in_use_), sizeof(in_use_)); +#endif +} + +void Datatype::unuse() +{ + if (in_use_ > 0) + in_use_--; + + if (in_use_ == 0) + this->~Datatype(); + +#if HAVE_MC + if(MC_is_active()) + MC_ignore(&(in_use_), sizeof(in_use_)); +#endif +} + +void Datatype::commit() +{ + flags_ |= DT_FLAG_COMMITED; +} + + +bool Datatype::is_valid(){ + return (flags_ & DT_FLAG_COMMITED); +} + +size_t Datatype::size(){ + return size_; +} + +int Datatype::flags(){ + return flags_; +} + +void Datatype::addflag(int flag){ + flags_ &= flag; +} + +MPI_Aint Datatype::lb(){ + return lb_; +} + +MPI_Aint Datatype::ub(){ + return ub_; +} + +char* Datatype::name(){ + return name_; +} + + +int Datatype::extent(MPI_Aint * lb, MPI_Aint * extent){ + *lb = lb_; + *extent = ub_ - lb_; + return MPI_SUCCESS; +} + +MPI_Aint Datatype::get_extent(){ + return ub_ - lb_; +} + +void Datatype::get_name(char* name, int* length){ + *length = strlen(name_); + strncpy(name, name_, *length+1); +} + +void Datatype::set_name(char* name){ + if(name_!=nullptr && (flags_ & DT_FLAG_PREDEFINED) == 0) + xbt_free(name_); + name_ = xbt_strdup(name); +} + +int Datatype::attr_delete(int keyval){ + smpi_type_key_elem elem = + static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&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(this, keyval, &value, &flag)==MPI_SUCCESS){ + int ret = elem->delete_fn(this, keyval, value, &flag); + if(ret!=MPI_SUCCESS) + return ret; + } + } + if(attributes_==nullptr) + return MPI_ERR_ARG; + + xbt_dict_remove_ext(attributes_, reinterpret_cast(&keyval), sizeof(int)); + return MPI_SUCCESS; +} + + +int Datatype::attr_get(int keyval, void* attr_value, int* flag){ + smpi_type_key_elem elem = + static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); + if(elem==nullptr) + return MPI_ERR_ARG; + if(attributes_==nullptr){ + *flag=0; + return MPI_SUCCESS; + } + try { + *static_cast(attr_value) = xbt_dict_get_ext(attributes_, reinterpret_cast(&keyval), sizeof(int)); + *flag=1; + } + catch (xbt_ex& ex) { + *flag=0; + } + return MPI_SUCCESS; +} + +int Datatype::attr_put(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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); + if(elem==nullptr) + return MPI_ERR_ARG; + int flag; + void* value = nullptr; + smpi_type_attr_get(this, 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) + return ret; + } + if(attributes_==nullptr) + attributes_ = xbt_dict_new_homogeneous(nullptr); + + xbt_dict_set_ext(attributes_, reinterpret_cast(&keyval), sizeof(int), attr_value, nullptr); + return MPI_SUCCESS; +} + +int Datatype::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(keyval), sizeof(int),reinterpret_cast(value), nullptr); + type_keyval_id++; + return MPI_SUCCESS; +} + +int Datatype::keyval_free(int* keyval){ + smpi_type_key_elem elem = + static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int))); + if(elem==0){ + return MPI_ERR_ARG; + } + xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int)); + xbt_free(elem); + return MPI_SUCCESS; +} + + +int Datatype::pack(void* inbuf, int incount, void* outbuf, int outcount, int* position,MPI_Comm comm){ + if (outcount - *position < incount*static_cast(size_)) + return MPI_ERR_BUFFER; + Datatype::copy(inbuf, incount, this, static_cast(outbuf) + *position, outcount, MPI_CHAR); + *position += incount * size_; + return MPI_SUCCESS; +} + +int Datatype::unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount,MPI_Comm comm){ + if (outcount*(int)size_> insize) + return MPI_ERR_BUFFER; + Datatype::copy(static_cast(inbuf) + *position, insize, MPI_CHAR, outbuf, outcount, this); + *position += outcount * size_; + return MPI_SUCCESS; +} + + +int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int recvcount, MPI_Datatype recvtype){ +// int count; + if(smpi_privatize_global_variables){ + smpi_switch_data_segment(smpi_process_index()); + } + /* First check if we really have something to do */ + if (recvcount > 0 && recvbuf != sendbuf) { + /* FIXME: treat packed cases */ + sendcount *= sendtype->size(); + recvcount *= recvtype->size(); +// count = sendcount < recvcount ? sendcount : recvcount; + +// if(sendtype->sizeof_substruct == 0 && recvtype->sizeof_substruct == 0) { +// if(!smpi_process_get_replaying()) +// memcpy(recvbuf, sendbuf, count); +// } +// else if (sendtype->sizeof_substruct == 0) +// { +// s_smpi_subtype_t *subtype = static_cast(recvtype->substruct); +// subtype->unserialize( sendbuf, recvbuf, recvcount/smpi_datatype_size(recvtype), subtype, MPI_REPLACE); +// } +// else if (recvtype->sizeof_substruct == 0) +// { +// s_smpi_subtype_t *subtype = static_cast(sendtype->substruct); +// subtype->serialize(sendbuf, recvbuf, sendcount/smpi_datatype_size(sendtype), subtype); +// }else{ +// s_smpi_subtype_t *subtype = static_cast(sendtype->substruct); + +// void * buf_tmp = xbt_malloc(count); + +// subtype->serialize( sendbuf, buf_tmp,count/smpi_datatype_size(sendtype), subtype); +// subtype = static_cast(recvtype->substruct); +// subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype, MPI_REPLACE); + +// xbt_free(buf_tmp); +// } + } + + return sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; +} + +//Default serialization method : memcpy. +void Datatype::serialize( void* noncontiguous, void *contiguous, int count, void *type){ + char* contiguous_char = static_cast(contiguous); + char* noncontiguous_char = static_cast(noncontiguous)+lb_; + memcpy(contiguous_char, noncontiguous_char, count*size_); + +} + +void Datatype::unserialize( void* contiguous, void *noncontiguous, int count, void *type, MPI_Op op){ + char* contiguous_char = static_cast(contiguous); + char* noncontiguous_char = static_cast(noncontiguous)+lb_; + int n=count; + if(op!=MPI_OP_NULL) + op->apply( contiguous_char, noncontiguous_char, &n, this); +} + + + +} +} + diff --git a/src/smpi/smpi_datatype.hpp b/src/smpi/smpi_datatype.hpp new file mode 100644 index 0000000000..65eb838fe9 --- /dev/null +++ b/src/smpi/smpi_datatype.hpp @@ -0,0 +1,103 @@ +/* Copyright (c) 2009-2010, 2012-2014. 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_DATATYPE_HPP +#define SMPI_DATATYPE_HPP + +#include + +#include "private.h" + +#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) + +namespace simgrid{ +namespace smpi{ + +class Datatype{ +//TODO: remove + public: + char* name_; + size_t size_; + MPI_Aint lb_; + MPI_Aint ub_; + int flags_; + xbt_dict_t attributes_; + int in_use_; + + 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(); + void use(); + void unuse(); + void commit(); + bool is_valid(); + size_t size(); + int flags(); + void addflag(int flag); + MPI_Aint lb(); + MPI_Aint ub(); + int extent(MPI_Aint * lb, MPI_Aint * extent); + MPI_Aint get_extent(); + char* name(); + void get_name(char* name, int* length); + 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); + 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_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state); + 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); +}; + +class Type_Contiguous:Datatype{ +}; + +class Type_Vector:Datatype{ +}; + +class Type_Hvector:Datatype{ +}; + +class Type_Indexed:Datatype{ +}; + +class Type_Hindexed:Datatype{ +}; + +class Type_Struct:Datatype{ +}; + + +} +} + +#endif diff --git a/src/smpi/smpi_mpi_dt.cpp b/src/smpi/smpi_mpi_dt.cpp index b029c1c1e1..717bb1fbd1 100644 --- a/src/smpi/smpi_mpi_dt.cpp +++ b/src/smpi/smpi_mpi_dt.cpp @@ -16,170 +16,40 @@ #include #include -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 - -#define CREATE_MPI_DATATYPE(name, type) \ - static s_smpi_mpi_datatype_t mpi_##name = { \ - (char*) # name, \ - sizeof(type), /* size */ \ - 0, /*was 1 sizeof_substruct*/ \ - 0, /* lb */ \ - sizeof(type), /* ub = lb + size */ \ - DT_FLAG_BASIC, /* flags */ \ - nullptr, /* attributes */ \ - nullptr, /* pointer on extended struct*/ \ - 0 /* in_use counter */ \ - }; \ -const MPI_Datatype name = &mpi_##name; - -#define CREATE_MPI_DATATYPE_NULL(name) \ - static s_smpi_mpi_datatype_t mpi_##name = { \ - (char*) # name, \ - 0, /* size */ \ - 0, /* was 1 sizeof_substruct*/ \ - 0, /* lb */ \ - 0, /* ub = lb + size */ \ - DT_FLAG_BASIC, /* flags */ \ - nullptr, /* attributes */ \ - nullptr, /* pointer on extended struct*/ \ - 0 /* in_use counter */ \ - }; \ -const MPI_Datatype name = &mpi_##name; - - -// Predefined data types -CREATE_MPI_DATATYPE(MPI_CHAR, char); -CREATE_MPI_DATATYPE(MPI_SHORT, short); -CREATE_MPI_DATATYPE(MPI_INT, int); -CREATE_MPI_DATATYPE(MPI_LONG, long); -CREATE_MPI_DATATYPE(MPI_LONG_LONG, long long); -CREATE_MPI_DATATYPE(MPI_SIGNED_CHAR, signed char); -CREATE_MPI_DATATYPE(MPI_UNSIGNED_CHAR, unsigned char); -CREATE_MPI_DATATYPE(MPI_UNSIGNED_SHORT, unsigned short); -CREATE_MPI_DATATYPE(MPI_UNSIGNED, unsigned int); -CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG, unsigned long); -CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG_LONG, unsigned long long); -CREATE_MPI_DATATYPE(MPI_FLOAT, float); -CREATE_MPI_DATATYPE(MPI_DOUBLE, double); -CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE, long double); -CREATE_MPI_DATATYPE(MPI_WCHAR, wchar_t); -CREATE_MPI_DATATYPE(MPI_C_BOOL, bool); -CREATE_MPI_DATATYPE(MPI_BYTE, int8_t); -CREATE_MPI_DATATYPE(MPI_INT8_T, int8_t); -CREATE_MPI_DATATYPE(MPI_INT16_T, int16_t); -CREATE_MPI_DATATYPE(MPI_INT32_T, int32_t); -CREATE_MPI_DATATYPE(MPI_INT64_T, int64_t); -CREATE_MPI_DATATYPE(MPI_UINT8_T, uint8_t); -CREATE_MPI_DATATYPE(MPI_UINT16_T, uint16_t); -CREATE_MPI_DATATYPE(MPI_UINT32_T, uint32_t); -CREATE_MPI_DATATYPE(MPI_UINT64_T, uint64_t); -CREATE_MPI_DATATYPE(MPI_C_FLOAT_COMPLEX, float _Complex); -CREATE_MPI_DATATYPE(MPI_C_DOUBLE_COMPLEX, double _Complex); -CREATE_MPI_DATATYPE(MPI_C_LONG_DOUBLE_COMPLEX, long double _Complex); -CREATE_MPI_DATATYPE(MPI_AINT, MPI_Aint); -CREATE_MPI_DATATYPE(MPI_OFFSET, MPI_Offset); - -CREATE_MPI_DATATYPE(MPI_FLOAT_INT, float_int); -CREATE_MPI_DATATYPE(MPI_LONG_INT, long_int); -CREATE_MPI_DATATYPE(MPI_DOUBLE_INT, double_int); -CREATE_MPI_DATATYPE(MPI_SHORT_INT, short_int); -CREATE_MPI_DATATYPE(MPI_2INT, int_int); -CREATE_MPI_DATATYPE(MPI_2FLOAT, float_float); -CREATE_MPI_DATATYPE(MPI_2DOUBLE, double_double); -CREATE_MPI_DATATYPE(MPI_2LONG, long_long); - -CREATE_MPI_DATATYPE(MPI_REAL, float); -CREATE_MPI_DATATYPE(MPI_REAL4, float); -CREATE_MPI_DATATYPE(MPI_REAL8, float); -CREATE_MPI_DATATYPE(MPI_REAL16, double); -CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX8); -CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX16); -CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX32); -CREATE_MPI_DATATYPE(MPI_INTEGER1, int); -CREATE_MPI_DATATYPE(MPI_INTEGER2, int16_t); -CREATE_MPI_DATATYPE(MPI_INTEGER4, int32_t); -CREATE_MPI_DATATYPE(MPI_INTEGER8, int64_t); -CREATE_MPI_DATATYPE(MPI_INTEGER16, integer128_t); - -CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE_INT, long_double_int); - -CREATE_MPI_DATATYPE_NULL(MPI_UB); -CREATE_MPI_DATATYPE_NULL(MPI_LB); -CREATE_MPI_DATATYPE(MPI_PACKED, char); -// Internal use only -CREATE_MPI_DATATYPE(MPI_PTR, void*); +//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); + return datatype != MPI_DATATYPE_NULL && ((datatype->flags_ & DT_FLAG_COMMITED) != 0); } size_t smpi_datatype_size(MPI_Datatype datatype) { - return datatype->size; + return datatype->size_; } MPI_Aint smpi_datatype_lb(MPI_Datatype datatype) { - return datatype->lb; + return datatype->lb_; } MPI_Aint smpi_datatype_ub(MPI_Datatype datatype) { - return datatype->ub; + return datatype->ub_; } int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t) { int ret=MPI_SUCCESS; - *new_t= xbt_new(s_smpi_mpi_datatype_t,1); - memcpy(*new_t, datatype, sizeof(s_smpi_mpi_datatype_t)); - (*new_t)->in_use=1; - (*new_t)->flags &= ~DT_FLAG_PREDEFINED; - if (datatype->sizeof_substruct){ - (*new_t)->substruct=xbt_malloc(datatype->sizeof_substruct); - memcpy((*new_t)->substruct, datatype->substruct, datatype->sizeof_substruct); - } - if(datatype->name) - (*new_t)->name = xbt_strdup(datatype->name); - if(datatype->attributes !=nullptr){ - (*new_t)->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) { - smpi_type_key_elem elem = - static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, key, sizeof(int))); - if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) { - 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; - xbt_dict_cursor_free(&cursor); - return ret; - } - if (flag) - xbt_dict_set_ext((*new_t)->attributes, key, sizeof(int), value_out, nullptr); - } - } - } return ret; } int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent) { - if(datatype == MPI_DATATYPE_NULL){ - *lb=0; - *extent=0; - return MPI_SUCCESS; - } - *lb = datatype->lb; - *extent = datatype->ub - datatype->lb; return MPI_SUCCESS; } @@ -187,60 +57,24 @@ MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype){ if(datatype == MPI_DATATYPE_NULL){ return 0; } - return datatype->ub - datatype->lb; + 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); + *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); + 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) { - int count; - if(smpi_privatize_global_variables){ - smpi_switch_data_segment(smpi_process_index()); - } - /* First check if we really have something to do */ - if (recvcount > 0 && recvbuf != sendbuf) { - /* FIXME: treat packed cases */ - sendcount *= smpi_datatype_size(sendtype); - recvcount *= smpi_datatype_size(recvtype); - count = sendcount < recvcount ? sendcount : recvcount; - - if(sendtype->sizeof_substruct == 0 && recvtype->sizeof_substruct == 0) { - if(!smpi_process_get_replaying()) - memcpy(recvbuf, sendbuf, count); - } - else if (sendtype->sizeof_substruct == 0) - { - s_smpi_subtype_t *subtype = static_cast(recvtype->substruct); - subtype->unserialize( sendbuf, recvbuf, recvcount/smpi_datatype_size(recvtype), subtype, MPI_REPLACE); - } - else if (recvtype->sizeof_substruct == 0) - { - s_smpi_subtype_t *subtype = static_cast(sendtype->substruct); - subtype->serialize(sendbuf, recvbuf, sendcount/smpi_datatype_size(sendtype), subtype); - }else{ - s_smpi_subtype_t *subtype = static_cast(sendtype->substruct); - - void * buf_tmp = xbt_malloc(count); - - subtype->serialize( sendbuf, buf_tmp,count/smpi_datatype_size(sendtype), subtype); - subtype = static_cast(recvtype->substruct); - subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype, MPI_REPLACE); - - xbt_free(buf_tmp); - } - } - + return sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS; } @@ -255,25 +89,25 @@ int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, */ void serialize_vector( void* noncontiguous_vector, void *contiguous_vector, int count, void *type) { - s_smpi_mpi_vector_t* type_c = reinterpret_cast(type); - int i; - char* contiguous_vector_char = static_cast(contiguous_vector); - char* noncontiguous_vector_char = static_cast(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(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); - } +// s_smpi_mpi_vector_t* type_c = reinterpret_cast(type); +// int i; +// char* contiguous_vector_char = static_cast(contiguous_vector); +// char* noncontiguous_vector_char = static_cast(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(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); +// } } /* @@ -287,27 +121,27 @@ void serialize_vector( void* noncontiguous_vector, void *contiguous_vector, int */ 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(type); - int i; - - char* contiguous_vector_char = static_cast(contiguous_vector); - char* noncontiguous_vector_char = static_cast(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(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); - } +// s_smpi_mpi_vector_t* type_c = reinterpret_cast(type); +// int i; + +// char* contiguous_vector_char = static_cast(contiguous_vector); +// char* noncontiguous_vector_char = static_cast(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(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 @@ -330,93 +164,93 @@ s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride, int block_le 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 +// 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(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; +// 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(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((type)->substruct)->subtype_use(&type); - } -#if HAVE_MC - if(MC_is_active()) - MC_ignore(&(type->in_use), sizeof(type->in_use)); -#endif +// if(type == MPI_DATATYPE_NULL) +// return; +// type->in_use++; + +// if(type->sizeof_substruct!=0){ +// static_cast((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 == MPI_DATATYPE_NULL) +// return; - if (type->in_use > 0) - type->in_use--; +// if (type->in_use > 0) +// type->in_use--; - if(type->sizeof_substruct!=0){ - static_cast((type)->substruct)->subtype_free(&type); - } +// if(type->sizeof_substruct!=0){ +// static_cast((type)->substruct)->subtype_free(&type); +// } - if (type->in_use == 0) - smpi_datatype_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 +//#if HAVE_MC +// if(MC_is_active()) +// MC_ignore(&(type->in_use), sizeof(type->in_use)); +//#endif } /*Contiguous Implementation*/ @@ -446,20 +280,20 @@ void serialize_contiguous( void* noncontiguous_hvector, void *contiguous_hvector */ 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(type); - char* contiguous_vector_char = static_cast(contiguous_vector); - char* noncontiguous_vector_char = static_cast(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); +// s_smpi_mpi_contiguous_t* type_c = reinterpret_cast(type); +// char* contiguous_vector_char = static_cast(contiguous_vector); +// char* noncontiguous_vector_char = static_cast(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((*d)->substruct)->old_type); +// smpi_datatype_unuse(reinterpret_cast((*d)->substruct)->old_type); } void use_contiguous(MPI_Datatype* d){ - smpi_datatype_use(reinterpret_cast((*d)->substruct)->old_type); +// smpi_datatype_use(reinterpret_cast((*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 @@ -485,15 +319,15 @@ s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block 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); +// 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; } @@ -501,36 +335,36 @@ int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new 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); +// 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((*d)->substruct)->old_type); +// smpi_datatype_unuse(reinterpret_cast((*d)->substruct)->old_type); } void use_vector(MPI_Datatype* d){ - smpi_datatype_use(reinterpret_cast((*d)->substruct)->old_type); +// smpi_datatype_use(reinterpret_cast((*d)->substruct)->old_type); } /* Hvector Implementation - Vector with stride in bytes */ @@ -545,25 +379,25 @@ void use_vector(MPI_Datatype* d){ */ void serialize_hvector( void* noncontiguous_hvector, void *contiguous_hvector, int count, void *type) { - s_smpi_mpi_hvector_t* type_c = reinterpret_cast(type); - int i; - char* contiguous_vector_char = static_cast(contiguous_hvector); - char* noncontiguous_vector_char = static_cast(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(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; - } +// s_smpi_mpi_hvector_t* type_c = reinterpret_cast(type); +// int i; +// char* contiguous_vector_char = static_cast(contiguous_hvector); +// char* noncontiguous_vector_char = static_cast(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(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 @@ -575,26 +409,26 @@ void serialize_hvector( void* noncontiguous_hvector, void *contiguous_hvector, i */ 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(type); - int i; - - char* contiguous_vector_char = static_cast(contiguous_vector); - char* noncontiguous_vector_char = static_cast(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(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; - } +// s_smpi_mpi_hvector_t* type_c = reinterpret_cast(type); +// int i; + +// char* contiguous_vector_char = static_cast(contiguous_vector); +// char* noncontiguous_vector_char = static_cast(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(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 @@ -619,35 +453,35 @@ s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride, int b //do nothing for vector types void free_hvector(MPI_Datatype* d){ - smpi_datatype_unuse(reinterpret_cast((*d)->substruct)->old_type); +// smpi_datatype_unuse(reinterpret_cast((*d)->substruct)->old_type); } void use_hvector(MPI_Datatype* d){ - smpi_datatype_use(reinterpret_cast((*d)->substruct)->old_type); +// smpi_datatype_use(reinterpret_cast((*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; - } +// 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; } @@ -663,28 +497,28 @@ int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype */ void serialize_indexed( void* noncontiguous_indexed, void *contiguous_indexed, int count, void *type) { - s_smpi_mpi_indexed_t* type_c = reinterpret_cast(type); - char* contiguous_indexed_char = static_cast(contiguous_indexed); - char* noncontiguous_indexed_char = static_cast(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(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 (iblock_count-1) - noncontiguous_indexed_char = - static_cast(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); - } +// s_smpi_mpi_indexed_t* type_c = reinterpret_cast(type); +// char* contiguous_indexed_char = static_cast(contiguous_indexed); +// char* noncontiguous_indexed_char = static_cast(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(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 (iblock_count-1) +// noncontiguous_indexed_char = +// static_cast(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 @@ -696,43 +530,43 @@ void serialize_indexed( void* noncontiguous_indexed, void *contiguous_indexed, i */ 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(type); - char* contiguous_indexed_char = static_cast(contiguous_indexed); - char* noncontiguous_indexed_char = - static_cast(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(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 (iblock_count-1) - noncontiguous_indexed_char = - static_cast(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(noncontiguous_indexed_char); - } +// s_smpi_mpi_indexed_t* type_c = reinterpret_cast(type); +// char* contiguous_indexed_char = static_cast(contiguous_indexed); +// char* noncontiguous_indexed_char = +// static_cast(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(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 (iblock_count-1) +// noncontiguous_indexed_char = +// static_cast(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(noncontiguous_indexed_char); +// } } void free_indexed(MPI_Datatype* type){ - if((*type)->in_use==0){ - xbt_free(reinterpret_cast((*type)->substruct)->block_lengths); - xbt_free(reinterpret_cast((*type)->substruct)->block_indices); - } - smpi_datatype_unuse(reinterpret_cast((*type)->substruct)->old_type); +// if((*type)->in_use==0){ +// xbt_free(reinterpret_cast((*type)->substruct)->block_lengths); +// xbt_free(reinterpret_cast((*type)->substruct)->block_indices); +// } +// smpi_datatype_unuse(reinterpret_cast((*type)->substruct)->old_type); } void use_indexed(MPI_Datatype* type){ - smpi_datatype_use(reinterpret_cast((*type)->substruct)->old_type); +// smpi_datatype_use(reinterpret_cast((*type)->substruct)->old_type); } @@ -760,41 +594,41 @@ s_smpi_mpi_indexed_t* smpi_datatype_indexed_create( int* block_lengths, int* blo 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)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); - } +// 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)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 */ @@ -809,27 +643,27 @@ int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype */ void serialize_hindexed( void* noncontiguous_hindexed, void *contiguous_hindexed, int count, void *type) { - s_smpi_mpi_hindexed_t* type_c = reinterpret_cast(type); - char* contiguous_hindexed_char = static_cast(contiguous_hindexed); - char* noncontiguous_hindexed_char = static_cast(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(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 (iblock_count-1) - noncontiguous_hindexed_char = static_cast(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(noncontiguous_hindexed_char); - } +// s_smpi_mpi_hindexed_t* type_c = reinterpret_cast(type); +// char* contiguous_hindexed_char = static_cast(contiguous_hindexed); +// char* noncontiguous_hindexed_char = static_cast(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(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 (iblock_count-1) +// noncontiguous_hindexed_char = static_cast(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(noncontiguous_hindexed_char); +// } } /* Copies contiguous data into noncontiguous memory. * @param noncontiguous_hindexed - output hindexed @@ -842,42 +676,42 @@ void serialize_hindexed( void* noncontiguous_hindexed, void *contiguous_hindexed 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(type); - - char* contiguous_hindexed_char = static_cast(contiguous_hindexed); - char* noncontiguous_hindexed_char = static_cast(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(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 (iblock_count-1) - noncontiguous_hindexed_char = static_cast(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(noncontiguous_hindexed_char); - } +// s_smpi_mpi_hindexed_t* type_c = reinterpret_cast(type); + +// char* contiguous_hindexed_char = static_cast(contiguous_hindexed); +// char* noncontiguous_hindexed_char = static_cast(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(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 (iblock_count-1) +// noncontiguous_hindexed_char = static_cast(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(noncontiguous_hindexed_char); +// } } void free_hindexed(MPI_Datatype* type){ - if((*type)->in_use==0){ - xbt_free(reinterpret_cast((*type)->substruct)->block_lengths); - xbt_free(reinterpret_cast((*type)->substruct)->block_indices); - } - smpi_datatype_unuse(reinterpret_cast((*type)->substruct)->old_type); +// if((*type)->in_use==0){ +// xbt_free(reinterpret_cast((*type)->substruct)->block_lengths); +// xbt_free(reinterpret_cast((*type)->substruct)->block_indices); +// } +// smpi_datatype_unuse(reinterpret_cast((*type)->substruct)->old_type); } void use_hindexed(MPI_Datatype* type){ - smpi_datatype_use(reinterpret_cast((*type)->substruct)->old_type); +// smpi_datatype_use(reinterpret_cast((*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 @@ -905,39 +739,39 @@ s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create( int* block_lengths, MPI_Ai 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)ub) - ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_type); - - if ( (i< count -1) && (indices[i]+blocklens[i]*(static_cast(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); - } +// 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)ub) +// ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_type); + +// if ( (i< count -1) && (indices[i]+blocklens[i]*(static_cast(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; } @@ -953,29 +787,29 @@ int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Dat */ void serialize_struct( void* noncontiguous_struct, void *contiguous_struct, int count, void *type) { - s_smpi_mpi_struct_t* type_c = reinterpret_cast(type); - char* contiguous_struct_char = static_cast(contiguous_struct); - char* noncontiguous_struct_char = static_cast(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(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 (iblock_count-1) - noncontiguous_struct_char = static_cast(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(noncontiguous_struct_char); - } +// s_smpi_mpi_struct_t* type_c = reinterpret_cast(type); +// char* contiguous_struct_char = static_cast(contiguous_struct); +// char* noncontiguous_struct_char = static_cast(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(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 (iblock_count-1) +// noncontiguous_struct_char = static_cast(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(noncontiguous_struct_char); +// } } /* Copies contiguous data into noncontiguous memory. @@ -988,45 +822,45 @@ void serialize_struct( void* noncontiguous_struct, void *contiguous_struct, int */ 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(type); - - char* contiguous_struct_char = static_cast(contiguous_struct); - char* noncontiguous_struct_char = static_cast(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(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 (iblock_count-1) - noncontiguous_struct_char = static_cast(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(noncontiguous_struct_char); - } +// s_smpi_mpi_struct_t* type_c = reinterpret_cast(type); + +// char* contiguous_struct_char = static_cast(contiguous_struct); +// char* noncontiguous_struct_char = static_cast(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(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 (iblock_count-1) +// noncontiguous_struct_char = static_cast(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(noncontiguous_struct_char); +// } } void free_struct(MPI_Datatype* type){ - for (int i = 0; i < reinterpret_cast((*type)->substruct)->block_count; i++) - smpi_datatype_unuse(reinterpret_cast((*type)->substruct)->old_types[i]); - if((*type)->in_use==0){ - xbt_free(reinterpret_cast((*type)->substruct)->block_lengths); - xbt_free(reinterpret_cast((*type)->substruct)->block_indices); - xbt_free(reinterpret_cast((*type)->substruct)->old_types); - } +// for (int i = 0; i < reinterpret_cast((*type)->substruct)->block_count; i++) +// smpi_datatype_unuse(reinterpret_cast((*type)->substruct)->old_types[i]); +// if((*type)->in_use==0){ +// xbt_free(reinterpret_cast((*type)->substruct)->block_lengths); +// xbt_free(reinterpret_cast((*type)->substruct)->block_indices); +// xbt_free(reinterpret_cast((*type)->substruct)->old_types); +// } } void use_struct(MPI_Datatype* type){ - for (int i = 0; i < reinterpret_cast((*type)->substruct)->block_count; i++) - smpi_datatype_use(reinterpret_cast((*type)->substruct)->old_types[i]); +// for (int i = 0; i < reinterpret_cast((*type)->substruct)->block_count; i++) +// smpi_datatype_use(reinterpret_cast((*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 @@ -1054,145 +888,145 @@ s_smpi_mpi_struct_t* smpi_datatype_struct_create( int* block_lengths, MPI_Aint* 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])ub) - ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i]); - - if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast(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); - } +// 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])ub) +// ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i]); + +// if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast(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); +// (*datatype)->flags= ((*datatype)->flags | DT_FLAG_COMMITED); } int smpi_type_attr_delete(MPI_Datatype type, int keyval){ - smpi_type_key_elem elem = - static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&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(&keyval), sizeof(int)); +// smpi_type_key_elem elem = +// static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&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(&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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==nullptr) - return MPI_ERR_ARG; - if(type->attributes==nullptr){ - *flag=0; - return MPI_SUCCESS; - } - try { - *static_cast(attr_value) = xbt_dict_get_ext(type->attributes, reinterpret_cast(&keyval), sizeof(int)); - *flag=1; - } - catch (xbt_ex& ex) { - *flag=0; - } +// smpi_type_key_elem elem = +// static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); +// if(elem==nullptr) +// return MPI_ERR_ARG; +// if(type->attributes==nullptr){ +// *flag=0; +// return MPI_SUCCESS; +// } +// try { +// *static_cast(attr_value) = xbt_dict_get_ext(type->attributes, reinterpret_cast(&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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&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(&keyval), sizeof(int), attr_value, nullptr); +// if(smpi_type_keyvals==nullptr) +// smpi_type_keyvals = xbt_dict_new_homogeneous(nullptr); +// smpi_type_key_elem elem = +// static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&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(&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); +// 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); +// 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; +// value->copy_fn=copy_fn; +// value->delete_fn=delete_fn; - *keyval = type_keyval_id; - xbt_dict_set_ext(smpi_type_keyvals,reinterpret_cast(keyval), sizeof(int),reinterpret_cast(value), nullptr); - type_keyval_id++; +// *keyval = type_keyval_id; +// xbt_dict_set_ext(smpi_type_keyvals,reinterpret_cast(keyval), sizeof(int),reinterpret_cast(value), nullptr); +// type_keyval_id++; return MPI_SUCCESS; } int smpi_type_keyval_free(int* keyval){ - smpi_type_key_elem elem = - static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int))); - if(elem==0){ - return MPI_ERR_ARG; - } - xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int)); - xbt_free(elem); +// smpi_type_key_elem elem = +// static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int))); +// if(elem==0){ +// return MPI_ERR_ARG; +// } +// xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int)); +// xbt_free(elem); return MPI_SUCCESS; } diff --git a/src/smpi/smpi_op.cpp b/src/smpi/smpi_op.cpp index e3d4e2a845..96ac1b8c10 100644 --- a/src/smpi/smpi_op.cpp +++ b/src/smpi/smpi_op.cpp @@ -97,7 +97,7 @@ APPLY_OP_LOOP(MPI_2LONG, long_long,op) #define APPLY_END_OP_LOOP(op)\ {\ - xbt_die("Failed to apply " #op " to type %s", (*datatype)->name);\ + xbt_die("Failed to apply " #op " to type %s", (*datatype)->name());\ } static void max_func(void *a, void *b, int *length, MPI_Datatype * datatype) @@ -231,7 +231,7 @@ void Op::set_fortran_op() is_fortran_op_ = true; } -void Op::apply(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype) +void Op::apply(void *invec, void *inoutvec, int *len, MPI_Datatype datatype) { if(smpi_privatize_global_variables){//we need to switch as the called function may silently touch global variables XBT_DEBUG("Applying operation, switch to the right data frame "); @@ -240,9 +240,9 @@ void Op::apply(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype) if(!smpi_process_get_replaying()){ if(! is_fortran_op_) - this->func_(invec, inoutvec, len, datatype); + this->func_(invec, inoutvec, len, &datatype); else{ - int tmp = smpi_type_c2f(*datatype); + int tmp = smpi_type_c2f(datatype); /* Unfortunately, the C and Fortran version of the MPI standard do not agree on the type here, thus the reinterpret_cast. */ this->func_(invec, inoutvec, len, reinterpret_cast(&tmp) ); diff --git a/src/smpi/smpi_op.hpp b/src/smpi/smpi_op.hpp index 55e2c423e3..1e3c127695 100644 --- a/src/smpi/smpi_op.hpp +++ b/src/smpi/smpi_op.hpp @@ -24,7 +24,7 @@ class Op { bool is_commutative(); bool is_fortran_op(); void set_fortran_op(); - void apply(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype); + void apply(void *invec, void *inoutvec, int *len, MPI_Datatype datatype); }; } diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index e87079d3aa..41ab06e663 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -1767,7 +1767,7 @@ int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count, MPI_Datatype datat if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) { retval = MPI_ERR_ARG; } else { - if(op!=MPI_OP_NULL) op->apply( inbuf, inoutbuf, &count, &datatype); + if(op!=MPI_OP_NULL) op->apply( inbuf, inoutbuf, &count, datatype); retval = MPI_SUCCESS; } smpi_bench_begin(); @@ -2420,9 +2420,9 @@ int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint 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); + smpi_datatype_create(newtype, oldtype->size(), lb, lb + extent, sizeof(s_smpi_mpi_struct_t), subtype, DT_FLAG_VECTOR); - (*newtype)->flags &= ~DT_FLAG_COMMITED; + (*newtype)->addflag(~DT_FLAG_COMMITED); return MPI_SUCCESS; } diff --git a/src/smpi/smpi_request.cpp b/src/smpi/smpi_request.cpp index 89bab5ae68..6414543982 100644 --- a/src/smpi/smpi_request.cpp +++ b/src/smpi/smpi_request.cpp @@ -113,16 +113,16 @@ Request::Request(){} Request::Request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags) { void *old_buf = nullptr; - s_smpi_subtype_t *subtype = static_cast(datatype->substruct); - - 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)); - if ((datatype->sizeof_substruct != 0) && ((flags & SEND) != 0)) { - subtype->serialize(old_buf, buf_, count, datatype->substruct); - } - } +// s_smpi_subtype_t *subtype = static_cast(datatype->substruct); + +// 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)); +// 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; @@ -482,24 +482,24 @@ void Request::start() void* buf = buf_; if ((flags_ & SSEND) == 0 && ( (flags_ & RMA) != 0 || static_cast(size_) < xbt_cfg_get_int("smpi/send-is-detached-thresh") ) ) { - void *oldbuf = nullptr; +// void *oldbuf = nullptr; detached_ = 1; XBT_DEBUG("Send request %p is detached", this); refcount_++; - if(old_type_->sizeof_substruct == 0){ - oldbuf = buf_; - if (!smpi_process_get_replaying() && oldbuf != nullptr && size_!=0){ - if((smpi_privatize_global_variables != 0) - && (static_cast(buf_) >= smpi_start_data_exe) - && (static_cast(buf_) < smpi_start_data_exe + smpi_size_data_exe )){ - XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment "); - smpi_switch_data_segment(src_); - } - buf = xbt_malloc(size_); - memcpy(buf,oldbuf,size_); - XBT_DEBUG("buf %p copied into %p",oldbuf,buf); - } - } +// if(old_type_->sizeof_substruct == 0){ +// oldbuf = buf_; +// if (!smpi_process_get_replaying() && oldbuf != nullptr && size_!=0){ +// if((smpi_privatize_global_variables != 0) +// && (static_cast(buf_) >= smpi_start_data_exe) +// && (static_cast(buf_) < smpi_start_data_exe + smpi_size_data_exe )){ +// XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment "); +// smpi_switch_data_segment(src_); +// } +// buf = xbt_malloc(size_); +// memcpy(buf,oldbuf,size_); +// XBT_DEBUG("buf %p copied into %p",oldbuf,buf); +// } +// } } //if we are giving back the control to the user without waiting for completion, we have to inject timings @@ -792,7 +792,7 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status) req->print_request("Finishing"); MPI_Datatype datatype = req->old_type_; - if(((req->flags_ & ACCUMULATE) != 0) || (datatype->sizeof_substruct != 0)){ + if(((req->flags_ & ACCUMULATE) != 0)/* || (datatype->sizeof_substruct != 0)*/){ if (!smpi_process_get_replaying()){ if( smpi_privatize_global_variables != 0 && (static_cast(req->old_buf_) >= smpi_start_data_exe) && ((char*)req->old_buf_ < smpi_start_data_exe + smpi_size_data_exe )){ @@ -801,16 +801,17 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status) } } - if(datatype->sizeof_substruct != 0){ - // This part handles the problem of non-contignous memory the unserialization at the reception - s_smpi_subtype_t *subtype = static_cast(datatype->substruct); - if(req->flags_ & RECV) - subtype->unserialize(req->buf_, req->old_buf_, req->real_size_/smpi_datatype_size(datatype) , - datatype->substruct, req->op_); - xbt_free(req->buf_); - }else if(req->flags_ & RECV){//apply op on contiguous buffer for accumulate +// if(datatype->sizeof_substruct != 0){ +// // This part handles the problem of non-contignous memory the unserialization at the reception +// s_smpi_subtype_t *subtype = static_cast(datatype->substruct); +// if(req->flags_ & RECV) +// subtype->unserialize(req->buf_, req->old_buf_, req->real_size_/smpi_datatype_size(datatype) , +// 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); - req->op_->apply(req->buf_, req->old_buf_, &n, &datatype); + req->op_->apply(req->buf_, req->old_buf_, &n, datatype); xbt_free(req->buf_); } } diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 6aa4ac9697..be466440fa 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -220,6 +220,8 @@ set(SMPI_SRC 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 src/smpi/smpi_op.hpp src/smpi/smpi_pmpi.cpp -- 2.20.1