* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/msg.h"
-#include "xbt/synchro_core.h"
+#include "xbt/synchro.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_migration, "Messages specific for this msg example");
*/
#define MSG_BARRIER_SERIAL_PROCESS -1
-typedef struct s_xbt_bar *msg_bar_t;
+typedef struct s_msg_bar* msg_bar_t;
XBT_PUBLIC(msg_bar_t) MSG_barrier_init( unsigned int count);
XBT_PUBLIC(void) MSG_barrier_destroy(msg_bar_t bar);
XBT_PUBLIC(int) MSG_barrier_wait(msg_bar_t bar);
-/* xbt/synchro_core.h -- Simulated synchronization */
+/* xbt/synchro.h -- Simulated synchronization */
/* Copyright (c) 2009-2016. The SimGrid Team. */
/* 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. */
-/* splited away from synchro.h since we are used by dynar.h, and synchro.h uses dynar */
-
-
#ifndef _XBT_THREAD_H
#define _XBT_THREAD_H
#include <simgrid/simix.h>
-#include "xbt/misc.h" /* SG_BEGIN_DECL */
#include "xbt/function_types.h"
+#include "xbt/misc.h" /* SG_BEGIN_DECL */
SG_BEGIN_DECL()
/** @brief Thread mutex data type (opaque object)
* @hideinitializer
*/
-typedef struct s_smx_mutex_ *xbt_mutex_t;
+typedef struct s_smx_mutex_* xbt_mutex_t;
/** @brief Creates a new mutex variable */
XBT_PUBLIC(xbt_mutex_t) xbt_mutex_init(void);
/** @brief Blocks onto the given mutex variable */
XBT_PUBLIC(void) xbt_mutex_acquire(xbt_mutex_t mutex);
-/** @brief Tries to block onto the given mutex variable
+/** @brief Tries to block onto the given mutex variable
* Tries to lock a mutex, return 1 if the mutex is unlocked, else 0.
* This function does not block and wait for the mutex to be unlocked.
* \param mutex The mutex
/** @brief Destroyes the given mutex variable */
XBT_PUBLIC(void) xbt_mutex_destroy(xbt_mutex_t mutex);
-
/** @brief Thread condition data type (opaque object)
* @hideinitializer
*/
-typedef struct s_smx_cond_ *xbt_cond_t;
+typedef struct s_smx_cond_* xbt_cond_t;
/** @brief Creates a condition variable */
XBT_PUBLIC(xbt_cond_t) xbt_cond_init(void);
/** @brief Destroys the given mutex variable */
XBT_PUBLIC(void) xbt_cond_destroy(xbt_cond_t cond);
-#define XBT_BARRIER_SERIAL_PROCESS -1
-typedef struct s_xbt_bar_ *xbt_bar_t;
-XBT_PUBLIC(xbt_bar_t) xbt_barrier_init( unsigned int count);
-XBT_PUBLIC(void) xbt_barrier_destroy(xbt_bar_t bar);
-XBT_PUBLIC(int) xbt_barrier_wait(xbt_bar_t bar);
-
/** @} */
SG_END_DECL()
-#endif /* _XBT_THREAD_H */
+#endif /* _XBT_THREAD_H */
#include <xbt/ex.hpp>
#include "jmsg.h"
-#include "xbt/synchro_core.h"
#include "jmsg_synchro.h"
#include "jxbt_utilities.h"
+#include "xbt/synchro.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
#include <xbt/ex.hpp>
#include "msg_private.h"
-#include "xbt/sysdep.h"
-#include "xbt/synchro_core.h"
#include "xbt/log.h"
+#include "xbt/synchro.h"
+#include "xbt/sysdep.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_synchro, msg, "Logging specific to MSG (synchro)");
return simcall_sem_would_block(sem);
}
+/*-**** barrier related functions ****-*/
+typedef struct s_msg_bar {
+ xbt_mutex_t mutex;
+ xbt_cond_t cond;
+ unsigned int arrived_processes;
+ unsigned int expected_processes;
+} s_msg_bar_t;
+
/** @brief Initializes a barrier, with count elements */
msg_bar_t MSG_barrier_init(unsigned int count) {
- return (msg_bar_t)xbt_barrier_init(count);
+ msg_bar_t bar = xbt_new0(s_msg_bar, 1);
+ bar->expected_processes = count;
+ bar->arrived_processes = 0;
+ bar->mutex = xbt_mutex_init();
+ bar->cond = xbt_cond_init();
+ return bar;
}
/** @brief Initializes a barrier, with count elements */
void MSG_barrier_destroy(msg_bar_t bar) {
- xbt_barrier_destroy((xbt_bar_t)bar);
+ xbt_mutex_destroy(bar->mutex);
+ xbt_cond_destroy(bar->cond);
+ xbt_free(bar);
}
/** @brief Performs a barrier already initialized */
int MSG_barrier_wait(msg_bar_t bar) {
- if(xbt_barrier_wait((xbt_bar_t)bar) == XBT_BARRIER_SERIAL_PROCESS)
+ xbt_mutex_acquire(bar->mutex);
+ if (++bar->arrived_processes == bar->expected_processes) {
+ xbt_cond_broadcast(bar->cond);
+ xbt_mutex_release(bar->mutex);
+ bar->arrived_processes = 0;
return MSG_BARRIER_SERIAL_PROCESS;
- else
- return 0;
+ }
+
+ xbt_cond_wait(bar->cond, bar->mutex);
+ xbt_mutex_release(bar->mutex);
+ return 0;
}
/**@}*/
#ifndef SMPI_PRIVATE_H
#define SMPI_PRIVATE_H
+#include "simgrid/simix.h"
+#include "smpi/smpi.h"
+#include "src/include/smpi/smpi_interface.h"
+#include "src/instr/instr_private.h"
#include "src/internal_config.h"
#include "xbt.h"
#include "xbt/base.h"
+#include "xbt/synchro.h"
#include "xbt/xbt_os_time.h"
-#include "xbt/synchro_core.h"
-#include "simgrid/simix.h"
-#include "src/include/smpi/smpi_interface.h"
-#include "smpi/smpi.h"
-#include "src/instr/instr_private.h"
SG_BEGIN_DECL()
XBT_PRIVATE void smpi_process_set_replaying(bool s);
XBT_PRIVATE bool smpi_process_get_replaying();
-XBT_PRIVATE void smpi_deployment_register_process(const char* instance_id, int rank, int index, MPI_Comm** comm, xbt_bar_t*bar);
+XBT_PRIVATE void smpi_deployment_register_process(const char* instance_id, int rank, int index, MPI_Comm** comm,
+ msg_bar_t* bar);
XBT_PRIVATE void smpi_deployment_cleanup_instances();
XBT_PRIVATE void smpi_comm_copy_buffer_callback(smx_activity_t comm, void *buff, size_t buff_size);
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "private.h"
-#include "xbt/sysdep.h"
-#include "xbt/synchro_core.h"
-#include "xbt/log.h"
+#include "simgrid/msg.h" /* barrier */
#include "xbt/dict.h"
+#include "xbt/log.h"
+#include "xbt/sysdep.h"
static xbt_dict_t smpi_instances = nullptr;
extern int process_count;
int present_processes;
int index;
MPI_Comm comm_world;
- xbt_bar_t finalization_barrier;
+ msg_bar_t finalization_barrier;
} s_smpi_mpi_instance_t;
/** \ingroup smpi_simulation
instance->present_processes = 0;
instance->index = process_count;
instance->comm_world = MPI_COMM_NULL;
- instance->finalization_barrier=xbt_barrier_init(num_processes);
+ instance->finalization_barrier = MSG_barrier_init(num_processes);
process_count+=num_processes;
}
//get the index of the process in the process_data array
-void smpi_deployment_register_process(const char* instance_id, int rank, int index,MPI_Comm** comm, xbt_bar_t* bar){
+void smpi_deployment_register_process(const char* instance_id, int rank, int index, MPI_Comm** comm, msg_bar_t* bar)
+{
if(smpi_instances==nullptr){//no instance registered, we probably used smpirun.
index_to_process_data[index]=index;
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);
+ MSG_barrier_destroy(instance->finalization_barrier);
}
xbt_dict_free(&smpi_instances);
}
int sampling; /* inside an SMPI_SAMPLE_ block? */
char* instance_id;
bool replaying; /* is the process replaying a trace */
- xbt_bar_t finalization_barrier;
+ msg_bar_t finalization_barrier;
int return_value;
smpi_trace_call_location_t trace_call_loc;
#if HAVE_PAPI
}
MPI_Comm* temp_comm_world;
- xbt_bar_t temp_bar;
+ msg_bar_t temp_bar;
smpi_deployment_register_process(instance_id, rank, index, &temp_comm_world, &temp_bar);
smpi_process_data_t data = smpi_process_remote_data(index);
data->comm_world = temp_comm_world;
int index = smpi_process_index();
// wait for all pending asynchronous comms to finish
- xbt_barrier_wait(process_data[index_to_process_data[index]]->finalization_barrier);
+ MSG_barrier_wait(process_data[index_to_process_data[index]]->finalization_barrier);
}
/** @brief Check if a process is finalized */
group = smpi_group_new(process_count);
MPI_COMM_WORLD = smpi_comm_new(group, nullptr);
MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast<void *>(process_count));
- xbt_bar_t bar=xbt_barrier_init(process_count);
+ msg_bar_t bar = MSG_barrier_init(process_count);
for (i = 0; i < process_count; i++) {
smpi_group_set_mapping(group, i, i);
void smpi_global_destroy()
{
int count = smpi_process_count();
- int i;
smpi_bench_destroy();
if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){
while (smpi_group_unuse(smpi_comm_group(MPI_COMM_WORLD)) > 0);
- xbt_barrier_destroy(process_data[0]->finalization_barrier);
+ MSG_barrier_destroy(process_data[0]->finalization_barrier);
}else{
smpi_deployment_cleanup_instances();
}
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
if(process_data[i]->comm_self!=MPI_COMM_NULL){
smpi_comm_destroy(process_data[i]->comm_self);
}
#define RMA_TAG -1234
-xbt_bar_t creation_bar = nullptr;
+msg_bar_t creation_bar = nullptr;
typedef struct s_smpi_mpi_win{
void* base;
MPI_Info info;
int assert;
std::vector<MPI_Request> *requests;
- xbt_bar_t bar;
+ msg_bar_t bar;
MPI_Win* connected_wins;
char* name;
int opened;
win->connected_wins[rank] = win;
if(rank==0){
- win->bar=xbt_barrier_init(comm_size);
+ win->bar = MSG_barrier_init(comm_size);
}
mpi_coll_allgather_fun(&(win->connected_wins[rank]), sizeof(MPI_Win), MPI_BYTE, win->connected_wins, sizeof(MPI_Win),
MPI_BYTE, comm);
- mpi_coll_bcast_fun( &(win->bar), sizeof(xbt_bar_t), MPI_BYTE, 0, comm);
+ mpi_coll_bcast_fun(&(win->bar), sizeof(msg_bar_t), MPI_BYTE, 0, comm);
mpi_coll_barrier_fun(comm);
int smpi_mpi_win_free( MPI_Win* win){
//As per the standard, perform a barrier to ensure every async comm is finished
- xbt_barrier_wait((*win)->bar);
+ MSG_barrier_wait((*win)->bar);
delete (*win)->requests;
xbt_free((*win)->connected_wins);
if ((*win)->name != nullptr){
mpi_coll_barrier_fun((*win)->comm);
int rank=smpi_comm_rank((*win)->comm);
if(rank == 0)
- xbt_barrier_destroy((*win)->bar);
+ MSG_barrier_destroy((*win)->bar);
xbt_free(*win);
*win = MPI_WIN_NULL;
return MPI_SUCCESS;
if(win->opened==0)
win->opened=1;
if(assert != MPI_MODE_NOPRECEDE){
- xbt_barrier_wait(win->bar);
+ MSG_barrier_wait(win->bar);
std::vector<MPI_Request> *reqs = win->requests;
int size = static_cast<int>(reqs->size());
}
win->assert = assert;
- xbt_barrier_wait(win->bar);
+ MSG_barrier_wait(win->bar);
XBT_DEBUG("Leaving fence ");
return MPI_SUCCESS;
#include "xbt/backtrace.h"
#include "xbt/backtrace.hpp"
#include "xbt/str.h"
-#include "xbt/synchro_core.h"
#include "src/xbt_modinter.h" /* backtrace initialization headers */
#include "src/xbt/ex_interface.h"
/* layout_simple - a dumb log layout */
-/* Copyright (c) 2007-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2016. The SimGrid Team. */
/* 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 "src/internal_config.h" /* execinfo when available */
-#include "xbt/synchro_core.h" /* xbt_thread_self_name */
#include "xbt/sysdep.h"
#include "xbt/strbuff.h"
#include "src/xbt/log_private.h"
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/ex.h"
-#include "xbt/synchro_core.h"
+#include "xbt/synchro.h"
#include "simgrid/simix.h" /* used implementation */
{
SIMIX_cond_unref((smx_cond_t) cond);
}
-
-/***** barrier related functions *****/
-typedef struct s_xbt_bar_ {
- xbt_mutex_t mutex;
- xbt_cond_t cond;
- unsigned int arrived_processes;
- unsigned int expected_processes;
-} s_xbt_bar_;
-
-xbt_bar_t xbt_barrier_init(unsigned int count)
-{
- xbt_bar_t bar = xbt_new0(s_xbt_bar_, 1);
- bar->expected_processes = count;
- bar->arrived_processes = 0;
- bar->mutex = xbt_mutex_init();
- bar->cond = xbt_cond_init();
- return bar;
-}
-
-int xbt_barrier_wait(xbt_bar_t bar)
-{
- int ret=0;
- xbt_mutex_acquire(bar->mutex);
- if (++bar->arrived_processes == bar->expected_processes) {
- xbt_cond_broadcast(bar->cond);
- xbt_mutex_release(bar->mutex);
- ret=XBT_BARRIER_SERIAL_PROCESS;
- bar->arrived_processes = 0;
- } else {
- xbt_cond_wait(bar->cond, bar->mutex);
- xbt_mutex_release(bar->mutex);
- }
- return ret;
-}
-
-void xbt_barrier_destroy(xbt_bar_t bar)
-{
- xbt_mutex_destroy(bar->mutex);
- xbt_cond_destroy(bar->cond);
- xbt_free(bar);
-}
* and the MC does not find the counter-example.
*/
-#include "simgrid/msg.h"
#include "mc/mc.h"
-#include <xbt/synchro_core.h>
+#include "simgrid/msg.h"
+#include <xbt/synchro.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
include/xbt/str.h
include/xbt/strbuff.h
include/xbt/swag.h
- include/xbt/synchro_core.h
+ include/xbt/synchro.h
include/xbt/sysdep.h
include/xbt/system_error.hpp
include/xbt/utility.hpp