X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c73f2fe7c4b3dc6deeae12389ae22387928f0872..b91d8031bb392545546a25d9792f1ac68de5ecce:/src/smpi/smpi_mpi.c diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index 3dda18f396..65a0596a4f 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -1,4 +1,8 @@ -/* $Id$tag */ +/* Copyright (c) 2007, 2008, 2009, 2010. 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 "private.h" #include "smpi_coll_private.h" @@ -12,10 +16,16 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, int MPI_Init(int* argc, char*** argv) { smpi_process_init(argc, argv); smpi_bench_begin(-1, NULL); +#ifdef HAVE_TRACING + TRACE_smpi_init(smpi_process_index()); +#endif return MPI_SUCCESS; } int MPI_Finalize(void) { +#ifdef HAVE_TRACING + TRACE_smpi_finalize(smpi_process_index()); +#endif smpi_bench_end(-1, NULL); smpi_process_destroy(); return MPI_SUCCESS; @@ -73,6 +83,33 @@ double MPI_Wtime(void) { return time; } +int MPI_Address(void *location, MPI_Aint *address) { + int retval; + + smpi_bench_end(-1, NULL); + if(!address) { + retval = MPI_ERR_ARG; + } else { + *address = (MPI_Aint)location; + } + smpi_bench_begin(-1, NULL); + return retval; +} + +int MPI_Type_free(MPI_Datatype* datatype) { + int retval; + + smpi_bench_end(-1, NULL); + if(!datatype) { + retval = MPI_ERR_ARG; + } else { + // FIXME: always fail for now + retval = MPI_ERR_TYPE; + } + smpi_bench_begin(-1, NULL); + return retval; +} + int MPI_Type_size(MPI_Datatype datatype, size_t* size) { int retval; @@ -104,6 +141,22 @@ int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint* extent) { return retval; } +int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint* extent) { + int retval; + MPI_Aint dummy; + + smpi_bench_end(-1, NULL); + if(datatype == MPI_DATATYPE_NULL) { + retval = MPI_ERR_TYPE; + } else if(extent == NULL) { + retval = MPI_ERR_ARG; + } else { + retval = smpi_datatype_extent(datatype, &dummy, extent); + } + smpi_bench_begin(-1, NULL); + return retval; +} + int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp) { int retval; @@ -638,6 +691,88 @@ int MPI_Comm_free(MPI_Comm* comm) { return retval; } +int MPI_Send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) { + int retval; + int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; + + smpi_bench_end(rank, "Send_init"); + if(request == NULL) { + retval = MPI_ERR_ARG; + } else if (comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else { + *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm); + retval = MPI_SUCCESS; + } + smpi_bench_begin(rank, "Send_init"); + return retval; +} + +int MPI_Recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request) { + int retval; + int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; + + smpi_bench_end(rank, "Recv_init"); + if(request == NULL) { + retval = MPI_ERR_ARG; + } else if (comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else { + *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm); + retval = MPI_SUCCESS; + } + smpi_bench_begin(rank, "Recv_init"); + return retval; +} + +int MPI_Start(MPI_Request* request) { + int retval; + MPI_Comm comm = (*request)->comm; + int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; + + smpi_bench_end(rank, "Start"); + if(request == NULL) { + retval = MPI_ERR_ARG; + } else { + smpi_mpi_start(*request); + retval = MPI_SUCCESS; + } + smpi_bench_begin(rank, "Start"); + return retval; +} + +int MPI_Startall(int count, MPI_Request* requests) { + int retval; + MPI_Comm comm = count > 0 && requests ? requests[0]->comm : MPI_COMM_NULL; + int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; + + smpi_bench_end(rank, "Startall"); + if(requests == NULL) { + retval = MPI_ERR_ARG; + } else { + smpi_mpi_startall(count, requests); + retval = MPI_SUCCESS; + } + smpi_bench_begin(rank, "Startall"); + return retval; +} + +int MPI_Request_free(MPI_Request* request) { + int retval; + MPI_Comm comm = (*request)->comm; + int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; + + smpi_bench_end(rank, "Request_free"); + if(request == NULL) { + retval = MPI_ERR_ARG; + } else { + smpi_mpi_request_free(request); + retval = MPI_SUCCESS; + } + smpi_bench_begin(rank, "Request_free"); + return retval; +} + int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request) { int retval; int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; @@ -732,30 +867,6 @@ int MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, i return retval; } -int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count) { - int retval; -/* - * Returns the number of entries received. (Again, we count entries, each of type datatype, not bytes.) - * The datatype argument should match the argument provided by the receive call that set the status variable. - * If the size of the datatype is zero, this routine will return a count of zero. - * If the amount of data in status is not an exact multiple of the size of datatype - * (so that count would not be integral), a count of MPI_UNDEFINED is returned instead. - * - */ - smpi_bench_end(-1, NULL); //FIXME - - if( 0==smpi_datatype_size(datatype)) { - // also check that the type is 'committed' when we have MPI_Type_commit (s.g. 23/03/21010) - retval = MPI_ERR_TYPE; - } else { - smpi_mpi_get_count(status, datatype, count); - retval = MPI_SUCCESS; - } - smpi_bench_begin(-1, NULL); - return retval; -} - - int MPI_Test(MPI_Request* request, int* flag, MPI_Status* status) { int retval; int rank = request && (*request)->comm != MPI_COMM_NULL @@ -1017,6 +1128,25 @@ int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype return retval; } +int MPI_Scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { + int retval; + int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1; + + smpi_bench_end(rank, "Scan"); + if(comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else if(datatype == MPI_DATATYPE_NULL) { + retval = MPI_ERR_TYPE; + } else if(op == MPI_OP_NULL) { + retval = MPI_ERR_OP; + } else { + smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm); + retval = MPI_SUCCESS; + } + smpi_bench_begin(rank, "Scan"); + return retval; +} + int MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int* recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { int retval, i, size, count; int* displs; @@ -1086,7 +1216,7 @@ int MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype s } else if(sendcounts == NULL || senddisps == NULL || recvcounts == NULL || recvdisps == NULL) { retval = MPI_ERR_ARG; } else { - retval = smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm); + retval = smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm); } smpi_bench_begin(rank, "Alltoallv"); return retval;