*/
void SIMIX_comm_destroy(smx_action_t action)
{
- XBT_DEBUG("Destroy action %p (refcount:%d)", action, action->comm.refcount);
+ XBT_DEBUG("Destroy action %p (refcount: %d), state: %d",
+ action, action->comm.refcount, action->state);
- xbt_assert(action->comm.refcount > 0,
- "The refcount of comm %p is already 0 before decreasing it. "
- "That's a bug!", action);
-
+ if (action->comm.refcount <= 0) {
+ xbt_backtrace_display_current();
+ xbt_die("the refcount of comm %p is already 0 before decreasing it. "
+ "That's a bug!", action);
-
+ }
action->comm.refcount--;
if (action->comm.refcount > 0)
return;
if (comm->comm.dst_buff_size)
*comm->comm.dst_buff_size = buff_size;
++<<<<<<< HEAD
+ if (buff_size > 0)
+ (*SIMIX_comm_copy_data_callback) (comm, buff_size);
++=======
+ if (buff_size == 0)
+ return;
+
+ SIMIX_comm_copy_data_callback(comm, buff_size);
++>>>>>>> master
/* Set the copied flag so we copy data only once */
/* (this function might be called from both communication ends) */
void *smpi_shared_malloc(size_t size, const char *file, int line)
{
- char *loc = bprintf("%s:%d:%zu", file, line, size);
+ char *loc = bprintf("%zu_%s_%d", (size_t)getpid(), file, line);
+ size_t len = strlen(loc);
+ size_t i;
+ int fd;
+ void* mem;
shared_data_t *data;
+ for(i = 0; i < len; i++) {
+ /* Make the 'loc' ID be a flat filename */
+ if(loc[i] == '/') {
+ loc[i] = '_';
+ }
+ }
if (!allocs) {
- allocs = xbt_dict_new();
+ allocs = xbt_dict_new_homogeneous(free);
}
data = xbt_dict_get_or_null(allocs, loc);
- if (!data) {
- data = (shared_data_t *) xbt_malloc0(sizeof(int) + size);
+ if(!data) {
+ fd = shm_open(loc, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if(fd < 0) {
+ switch(errno) {
+ case EEXIST:
+ xbt_die("Please cleanup /dev/shm/%s", loc);
+ default:
+ xbt_die("An unhandled error occured while opening %s: %s", loc, strerror(errno));
+ }
+ }
+ data = xbt_new(shared_data_t, 1);
+ data->fd = fd;
data->count = 1;
- xbt_dict_set(allocs, loc, data, &free);
+ data->loc = loc;
+ mem = shm_map(fd, size, data);
+ if(shm_unlink(loc) < 0) {
+ XBT_WARN("Could not early unlink %s: %s", loc, strerror(errno));
+ }
+ xbt_dict_set(allocs, loc, data, NULL);
+ XBT_DEBUG("Mapping %s at %p through %d", loc, mem, fd);
} else {
+ mem = shm_map(data->fd, size, data);
data->count++;
}
- free(loc);
- return data->data;
+ XBT_DEBUG("Malloc %zu in %p (metadata at %p)", size, mem, data);
+ return mem;
}
void smpi_shared_free(void *ptr)
return rate;
}
- /**--------- <copy/paste C code snippet in surf/network.c> -------------
- * produced by:
- * ./regression2.py ./pingpong-in.dat 0.15 100 2 2.4e-5 1.25e8
- * outliers: 65
- * gnuplot:
- plot "./pingpong-in.dat" using 1:2 with lines title "data", \
- (x >= 65472) ? 0.00850436*x+558.894 : \
- (x >= 15424) ? 0.0114635*x+167.446 : \
- (x >= 9376) ? 0.0136219*x+124.464 : \
- (x >= 5776) ? 0.00735707*x+105.022 : \
- (x >= 3484) ? 0.0103235*x+90.2886 : \
- (x >= 1426) ? 0.0131384*x+77.3159 : \
- (x >= 732) ? 0.0233927*x+93.6146 : \
- (x >= 257) ? 0.0236608*x+93.7637 : \
- (x >= 0) ? 0.00985119*x+96.704 : \
- 1.0 with lines title "piecewise function"
- *-------------------------------------------------------------------*/
-
+ /**********************/
+ /* SMPI callbacks */
+ /**********************/
+ static double smpi_latency_factor(double size)
+ {
+ /* 1 B <= size <= 1 KiB */
+ if (size <= 1024.0) {
+ return 1.0056;
+ }
- /* 2 KiB <= size <= 32 KiB */
- if (size <= 32768.0) {
- return 1.8805;
- }
+static double smpi_bandwidth_factor(double size)
+{
- /* 64 KiB <= size <= 4 MiB */
- return 22.7111;
+ if (size >= 65472) return 0.940694;
+ if (size >= 15424) return 0.697866;
+ if (size >= 9376) return 0.58729;
+ if (size >= 5776) return 1.08739;
+ if (size >= 3484) return 0.77493;
+ if (size >= 1426) return 0.608902;
+ if (size >= 732) return 0.341987;
+ if (size >= 257) return 0.338112;
+ if (size >= 0) return 0.812084;
+ return 1.0;
}
-static double smpi_bandwidth_factor(double size)
+static double smpi_latency_factor(double size)
{
- /* 1 B <= size <= 1 KiB */
- if (size <= 1024.0) {
- return 0.2758;
- }
-
- /* 2 KiB <= size <= 32 KiB */
- if (size <= 32768.0) {
- return 0.5477;
- }
- /* 64 KiB <= size <= 4 MiB */
- return 0.9359;
+ if (size >= 65472) return 11.6436;
+ if (size >= 15424) return 3.48845;
+ if (size >= 9376) return 2.59299;
+ if (size >= 5776) return 2.18796;
+ if (size >= 3484) return 1.88101;
+ if (size >= 1426) return 1.61075;
+ if (size >= 732) return 1.9503;
+ if (size >= 257) return 1.95341;
+ if (size >= 0) return 2.01467;
+ return 1.0;
}
+/**--------- <copy/paste C code snippet in surf/network.c> -----------*/
static double smpi_bandwidth_constraint(double rate, double bound,
double size)