/* 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 <xbt/config.hpp>
+
#include "private.h"
#include "xbt/virtu.h"
#include "mc/mc.h"
#include "simgrid/sg_config.h"
#include "colls/colls.h"
+#include "src/simix/SynchroComm.hpp"
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi, "Logging specific to SMPI (base)");
static int match_recv(void* a, void* b, smx_synchro_t ignored) {
int nb_values;
double values[4];//arbitrary set to 4
} s_smpi_factor_multival_t;
+
xbt_dynar_t smpi_os_values = NULL;
xbt_dynar_t smpi_or_values = NULL;
xbt_dynar_t smpi_ois_values = NULL;
-double smpi_wtime_sleep = 0.0;
-double smpi_iprobe_sleep = 1e-4;
-double smpi_test_sleep = 1e-4;
+static simgrid::config::Flag<double> smpi_wtime_sleep(
+ "smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0);
+static simgrid::config::Flag<double> smpi_iprobe_sleep(
+ "smpi/iprobe", "Minimum time to inject inside a call to MPI_Iprobe", 1e-4);
+static simgrid::config::Flag<double> smpi_test_sleep(
+ "smpi/test", "Minimum time to inject inside a call to MPI_Test", 1e-4);
static int factor_cmp(const void *pa, const void *pb)
{
s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(datatype->substruct);
- if(((flags & RECV) && (flags & ACCUMULATE)) || (datatype->has_subtype == 1)){
+ if(((flags & RECV) && (flags & ACCUMULATE)) || (datatype->sizeof_substruct != 0)){
// This part handles the problem of non-contiguous memory
old_buf = buf;
buf = count==0 ? NULL : xbt_malloc(count*smpi_datatype_size(datatype));
- if ((datatype->has_subtype == 1) && (flags & SEND)) {
+ if ((datatype->sizeof_substruct != 0) && (flags & SEND)) {
subtype->serialize(old_buf, buf, count, datatype->substruct);
}
}
request->old_type = datatype;
request->size = smpi_datatype_size(datatype) * count;
+ smpi_datatype_use(datatype);
request->src = src;
request->dst = dst;
request->tag = tag;
request->comm = comm;
+ smpi_comm_use(request->comm);
request->action = NULL;
request->flags = flags;
request->detached = 0;
request->op = MPI_REPLACE;
request->send = 0;
request->recv = 0;
- if (flags & SEND) smpi_datatype_unuse(datatype);
return request;
}
if (request->flags & RECV) {
print_request("New recv", request);
- int async_small_thresh = xbt_cfg_get_int("smpi/async_small_thresh");
+ int async_small_thresh = xbt_cfg_get_int("smpi/async-small-thresh");
xbt_mutex_t mut = smpi_process_mailboxes_mutex();
if (async_small_thresh != 0 ||request->flags & RMA)
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
request->real_size=request->size;
- smpi_datatype_use(request->old_type);
- smpi_comm_use(request->comm);
request->action = simcall_comm_irecv(SIMIX_process_self(), mailbox, request->buf, &request->real_size, &match_recv,
!smpi_process_get_replaying()? &smpi_comm_copy_buffer_callback
: &smpi_comm_null_copy_buffer_callback, request, -1.0);
XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size));
}
- int async_small_thresh = xbt_cfg_get_int("smpi/async_small_thresh");
+ int async_small_thresh = xbt_cfg_get_int("smpi/async-small-thresh");
xbt_mutex_t mut=smpi_process_remote_mailboxes_mutex(receiver);
}
void* buf = request->buf;
- if ( (! (request->flags & SSEND)) &&
- (static_cast<int>(request->size) < xbt_cfg_get_int("smpi/send_is_detached_thresh"))) {
+ if ( (! (request->flags & SSEND)) && ((request->flags & RMA) ||
+ (static_cast<int>(request->size) < xbt_cfg_get_int("smpi/send-is-detached-thresh")))) {
void *oldbuf = NULL;
request->detached = 1;
XBT_DEBUG("Send request %p is detached", request);
request->refcount++;
- if(request->old_type->has_subtype == 0){
+ if(request->old_type->sizeof_substruct == 0){
oldbuf = request->buf;
if (!smpi_process_get_replaying() && oldbuf && request->size!=0){
if((smpi_privatize_global_variables)
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
request->real_size=request->size;
- smpi_datatype_use(request->old_type);
- smpi_comm_use(request->comm);
request->action = simcall_comm_isend(SIMIX_process_from_PID(request->src+1), mailbox, request->size, -1.0,
buf, request->real_size, &match_send,
&xbt_free_f, // how to free the userdata if a detached send fails
if((*request)->refcount<0) xbt_die("wrong refcount");
if((*request)->refcount==0){
+ smpi_datatype_unuse((*request)->old_type);
+ smpi_comm_unuse((*request)->comm);
print_request("Destroying", (*request));
xbt_free(*request);
*request = MPI_REQUEST_NULL;
request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src, dst, tag,
comm, RMA | NON_PERSISTENT | ISEND | SEND | PREPARED | ACCUMULATE);
request->op = op;
+// smpi_datatype_use(datatype);
}
return request;
}
request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src, dst, tag,
comm, RMA | NON_PERSISTENT | RECV | PREPARED | ACCUMULATE);
request->op = op;
+// smpi_datatype_use(datatype);
}
return request;
}
print_request("Finishing", req);
MPI_Datatype datatype = req->old_type;
- if((req->flags & ACCUMULATE) || (datatype->has_subtype == 1)){
+ if((req->flags & ACCUMULATE) || (datatype->sizeof_substruct != 0)){
if (!smpi_process_get_replaying()){
if( smpi_privatize_global_variables && ((char*)req->old_buf >= smpi_start_data_exe)
&& ((char*)req->old_buf < smpi_start_data_exe + smpi_size_data_exe )){
}
}
- if(datatype->has_subtype == 1){
+ 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<s_smpi_subtype_t*>(datatype->substruct);
if(req->flags & RECV)
subtype->unserialize(req->buf, req->old_buf, req->real_size/smpi_datatype_size(datatype) ,
datatype->substruct, req->op);
- if(req->detached == 0) free(req->buf);
+ 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);
smpi_op_apply(req->op, req->buf, req->old_buf, &n, &datatype);
+ xbt_free(req->buf);
}
}
- smpi_comm_unuse(req->comm);
- smpi_datatype_unuse(datatype);
}
if (TRACE_smpi_view_internals()) {
print_request("New iprobe", request);
// We have to test both mailboxes as we don't know if we will receive one one or another
- if (xbt_cfg_get_int("smpi/async_small_thresh")>0){
+ if (xbt_cfg_get_int("smpi/async-small-thresh")>0){
mailbox = smpi_process_mailbox_small();
XBT_DEBUG("trying to probe the perm recv mailbox");
request->action = simcall_comm_iprobe(mailbox, 0, request->src, request->tag, &match_recv, (void*)request);
}
if (request->action){
- MPI_Request req = (MPI_Request)SIMIX_comm_get_src_data(request->action);
+ simgrid::simix::Comm *sync_comm = static_cast<simgrid::simix::Comm*>(request->action);
+ MPI_Request req = (MPI_Request)sync_comm->src_data;
*flag = 1;
if(status != MPI_STATUS_IGNORE && !(req->flags & PREPARED)) {
status->MPI_SOURCE = smpi_group_rank(smpi_comm_group(comm), req->src);
if ((*request)->action != NULL) { // this is not a detached send
simcall_comm_wait((*request)->action, -1.0);
- if((MC_is_active() || MC_record_replay_is_active()) && (*request)->action)
- (*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
+ if((MC_is_active() || MC_record_replay_is_active()) && (*request)->action) {
+ simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>( (*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
+ }
}
finish_wait(request, status);
{
int i, size, count;
int *displs;
- int rank = smpi_process_index();
+ int rank = smpi_comm_rank(comm);
void *tmpbuf;
/* arbitrarily choose root as rank 0 */
void **tmpbufs;
char* sendtmpbuf = (char*) sendbuf;
- if( sendbuf == MPI_IN_PLACE ) {
- sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype));
- smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
- }
+
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
smpi_coll_tuned_reduce_ompi_basic_linear(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
return;
}
+
+ if( sendbuf == MPI_IN_PLACE ) {
+ sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*smpi_datatype_get_extent(datatype));
+ smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
+ }
if(rank != root) {
// Send buffer to root
xbt_free(tmpbufs);
xbt_free(requests);
- if( sendbuf == MPI_IN_PLACE ) {
- smpi_free_tmp_buffer(sendtmpbuf);
- }
+ }
+ if( sendbuf == MPI_IN_PLACE ) {
+ smpi_free_tmp_buffer(sendtmpbuf);
}
}