当前位置: 首页>>代码示例>>C++>>正文


C++ xbt_assert函数代码示例

本文整理汇总了C++中xbt_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ xbt_assert函数的具体用法?C++ xbt_assert怎么用?C++ xbt_assert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xbt_assert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MSG_parallel_task_execute

/** \ingroup msg_task_usage
 * \brief Executes a parallel task and waits for its termination.
 *
 * \param task a #msg_task_t to execute on the location on which the process is running.
 *
 * \return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED
 * or #MSG_HOST_FAILURE otherwise
 */
msg_error_t MSG_parallel_task_execute(msg_task_t task)
{
  xbt_ex_t e;
  simdata_task_t simdata = task->simdata;
  msg_process_t self = SIMIX_process_self();
  simdata_process_t p_simdata = SIMIX_process_self_get_data(self);
  e_smx_state_t comp_state;
  msg_error_t status = MSG_OK;

#ifdef HAVE_TRACING
  TRACE_msg_task_execute_start(task);
#endif

  xbt_assert((!simdata->compute) && (task->simdata->isused == 0),
             "This task is executed somewhere else. Go fix your code! %d",
             task->simdata->isused);

  XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self()));

  if (simdata->computation_amount == 0 && !simdata->host_nb) {
#ifdef HAVE_TRACING
    TRACE_msg_task_execute_end(task);
#endif
    return MSG_OK;
  }


  TRY {

    simdata->isused=1;

    if (simdata->host_nb > 0) {
      simdata->compute = simcall_host_parallel_execute(task->name,
                                                       simdata->host_nb,
                                                       simdata->host_list,
                                                       simdata->comp_amount,
                                                       simdata->comm_amount,
                                                       1.0, -1.0);
      XBT_DEBUG("Parallel execution action created: %p", simdata->compute);
    } else {
      simdata->compute = simcall_host_execute(task->name,
                                              p_simdata->m_host,
                                              simdata->computation_amount,
                                              simdata->priority);

    }
#ifdef HAVE_TRACING
    simcall_set_category(simdata->compute, task->category);
#endif
    p_simdata->waiting_action = simdata->compute;
    comp_state = simcall_host_execution_wait(simdata->compute);

    p_simdata->waiting_action = NULL;

    simdata->isused=0;

    XBT_DEBUG("Execution task '%s' finished in state %d",
              task->name, (int)comp_state);
  }
  CATCH(e) {
    switch (e.category) {
    case cancel_error:
      status = MSG_TASK_CANCELED;
      break;
    default:
      RETHROW;
    }
    xbt_ex_free(e);
  }
  /* action ended, set comm and compute = NULL, the actions is already destroyed
   * in the main function */
  simdata->computation_amount = 0.0;
  simdata->comm = NULL;
  simdata->compute = NULL;
#ifdef HAVE_TRACING
  TRACE_msg_task_execute_end(task);
#endif

  MSG_RETURN(status);
}
开发者ID:dhascome,项目名称:simgrid,代码行数:88,代码来源:msg_gos.c

示例2: xbt_assert

/** \ingroup m_task_management
 * \brief Return the name of a #msg_task_t.
 *
 * This functions returns the name of a #msg_task_t as specified on creation
 */
const char *MSG_task_get_name(msg_task_t task)
{
  xbt_assert(task, "Invalid parameters");
  return task->name;
}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:10,代码来源:msg_task.c

示例3: MSG_parallel_task_execute

/** \ingroup msg_task_usage
 * \brief Executes a parallel task and waits for its termination.
 *
 * \param task a #msg_task_t to execute on the location on which the process is running.
 *
 * \return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED
 * or #MSG_HOST_FAILURE otherwise
 */
msg_error_t MSG_parallel_task_execute(msg_task_t task)
{
  simdata_task_t simdata = task->simdata;
  simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data();
  e_smx_state_t comp_state;
  msg_error_t status = MSG_OK;

  TRACE_msg_task_execute_start(task);

  xbt_assert((!simdata->compute) && !task->simdata->isused,
             "This task is executed somewhere else. Go fix your code!");

  XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self()));

  if (simdata->flops_amount == 0 && !simdata->host_nb) {
    TRACE_msg_task_execute_end(task);
    return MSG_OK;
  }

  try {
    simdata->setUsed();

    if (simdata->host_nb > 0) {
      simdata->compute = static_cast<simgrid::simix::Exec*>(
          simcall_execution_parallel_start(task->name, simdata->host_nb,simdata->host_list,
                                                       simdata->flops_parallel_amount, simdata->bytes_parallel_amount,
                                                       1.0, -1.0));
      XBT_DEBUG("Parallel execution action created: %p", simdata->compute);
    } else {
      unsigned long affinity_mask =
         (unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(simdata->affinity_mask_db, (char *) p_simdata->m_host,
                                                             sizeof(msg_host_t));
      XBT_DEBUG("execute %[email protected]%s with affinity(0x%04lx)",
                MSG_task_get_name(task), MSG_host_get_name(p_simdata->m_host), affinity_mask);

          simdata->compute = static_cast<simgrid::simix::Exec*>(
              simcall_execution_start(task->name, simdata->flops_amount, simdata->priority,
                                                 simdata->bound, affinity_mask));
    }
    simcall_set_category(simdata->compute, task->category);
    p_simdata->waiting_action = simdata->compute;
    comp_state = simcall_execution_wait(simdata->compute);

    p_simdata->waiting_action = nullptr;
    simdata->setNotUsed();

    XBT_DEBUG("Execution task '%s' finished in state %d", task->name, (int)comp_state);
  }
  catch (xbt_ex& e) {
    switch (e.category) {
    case cancel_error:
      status = MSG_TASK_CANCELED;
      break;
    case host_error:
      status = MSG_HOST_FAILURE;
      break;
    default:
      throw;
    }
  }

  /* action ended, set comm and compute = nullptr, the actions is already destroyed in the main function */
  simdata->flops_amount = 0.0;
  simdata->comm = nullptr;
  simdata->compute = nullptr;
  TRACE_msg_task_execute_end(task);

  MSG_RETURN(status);
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:77,代码来源:msg_gos.cpp

示例4: MSG_task_get_sender

/** \ingroup m_task_management
 * \brief Return the sender of a #msg_task_t.
 *
 * This functions returns the #msg_process_t which sent this task
 */
msg_process_t MSG_task_get_sender(msg_task_t task)
{
  xbt_assert(task, "Invalid parameters");
  return ((simdata_task_t) task->simdata)->sender;
}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:10,代码来源:msg_task.c

示例5: smpi_coll_tuned_reduce_scatter_mpich_noncomm

int smpi_coll_tuned_reduce_scatter_mpich_noncomm(void *sendbuf, void *recvbuf, int recvcounts[],
                              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
    int mpi_errno = MPI_SUCCESS;
    int comm_size = smpi_comm_size(comm) ;
    int rank = smpi_comm_rank(comm);
    int pof2;
    int log2_comm_size;
    int i, k;
    int recv_offset, send_offset;
    int block_size, total_count, size;
    MPI_Aint true_extent, true_lb;
    int buf0_was_inout;
    void *tmp_buf0;
    void *tmp_buf1;
    void *result_ptr;

    smpi_datatype_extent(datatype, &true_lb, &true_extent);

    pof2 = 1;
    log2_comm_size = 0;
    while (pof2 < comm_size) {
        pof2 <<= 1;
        ++log2_comm_size;
    }

    /* begin error checking */
    xbt_assert(pof2 == comm_size); /* FIXME this version only works for power of 2 procs */

    for (i = 0; i < (comm_size - 1); ++i) {
        xbt_assert(recvcounts[i] == recvcounts[i+1]);
    }
    /* end error checking */

    /* size of a block (count of datatype per block, NOT bytes per block) */
    block_size = recvcounts[0];
    total_count = block_size * comm_size;

    tmp_buf0=( void *)xbt_malloc( true_extent * total_count);
    tmp_buf1=( void *)xbt_malloc( true_extent * total_count);
    /* adjust for potential negative lower bound in datatype */
    tmp_buf0 = (void *)((char*)tmp_buf0 - true_lb);
    tmp_buf1 = (void *)((char*)tmp_buf1 - true_lb);

    /* Copy our send data to tmp_buf0.  We do this one block at a time and
       permute the blocks as we go according to the mirror permutation. */
    for (i = 0; i < comm_size; ++i) {
        mpi_errno = smpi_datatype_copy((char *)(sendbuf == MPI_IN_PLACE ? recvbuf : sendbuf) + (i * true_extent * block_size), block_size, datatype,
                                   (char *)tmp_buf0 + (MPIU_Mirror_permutation(i, log2_comm_size) * true_extent * block_size), block_size, datatype);
        if (mpi_errno) return(mpi_errno);
    }
    buf0_was_inout = 1;

    send_offset = 0;
    recv_offset = 0;
    size = total_count;
    for (k = 0; k < log2_comm_size; ++k) {
        /* use a double-buffering scheme to avoid local copies */
        char *incoming_data = (buf0_was_inout ? tmp_buf1 : tmp_buf0);
        char *outgoing_data = (buf0_was_inout ? tmp_buf0 : tmp_buf1);
        int peer = rank ^ (0x1 << k);
        size /= 2;

        if (rank > peer) {
            /* we have the higher rank: send top half, recv bottom half */
            recv_offset += size;
        }
        else {
            /* we have the lower rank: recv top half, send bottom half */
            send_offset += size;
        }

        smpi_mpi_sendrecv(outgoing_data + send_offset*true_extent,
                                     size, datatype, peer, COLL_TAG_SCATTER,
                                     incoming_data + recv_offset*true_extent,
                                     size, datatype, peer, COLL_TAG_SCATTER,
                                     comm, MPI_STATUS_IGNORE);
        /* always perform the reduction at recv_offset, the data at send_offset
           is now our peer's responsibility */
        if (rank > peer) {
            /* higher ranked value so need to call op(received_data, my_data) */
            smpi_op_apply(op, 
                   incoming_data + recv_offset*true_extent,
                     outgoing_data + recv_offset*true_extent,
                     &size, &datatype );
            /* buf0_was_inout = buf0_was_inout; */
        }
        else {
            /* lower ranked value so need to call op(my_data, received_data) */
	    smpi_op_apply( op,
		     outgoing_data + recv_offset*true_extent,
                     incoming_data + recv_offset*true_extent,
                     &size, &datatype);
            buf0_was_inout = !buf0_was_inout;
        }

        /* the next round of send/recv needs to happen within the block (of size
           "size") that we just received and reduced */
        send_offset = recv_offset;
    }
//.........这里部分代码省略.........
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:101,代码来源:reduce_scatter-mpich.c

示例6: MSG_mailbox_put_with_timeout

msg_error_t
MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
                             double timeout)
{
  msg_error_t ret = MSG_OK;
  simdata_task_t t_simdata = NULL;
  msg_process_t process = MSG_process_self();
  simdata_process_t p_simdata = SIMIX_process_self_get_data(process);

  int call_end = TRACE_msg_task_put_start(task);    //must be after CHECK_HOST()

  /* Prepare the task to send */
  t_simdata = task->simdata;
  t_simdata->sender = process;
  t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;

  if (t_simdata->isused != 0) {
    if (msg_global->debug_multiple_use){
      XBT_ERROR("This task is already used in there:");
      xbt_backtrace_display(t_simdata->isused);
      XBT_ERROR("And you try to reuse it from here:");
      xbt_backtrace_display_current();
    } else {
      xbt_assert(t_simdata->isused == 0,
                 "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)");
    }
  }

  if (msg_global->debug_multiple_use)
    MSG_BT(t_simdata->isused, "Using Backtrace");
  else
    t_simdata->isused = (void*)1;
  t_simdata->comm = NULL;
  msg_global->sent_msg++;


  p_simdata->waiting_task = task;

  xbt_ex_t e;
  /* Try to send it by calling SIMIX network layer */
  TRY {
    smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simix call  */
    comm = simcall_comm_isend(SIMIX_process_self(), mailbox,t_simdata->bytes_amount,
                                  t_simdata->rate, task, sizeof(void *),
                                  NULL, NULL, NULL, task, 0);
    if (TRACE_is_enabled())
      simcall_set_category(comm, task->category);
     t_simdata->comm = comm;
     simcall_comm_wait(comm, timeout);
  }

  CATCH(e) {
    switch (e.category) {
    case cancel_error:
      ret = MSG_HOST_FAILURE;
      break;
    case network_error:
      ret = MSG_TRANSFER_FAILURE;
      break;
    case timeout_error:
      ret = MSG_TIMEOUT;
      break;
    default:
      RETHROW;
    }
    xbt_ex_free(e);

    /* If the send failed, it is not used anymore */
    if (msg_global->debug_multiple_use && t_simdata->isused!=0)
      xbt_ex_free(*(xbt_ex_t*)t_simdata->isused);
    t_simdata->isused = 0;
  }


  p_simdata->waiting_task = NULL;
  if (call_end)
    TRACE_msg_task_put_end();
  MSG_RETURN(ret);
}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:79,代码来源:msg_mailbox.c

示例7: xbt_assert

/** \ingroup m_process_management
 * \brief Return the name of an agent.
 *
 * This function checks whether \a process is a valid pointer or not
   and return its name.
 */
const char *MSG_process_get_name(m_process_t process)
{
  xbt_assert(process, "Invalid parameter");

  return SIMIX_req_process_get_name(process);
}
开发者ID:rosacris,项目名称:simgrid,代码行数:12,代码来源:m_process.c

示例8: MSG_process_is_suspended

/** \ingroup m_process_management
 * \brief Returns true if the process is suspended .
 *
 * This checks whether a process is suspended or not by inspecting the
 * task on which it was waiting for the completion.
 */
int MSG_process_is_suspended(m_process_t process)
{
  xbt_assert(process != NULL, "Invalid parameter");
  return SIMIX_req_process_is_suspended(process);
}
开发者ID:rosacris,项目名称:simgrid,代码行数:11,代码来源:m_process.c

示例9: surf_config_init


//.........这里部分代码省略.........
                     _surf_cfg_cb__latency_factor, NULL);
    double_default_value = 1.0;
    xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
                     "Correction factor to apply to the provided bandwidth (default value set by network model)",
                     xbt_cfgelm_double, &double_default_value, 1, 1,
                     _surf_cfg_cb__bandwidth_factor, NULL);
    double_default_value = 0.0;
    xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
                     "Correction factor to apply to the weight of competing streams(default value set by network model)",
                     xbt_cfgelm_double, &double_default_value, 1, 1,
                     _surf_cfg_cb__weight_S, NULL);

    /* Inclusion path */
    xbt_cfg_register(&_surf_cfg_set, "path",
                     "Lookup path for inclusions in platform and deployment XML files",
                     xbt_cfgelm_string, NULL, 0, 0,
                     _surf_cfg_cb__surf_path, NULL);

    default_value_int = 0;
    xbt_cfg_register(&_surf_cfg_set, "maxmin_selective_update",
                     "Update the constraint set propagating recursively to others constraints",
                     xbt_cfgelm_int, &default_value_int, 0, 1,
                     _surf_cfg_cb__surf_maxmin_selective_update, NULL);

    /* do model-check */
    default_value_int = 0;
    xbt_cfg_register(&_surf_cfg_set, "model-check",
                     "Activate the model-checking of the \"simulated\" system (EXPERIMENTAL -- msg only for now)",
                     xbt_cfgelm_int, &default_value_int, 0, 1,
                     _surf_cfg_cb_model_check, NULL);
    /*
       FIXME: this function is not setting model-check to it's default value because
       internally it calls to variable->cb_set that in this case is the function 
       _surf_cfg_cb_model_check which sets it's value to 1 (instead of the defalut value 0)
       xbt_cfg_set_int(_surf_cfg_set, "model-check", default_value_int); */

    /* context factory */
    default_value = xbt_strdup("ucontext");
    xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
                     "Context factory to use in SIMIX (ucontext, thread or raw)",
                     xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);

    /* stack size of contexts in Ko */
    default_value_int = 128;
    xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
                     "Stack size of contexts in Ko (ucontext or raw only)",
                     xbt_cfgelm_int, &default_value_int, 1, 1,
                     _surf_cfg_cb_context_stack_size, NULL);

    /* number of parallel threads for user processes */
    default_value_int = 1;
    xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
                     "Number of parallel threads for user contexts (EXPERIMENTAL)",
                     xbt_cfgelm_int, &default_value_int, 1, 1,
                     _surf_cfg_cb_contexts_nthreads, NULL);

    /* minimal number of user contexts to be run in parallel */
    default_value_int = 1;
    xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
        "Minimal number of user contexts to be run in parallel",
        xbt_cfgelm_int, &default_value_int, 1, 1,
        _surf_cfg_cb_contexts_parallel_threshold, NULL);

    default_value_int = 0;
    xbt_cfg_register(&_surf_cfg_set, "fullduplex",
                     "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM03)",
                     xbt_cfgelm_int, &default_value_int, 0, 1,
                     _surf_cfg_cb__surf_network_fullduplex, NULL);
    xbt_cfg_setdefault_int(_surf_cfg_set, "fullduplex", default_value_int);

#ifdef HAVE_GTNETS
    xbt_cfg_register(&_surf_cfg_set, "gtnets_jitter",
                     "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
                     xbt_cfgelm_double, NULL, 1, 1,
                     _surf_cfg_cb__gtnets_jitter, NULL);
    xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets_jitter", 0.0);

    default_value_int = 10;
    xbt_cfg_register(&_surf_cfg_set, "gtnets_jitter_seed",
                     "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
                     xbt_cfgelm_int, &default_value_int, 0, 1,
                     _surf_cfg_cb__gtnets_jitter_seed, NULL);
#endif

    if (!surf_path) {
      /* retrieves the current directory of the        current process */
      const char *initial_path = __surf_get_initial_path();
      xbt_assert((initial_path),
                  "__surf_get_initial_path() failed! Can't resolves current Windows directory");

      surf_path = xbt_dynar_new(sizeof(char *), NULL);
      xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
    }


    surf_config_cmd_line(argc, argv);
  } else {
    XBT_WARN("Call to surf_config_init() after initialization ignored");
  }
}
开发者ID:rosacris,项目名称:simgrid,代码行数:101,代码来源:surf_config.c

示例10: get_memory_map

memory_map_t get_memory_map(void)
{
  FILE *fp;                     /* File pointer to process's proc maps file */
  char *line = NULL;            /* Temporal storage for each line that is readed */
  ssize_t read;                 /* Number of bytes readed */
  size_t n = 0;                 /* Amount of bytes to read by getline */
  memory_map_t ret = NULL;      /* The memory map to return */

/* The following variables are used during the parsing of the file "maps" */
  s_map_region memreg;          /* temporal map region used for creating the map */
  char *lfields[6], *tok, *endptr;
  int i;

/* Open the actual process's proc maps file and create the memory_map_t */
/* to be returned. */
  fp = fopen("/proc/self/maps", "r");

  xbt_assert(fp,
              "Cannot open /proc/self/maps to investigate the memory map of the process. Please report this bug.");

  ret = xbt_new0(s_memory_map_t, 1);

  /* Read one line at the time, parse it and add it to the memory map to be returned */
  while ((read = getline(&line, &n, fp)) != -1) {

    /* Wipeout the new line character */
    line[read - 1] = '\0';

    /* Tokenize the line using spaces as delimiters and store each token */
    /* in lfields array. We expect 5 tokens/fields */
    lfields[0] = strtok(line, " ");

    for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
      lfields[i] = strtok(NULL, " ");
    }

    /* Check to see if we got the expected amount of columns */
    if (i < 6)
      xbt_abort();

    /* Ok we are good enough to try to get the info we need */
    /* First get the start and the end address of the map   */
    tok = strtok(lfields[0], "-");
    if (tok == NULL)
      xbt_abort();

    memreg.start_addr = (void *) strtoul(tok, &endptr, 16);
    /* Make sure that the entire string was an hex number */
    if (*endptr != '\0')
      xbt_abort();

    tok = strtok(NULL, "-");
    if (tok == NULL)
      xbt_abort();

    memreg.end_addr = (void *) strtoul(tok, &endptr, 16);
    /* Make sure that the entire string was an hex number */
    if (*endptr != '\0')
      xbt_abort();

    /* Get the permissions flags */
    if (strlen(lfields[1]) < 4)
      xbt_abort();

    memreg.prot = 0;

    for (i = 0; i < 3; i++){
      switch(lfields[1][i]){
        case 'r':
          memreg.prot |= PROT_READ;
          break;
        case 'w':
          memreg.prot |= PROT_WRITE;
          break;
        case 'x':
          memreg.prot |= PROT_EXEC;
          break;
        default:
          break;
      }
    }
    if (memreg.prot == 0)
      memreg.prot |= PROT_NONE;

    if (lfields[1][4] == 'p')
      memreg.flags |= MAP_PRIVATE;

    else if (lfields[1][4] == 's')
      memreg.flags |= MAP_SHARED;

    /* Get the offset value */
    memreg.offset = (void *) strtoul(lfields[2], &endptr, 16);
    /* Make sure that the entire string was an hex number */
    if (*endptr != '\0')
      xbt_abort();

    /* Get the device major:minor bytes */
    tok = strtok(lfields[3], ":");
    if (tok == NULL)
      xbt_abort();
//.........这里部分代码省略.........
开发者ID:rosacris,项目名称:simgrid,代码行数:101,代码来源:memory_map.c

示例11: STag_surfxml_host

void STag_surfxml_host(void){
  AS_TAG = 0;
  xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
}
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:4,代码来源:surfxml_sax_cb.cpp

示例12: master

/** Emitter function  */
int master(int argc, char *argv[])
{
  int workers_count = 0;
  msg_host_t *workers = NULL;
  msg_task_t *todo = NULL;
  msg_host_t host_self = MSG_host_self();
  char *master_name = (char *) MSG_host_get_name(host_self);
  double task_comp_size = 0;
  double task_comm_size = 0;
  char channel[1024];
  double timeout = -1;

  int i;

  TRACE_category(master_name);

  _XBT_GNUC_UNUSED int res = sscanf(argv[1], "%lg", &timeout);
  xbt_assert(res,"Invalid argument %s\n", argv[1]);
  res = sscanf(argv[2], "%lg", &task_comp_size);
  xbt_assert(res, "Invalid argument %s\n", argv[2]);
  res = sscanf(argv[3], "%lg", &task_comm_size);
  xbt_assert(res, "Invalid argument %s\n", argv[3]);

  {                             /* Process organisation */
    workers_count = MSG_get_host_number();
    workers = xbt_dynar_to_array(MSG_hosts_as_dynar());
    
    for (i = 0; i < workers_count; i++)
      if(host_self == workers[i]) {
	workers[i] = workers[workers_count-1];
	workers_count--;
	break;
      }

    for (i = 0; i < workers_count; i++)
	MSG_process_create("worker", worker, master_name, workers[i]);
  }

  XBT_INFO("Got %d workers and will send tasks for %g seconds!", 
	   workers_count, timeout);
  xbt_dynar_t idle_hosts = xbt_dynar_new(sizeof(msg_host_t), NULL);
  msg_host_t request_host = NULL;

  for (i = 0; 1;) {
    char sprintf_buffer[64];
    msg_task_t task = NULL;

    msg_task_t request = NULL;
    while(MSG_task_listen(master_name)) {
      res = MSG_task_receive(&(request),master_name);
      xbt_assert(res == MSG_OK, "MSG_task_receive failed");
      request_host = MSG_task_get_data(request);
      xbt_dynar_push(idle_hosts, &request_host);
      MSG_task_destroy(request);
      request = NULL;
    }

    if(MSG_get_clock()>timeout) {
      if(xbt_dynar_length(idle_hosts) == workers_count) break;
      else {
	MSG_process_sleep(.1);
	continue;
      }
    }
    
    if(xbt_dynar_length(idle_hosts)<=0) {
      /* No request. Let's wait... */
      MSG_process_sleep(.1);
      continue;
    }

    sprintf(sprintf_buffer, "Task_%d", i);
    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
			   NULL);
    MSG_task_set_category(task, master_name);

    xbt_dynar_shift(idle_hosts, &request_host);

    build_channel_name(channel,master_name, MSG_host_get_name(request_host));
    
    XBT_DEBUG("Sending \"%s\" to channel \"%s\"", task->name, channel);
    MSG_task_send(task, channel);
    XBT_DEBUG("Sent");
    i++;
  }

  int task_num = i;

  XBT_DEBUG
      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
  for (i = 0; i < workers_count; i++) {
    msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
    MSG_task_send(finalize, build_channel_name(channel,master_name,
		    MSG_host_get_name(workers[i % workers_count])));
  }

  XBT_INFO("Sent %d tasks in total!", task_num);
  free(workers);
  free(todo);
//.........这里部分代码省略.........
开发者ID:dhascome,项目名称:simgrid,代码行数:101,代码来源:masterworker4.c

示例13: MSG_get_host_speed

/** \ingroup m_host_management
 * \brief Return the speed of the processor (in flop/s), regardless of 
    the current load on the machine.
 */
double MSG_get_host_speed(m_host_t h)
{
  xbt_assert((h != NULL), "Invalid parameters");

  return (SIMIX_req_host_get_speed(h->simdata->smx_host));
}
开发者ID:rosacris,项目名称:simgrid,代码行数:10,代码来源:host.c

示例14: xbt_ex_setup_backtrace

void xbt_ex_setup_backtrace(xbt_ex_t * e) //FIXME: This code could be greatly improved/simplifyied with http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html
{
  int i;

  /* to get the backtrace from the libc */
  char **backtrace_syms;

  /* To build the commandline of addr2line */
  char *cmd, *curr;

  /* to extract the addresses from the backtrace */
  char **addrs;
  char buff[256];

  /* To read the output of addr2line */
  FILE *pipe;
  char line_func[1024], line_pos[1024];

  /* size (in char) of pointers on this arch */
  int addr_len = 0;

  /* To search for the right executable path when not trivial */
  struct stat stat_buf;
  char *binary_name = NULL;

  xbt_assert(e, "Backtrace not setup yet, cannot set it up for display");

  e->bt_strings = NULL;

  if (xbt_binary_name == NULL) /* no binary name, nothing to do */
    return;

  if (e->used <= 1)
    return;

  /* ignore first one, which is xbt_backtrace_current() */
  e->used--;
  memmove(e->bt, e->bt + 1, (sizeof *e->bt) * e->used);

  backtrace_syms = backtrace_symbols(e->bt, e->used);

  /* build the commandline */
  if (stat(xbt_binary_name, &stat_buf)) {
    /* Damn. binary not in current dir. We'll have to dig the PATH to find it */
    for (i = 0; environ[i]; i++) {
      if (!strncmp("PATH=", environ[i], 5)) {
        xbt_dynar_t path = xbt_str_split(environ[i] + 5, ":");
        unsigned int cpt;
        char *data;

        xbt_dynar_foreach(path, cpt, data) {
          free(binary_name);
          binary_name = bprintf("%s/%s", data, xbt_binary_name);
          if (!stat(binary_name, &stat_buf)) {
            /* Found. */
            XBT_DEBUG("Looked in the PATH for the binary. Found %s", binary_name);
            break;
          }
        }
        xbt_dynar_free(&path);
        if (stat(binary_name, &stat_buf)) {
          /* not found */
          e->used = 1;
          e->bt_strings = xbt_new(char *, 1);

          e->bt_strings[0] = bprintf("(binary '%s' not found in the PATH)", xbt_binary_name);
          free(backtrace_syms);
          return;
        }
        break;
      }
开发者ID:R7R8,项目名称:simgrid,代码行数:71,代码来源:backtrace_linux.c

示例15: MSG_host_get_properties

/** \ingroup m_host_management
 * \brief Returns a xbt_dynar_t consisting of the list of properties assigned to this host
 *
 * \param host a host
 * \return a dict containing the properties
 */
xbt_dict_t MSG_host_get_properties(m_host_t host)
{
  xbt_assert((host != NULL), "Invalid parameters (host is NULL)");

  return (SIMIX_req_host_get_properties(host->simdata->smx_host));
}
开发者ID:rosacris,项目名称:simgrid,代码行数:12,代码来源:host.c


注:本文中的xbt_assert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。