double smpi_process_simulated_elapsed(void);
void smpi_process_set_sampling(int s);
int smpi_process_get_sampling(void);
+void smpi_process_set_replaying(int s);
+int smpi_process_get_replaying(void);
void smpi_deployment_register_process(const char* instance_id, int rank, int index, MPI_Comm**, xbt_bar_t*);
void smpi_deployment_cleanup_instances(void);
void smpi_comm_copy_buffer_callback(smx_action_t comm,
void *buff, size_t buff_size);
+void smpi_comm_null_copy_buffer_callback(smx_action_t comm,
+ void *buff, size_t buff_size);
+
void print_request(const char *message, MPI_Request request);
int smpi_enabled(void);
smpi_comm_use(request->comm);
request->action = simcall_comm_irecv(mailbox, request->buf,
&request->real_size, &match_recv,
- &smpi_comm_copy_buffer_callback,
+ !smpi_process_get_replaying()? &smpi_comm_copy_buffer_callback
+ : &smpi_comm_null_copy_buffer_callback,
request, -1.0);
XBT_DEBUG("recv simcall posted");
request->refcount++;
if(request->old_type->has_subtype == 0){
oldbuf = request->buf;
- if (!_xbt_replay_is_active() && oldbuf && request->size!=0){
+ if (!smpi_process_get_replaying() && oldbuf && request->size!=0){
if((smpi_privatize_global_variables)
&& ((char*)request->buf >= start_data_exe)
&& ((char*)request->buf < start_data_exe + size_data_exe )){
buf, request->real_size,
&match_send,
&xbt_free_f, // how to free the userdata if a detached send fails
- &smpi_comm_copy_buffer_callback,
+ !smpi_process_get_replaying()? &smpi_comm_copy_buffer_callback
+ : &smpi_comm_null_copy_buffer_callback,
request,
// detach if msg size < eager/rdv switch limit
request->detached);
MPI_Datatype datatype = req->old_type;
if((req->flags & ACCUMULATE) || (datatype->has_subtype == 1)){
- if (!_xbt_replay_is_active()){
+ if (!smpi_process_get_replaying()){
if( smpi_privatize_global_variables
&& ((char*)req->old_buf >= start_data_exe)
&& ((char*)req->old_buf < start_data_exe + size_data_exe )
if(src != root) {
// FIXME: possibly overkill we we have contiguous/noncontiguous data
// mapping...
- if (!_xbt_replay_is_active())
+ if (!smpi_process_get_replaying())
tmpbufs[index] = xbt_malloc(count * dataext);
else
tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
#include "smpi_mpi_dt_private.h"
#include "limits.h"
#include "simix/smx_private.h"
-#include "xbt/replay.h"
#include "colls/colls.h"
-extern int is_replay_active ;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi,
"Logging specific to SMPI (comm)");
}
void smpi_comm_set_intra_comm(MPI_Comm comm, MPI_Comm leaders){
- if (comm == MPI_COMM_UNINITIALIZED)
- comm = smpi_process_comm_world();
comm->intra_comm=leaders;
}
}
MPI_Comm smpi_comm_get_intra_comm(MPI_Comm comm){
- if (comm == MPI_COMM_UNINITIALIZED)
- comm = smpi_process_comm_world();
- if(comm==MPI_COMM_WORLD) return smpi_process_get_comm_intra();
+ if (comm == MPI_COMM_UNINITIALIZED || comm==MPI_COMM_WORLD)
+ return smpi_process_get_comm_intra();
else return comm->intra_comm;
}
// say to SimGrid that we are not in replay for a while, because we need
// the buffers to be copied for the following calls
int replaying = 0; //cache data to set it back again after
- if(_xbt_replay_is_active()){
- replaying = 1;
- is_replay_active = 0 ;
+ if(smpi_process_get_replaying()){
+ replaying=1;
+ smpi_process_set_replaying(0);
}
if(smpi_privatize_global_variables){ //we need to switch here, as the called function may silently touch global variables
MPI_Comm leader_comm = MPI_COMM_NULL;
- if(comm!=MPI_COMM_WORLD){
+ if(MPI_COMM_WORLD!=MPI_COMM_UNINITIALIZED && comm!=MPI_COMM_WORLD){
//create leader_communicator
for (i=0; i< leader_group_size;i++)
smpi_group_set_mapping(leaders_group, leader_list[i], i);
// Are the nodes uniform ? = same number of process/node
int my_local_size=smpi_comm_size(comm_intra);
if(smpi_comm_rank(comm_intra)==0) {
- int* non_uniform_map = xbt_malloc(sizeof(int)*leader_group_size);
+ int* non_uniform_map = xbt_malloc0(sizeof(int)*leader_group_size);
smpi_coll_tuned_allgather_mpich(&my_local_size, 1, MPI_INT,
non_uniform_map, 1, MPI_INT, leader_comm);
for(i=0; i < leader_group_size; i++) {
smpi_mpi_allreduce(&is_blocked, &(global_blocked), 1,
MPI_INT, MPI_LAND, comm);
- if(comm==MPI_COMM_WORLD){
+ if(MPI_COMM_WORLD==SMPI_UNINITIALIZED || comm==MPI_COMM_WORLD){
if(smpi_comm_rank(comm)==0){
comm->is_blocked=global_blocked;
}
xbt_free(leader_list);
if(replaying==1)
- is_replay_active = 1;
+ smpi_process_set_replaying(1);
}
s_smpi_mpi_instance_t* instance = NULL;
char *name = NULL;
xbt_dict_foreach(smpi_instances, cursor, name, instance) {
- while (smpi_group_unuse(smpi_comm_group(instance->comm_world)) > 0);
+ if(instance->comm_world!=MPI_COMM_NULL)
+ while (smpi_group_unuse(smpi_comm_group(instance->comm_world)) > 0);
xbt_free(instance->comm_world);
xbt_barrier_destroy(instance->finalization_barrier);
}
char state;
int sampling; /* inside an SMPI_SAMPLE_ block? */
char* instance_id;
+ int replaying; /* is the process replaying a trace */
xbt_bar_t finalization_barrier;
} s_smpi_process_data_t;
if(temp_bar != NULL) data->finalization_barrier = temp_bar;
data->index = index;
data->instance_id = instance_id;
+ data->replaying = 0;
xbt_free(simcall_process_get_data(proc));
simcall_process_set_data(proc, data);
if (*argc > 3) {
process_data[index_to_process_data[index]]->state = SMPI_INITIALIZED;
}
+void smpi_process_set_replaying(int value){
+ int index = smpi_process_index();
+ if ((index != MPI_UNDEFINED) && (process_data[index_to_process_data[index]]->state != SMPI_FINALIZED))
+ process_data[index_to_process_data[index]]->replaying = value;
+}
+
+int smpi_process_get_replaying(){
+ int index = smpi_process_index();
+ if (index != MPI_UNDEFINED)
+ return process_data[index_to_process_data[index]]->replaying;
+ else return _xbt_replay_is_active();
+}
+
int smpi_global_size(void)
{
}
+
+void smpi_comm_null_copy_buffer_callback(smx_action_t comm,
+ void *buff, size_t buff_size)
+{
+ return;
+}
+
static void smpi_check_options(){
//check correctness of MPI parameters
count = sendcount < recvcount ? sendcount : recvcount;
if(sendtype->has_subtype == 0 && recvtype->has_subtype == 0) {
- if(!_xbt_replay_is_active()) memcpy(recvbuf, sendbuf, count);
+ if(!smpi_process_get_replaying()) memcpy(recvbuf, sendbuf, count);
}
else if (sendtype->has_subtype == 0)
{
void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
MPI_Datatype * datatype)
{
+ if(op==MPI_OP_NULL)
+ return;
+
if(smpi_privatize_global_variables){ //we need to switch here, as the called function may silently touch global variables
XBT_DEBUG("Applying operation, switch to the right data frame ");
smpi_switch_data_segment(smpi_process_index());
}
- if(!_xbt_replay_is_active())
+ if(!smpi_process_get_replaying())
op->func(invec, inoutvec, len, datatype);
}
//allocate a single buffer for all sends, growing it if needed
void* smpi_get_tmp_sendbuffer(int size){
- if (!_xbt_replay_is_active())
+ if (!smpi_process_get_replaying())
return xbt_malloc(size);
if (sendbuffer_size<size){
sendbuffer=xbt_realloc(sendbuffer,size);
}
//allocate a single buffer for all recv
void* smpi_get_tmp_recvbuffer(int size){
- if (!_xbt_replay_is_active())
+ if (!smpi_process_get_replaying())
return xbt_malloc(size);
if (recvbuffer_size<size){
recvbuffer=xbt_realloc(recvbuffer,size);
}
void smpi_free_tmp_buffer(void* buf){
- if (!_xbt_replay_is_active())
+ if (!smpi_process_get_replaying())
xbt_free(buf);
}
void smpi_replay_init(int *argc, char***argv){
smpi_process_init(argc, argv);
smpi_process_mark_as_initialized();
+ smpi_process_set_replaying(1);
#ifdef HAVE_TRACING
int rank = smpi_process_index();
TRACE_smpi_init(rank);