X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f4b7b8e6ce0fd35fc2ada5f5c06d212bcd2199c8..6d12558bf98bb09f8fc8c45527d740bf999f789c:/src/smpi/smpi_base.c diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index f114a57aa1..cb06b33939 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team. +/* Copyright (c) 2007-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -187,7 +187,7 @@ static MPI_Request build_request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) { - MPI_Request request; + MPI_Request request = NULL; void *old_buf = NULL; @@ -219,6 +219,7 @@ static MPI_Request build_request(void *buf, int count, request->flags = flags; request->detached = 0; request->detached_sender = NULL; + request->real_src = 0; request->truncated = 0; request->real_size = 0; @@ -284,9 +285,9 @@ static void smpi_mpi_request_free_voidp(void* request) MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, PERSISTENT | SEND | PREPARED); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, PERSISTENT | SEND | PREPARED); request->refcount++; return request; } @@ -294,9 +295,9 @@ MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, PERSISTENT | SSEND | SEND | PREPARED); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, PERSISTENT | SSEND | SEND | PREPARED); request->refcount++; return request; } @@ -304,9 +305,9 @@ MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, - comm, PERSISTENT | RECV | PREPARED); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, + comm, PERSISTENT | RECV | PREPARED); request->refcount++; return request; } @@ -320,6 +321,7 @@ void smpi_mpi_start(MPI_Request request) if(request->flags & PREPARED)request->flags &= ~PREPARED; if(request->flags & RECV) { print_request("New recv", request); + //FIXME: if receive is posted with a large size, but send is smaller, mailboxes may not match ! if (request->size < sg_cfg_get_int("smpi/async_small_thres")) mailbox = smpi_process_mailbox_small(); else @@ -345,7 +347,7 @@ void smpi_mpi_start(MPI_Request request) #ifdef HAVE_TRACING int rank = smpi_process_index(); if (TRACE_smpi_view_internals()) { - TRACE_smpi_send(rank, rank, receiver); + TRACE_smpi_send(rank, rank, receiver,request->size); } #endif /* if(receiver == MPI_UNDEFINED) {*/ @@ -441,20 +443,18 @@ void smpi_mpi_request_free(MPI_Request * request) MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf , count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, NON_PERSISTENT | SEND | PREPARED); - + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf , count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, NON_PERSISTENT | ISEND | SEND | PREPARED); return request; } MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM?(void*)0:buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, NON_PERSISTENT | ISEND | SEND); - + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM?(void*)0:buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, NON_PERSISTENT | ISEND | SEND); smpi_mpi_start(request); return request; } @@ -462,9 +462,9 @@ MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, NON_PERSISTENT | ISEND | SSEND | SEND); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, NON_PERSISTENT | ISEND | SSEND | SEND); smpi_mpi_start(request); return request; } @@ -474,19 +474,18 @@ MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, - comm, NON_PERSISTENT | RECV | PREPARED); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, + comm, NON_PERSISTENT | RECV | PREPARED); return request; } MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, - comm, NON_PERSISTENT | RECV); - + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, + comm, NON_PERSISTENT | RECV); smpi_mpi_start(request); return request; } @@ -494,9 +493,10 @@ MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype, void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status) { - MPI_Request request; + MPI_Request request = NULL; request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); smpi_mpi_wait(&request, status); + request = NULL; } @@ -504,23 +504,25 @@ void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src, void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, NON_PERSISTENT | SEND); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, NON_PERSISTENT | SEND); + smpi_mpi_start(request); smpi_mpi_wait(&request, MPI_STATUS_IGNORE); - + request = NULL; } void smpi_mpi_ssend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = - build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, - comm, NON_PERSISTENT | SSEND | SEND); + MPI_Request request = NULL; + request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, + comm, NON_PERSISTENT | SSEND | SEND); smpi_mpi_start(request); smpi_mpi_wait(&request, MPI_STATUS_IGNORE); + request = NULL; } void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, @@ -619,7 +621,7 @@ int smpi_mpi_test(MPI_Request * request, MPI_Status * status) { flag = simcall_comm_test((*request)->action); if(flag) { finish_wait(request, status); - request=MPI_REQUEST_NULL; + *request = MPI_REQUEST_NULL; }else{ smpi_empty_status(status); } @@ -753,8 +755,14 @@ void smpi_mpi_wait(MPI_Request * request, MPI_Status * status) if ((*request)->action != NULL) { // this is not a detached send simcall_comm_wait((*request)->action, -1.0); } + +#ifdef HAVE_MC + if(MC_is_active()) + (*request)->action->comm.dst_data = NULL; // dangling pointer : dst_data is freed with a wait, need to set it to NULL for system state comparison +#endif + finish_wait(request, status); - request=MPI_REQUEST_NULL; + *request = MPI_REQUEST_NULL; // FIXME for a detached send, finish_wait is not called: }