Beispiel #1
0
static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
{
  XBT_DEBUG("NS3_ADD_LINK '%s'",link->id);

  if(!IPV4addr) IPV4addr = xbt_dynar_new(sizeof(char*),free);

  tmgr_trace_t bw_trace;
  tmgr_trace_t state_trace;
  tmgr_trace_t lat_trace;

  bw_trace = link->bandwidth_trace;
  lat_trace = link->latency_trace;
  state_trace = link->state_trace;

  if (bw_trace)
    XBT_INFO("The NS3 network model doesn't support bandwidth state traces");
  if (lat_trace)
    XBT_INFO("The NS3 network model doesn't support latency state traces");
  if (state_trace)
    XBT_INFO("The NS3 network model doesn't support link state traces");

  ns3_link_t link_ns3 = xbt_new0(s_ns3_link_t,1);;
  link_ns3->id = xbt_strdup((char*)(link->id));
  link_ns3->bdw = bprintf("%f",link->bandwidth);
  link_ns3->lat = bprintf("%f",link->latency);

  surf_ns3_link_t l = xbt_new0(s_surf_ns3_link_t,1);
  l->generic_resource.name = xbt_strdup(link->id);
  l->generic_resource.properties = current_property_set;
  l->data = link_ns3;
  l->created = 1;

  xbt_lib_set(link_lib,link->id,NS3_LINK_LEVEL,link_ns3);
  xbt_lib_set(link_lib,link->id,SURF_LINK_LEVEL,l);
}
Beispiel #2
0
/**
 * \brief Add a "host" to the network element list
 */
static void parse_S_host(sg_platf_host_cbarg_t host)
{
  sg_routing_edge_t info = NULL;
  if (current_routing->hierarchy == SURF_ROUTING_NULL)
    current_routing->hierarchy = SURF_ROUTING_BASE;
  xbt_assert(!xbt_lib_get_or_null(host_lib, host->id, ROUTING_HOST_LEVEL),
             "Reading a host, processing unit \"%s\" already exists", host->id);

  info = xbt_new0(s_routing_edge_t, 1);
  info->rc_component = current_routing;
  info->rc_type = SURF_NETWORK_ELEMENT_HOST;
  info->name = xbt_strdup(host->id);
  info->id = current_routing->parse_PU(current_routing, (void *) info);
  xbt_lib_set(host_lib, host->id, ROUTING_HOST_LEVEL, (void *) info);
  XBT_DEBUG("Having set name '%s' id '%d'",host->id,info->id);

  if(mount_list){
    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
    mount_list = NULL;
  }

  if (host->coord && strcmp(host->coord, "")) {
    unsigned int cursor;
    char*str;

    if (!COORD_HOST_LEVEL)
      xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line");
    /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/
    xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " ");
    xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL);
    xbt_dynar_foreach(ctn_str,cursor, str) {
      double val = atof(str);
      xbt_dynar_push(ctn,&val);
    }
Beispiel #3
0
static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster)
{
  const char *cluster_prefix = cluster->prefix;
  const char *cluster_suffix = cluster->suffix;
  const char *cluster_radical = cluster->radical;
  const char *cluster_bb_bw = bprintf("%f",cluster->bb_bw);
  const char *cluster_bb_lat = bprintf("%f",cluster->bb_lat);
  const char *cluster_bw = bprintf("%f",cluster->bw);
  const char *cluster_lat = bprintf("%f",cluster->lat);
  const char *groups = NULL;

  int start, end, i;
  unsigned int iter;

  xbt_dynar_t radical_elements;
  xbt_dynar_t radical_ends;
  xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);

  char *router_id,*host_id;

  radical_elements = xbt_str_split(cluster_radical, ",");
  xbt_dynar_foreach(radical_elements, iter, groups) {
    radical_ends = xbt_str_split(groups, "-");

    switch (xbt_dynar_length(radical_ends)) {
    case 1:
      start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
      xbt_dynar_push_as(tab_elements_num, int, start);
      router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix);
      xbt_lib_set(host_lib,
                  router_id,
                  NS3_HOST_LEVEL,
                  ns3_add_host_cluster(router_id)
        );
      XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
      free(router_id);
      break;

    case 2:
      start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
      end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
      for (i = start; i <= end; i++){
        xbt_dynar_push_as(tab_elements_num, int, i);
        router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix);
        xbt_lib_set(host_lib,
                    router_id,
                    NS3_HOST_LEVEL,
                    ns3_add_host_cluster(router_id)
          );
        XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
        free(router_id);
      }
      break;

    default:
      XBT_DEBUG("Malformed radical");
    }
  }
Beispiel #4
0
/********************************* Host **************************************/
msg_host_t __MSG_host_create(smx_host_t workstation)
{
  const char *name = SIMIX_host_get_name(workstation);
  msg_host_priv_t host = xbt_new0(s_msg_host_priv_t, 1);
  s_msg_vm_t vm; // simply to compute the offset

  host->vms = xbt_swag_new(xbt_swag_offset(vm,host_vms_hookup));

#ifdef MSG_USE_DEPRECATED
  int i;
  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  if (msg_global->max_channel > 0)
    host->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    host->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }
#endif

  xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
  
  return xbt_lib_get_elm_or_null(host_lib, name);
}
Beispiel #5
0
Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
    const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach)
{

  xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
      "Storage '%s' declared several times in the platform file", id);

  storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);

  double Bread  = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bread"),
      "property Bread, storage",type_id);
  double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bwrite"),
      "property Bwrite, storage",type_id);
  double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"),
      "property Bconnection, storage",type_id);

  Storage *storage = new StorageN11(this, id, properties, maxminSystem_,
      Bread, Bwrite, Bconnection, type_id, (char *)content_name,
      content_type, storage_type->size, (char *) attach);
  storageCreatedCallbacks(storage);
  xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);

  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tproperties '%p'\n\t\tBread '%f'\n",
      id, type_id, properties, Bread);

  p_storageList.push_back(storage);

  return storage;
}
Beispiel #6
0
/********************************* Host **************************************/
m_host_t __MSG_host_create(smx_host_t workstation, void *data)
{
  const char *name;
  simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
  m_host_t host = xbt_new0(s_m_host_t, 1);
  int i;

  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  name = SIMIX_host_get_name(workstation);
  /* Host structure */
  host->name = xbt_strdup(name);
  host->simdata = simdata;
  host->data = data;

  simdata->smx_host = workstation;

  if (msg_global->max_channel > 0)
    simdata->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    simdata->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }

  SIMIX_req_host_set_data(workstation, host);
  xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);

  return host;
}
Beispiel #7
0
/** @brief Add an "host" to the current AS */
void sg_platf_new_host(sg_platf_host_cbarg_t host)
{
  xbt_assert(! sg_host_by_name(host->id),
      "Refusing to create a second host named '%s'.", host->id);

  simgrid::surf::AsImpl* current_routing = routing_get_current();
  if (current_routing->hierarchy_ == simgrid::surf::AsImpl::RoutingMode::unset)
    current_routing->hierarchy_ = simgrid::surf::AsImpl::RoutingMode::base;

  simgrid::surf::NetCard *netcard =
      new simgrid::surf::NetCardImpl(host->id, SURF_NETWORK_ELEMENT_HOST, current_routing);

  netcard->setId(current_routing->addComponent(netcard));
  sg_host_t h = simgrid::s4u::Host::by_name_or_create(host->id);
  h->pimpl_netcard = netcard;
  simgrid::surf::netcardCreatedCallbacks(netcard);

  if(mount_list){
    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
    mount_list = NULL;
  }

  if (host->coord && strcmp(host->coord, "")) {
    unsigned int cursor;
    char*str;

    if (!COORD_HOST_LEVEL)
      xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line");
    /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/
    xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " ");
    xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL);
    xbt_dynar_foreach(ctn_str,cursor, str) {
      double val = xbt_str_parse_double(str, "Invalid coordinate: %s");
      xbt_dynar_push(ctn,&val);
    }
Beispiel #8
0
/********************************* Host **************************************/
msg_host_t __MSG_host_create(smx_host_t workstation)
{
  const char *name = SIMIX_host_get_name(workstation);
  msg_host_priv_t priv = xbt_new0(s_msg_host_priv_t, 1);

#ifdef MSG_USE_DEPRECATED
  int i;
  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  priv->mailboxes = (msg_global->max_channel > 0) ?
    xbt_new0(msg_mailbox_t, msg_global->max_channel) : NULL;

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    priv->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }
#endif


  priv->dp_objs = xbt_dict_new();
  priv->dp_enabled = 0;
  priv->dp_updated_by_deleted_tasks = 0;
  priv->is_migrating = 0;

  priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);

  xbt_lib_set(host_lib, name, MSG_HOST_LEVEL, priv);
  
  return xbt_lib_get_elm_or_null(host_lib, name);
}
Beispiel #9
0
static void parse_ns3_add_AS(sg_platf_AS_cbarg_t AS)
{
  XBT_DEBUG("NS3_ADD_AS '%s'",AS->id);
  xbt_lib_set(as_router_lib,
              AS->id,
              NS3_ASR_LEVEL,
              ns3_add_AS(AS->id)
    );
}
Beispiel #10
0
static void parse_ns3_add_router(sg_platf_router_cbarg_t router)
{
  XBT_DEBUG("NS3_ADD_ROUTER '%s'",router->id);
  xbt_lib_set(as_router_lib,
              router->id,
              NS3_ASR_LEVEL,
              ns3_add_router(router->id)
    );
}
Beispiel #11
0
HostPtr HostCLM03Model::createHost(const char *name){
  HostPtr host = new HostCLM03(surf_host_model, name, NULL,
		  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
		  (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL),
		  static_cast<CpuPtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)));
  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
  xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
  return host;
}
Beispiel #12
0
static void parse_ns3_add_host(sg_platf_host_cbarg_t host)
{
  XBT_DEBUG("NS3_ADD_HOST '%s'",host->id);
  xbt_lib_set(host_lib,
              host->id,
              NS3_HOST_LEVEL,
              ns3_add_host(host->id)
    );
}
Beispiel #13
0
Host *HostCLM03Model::createHost(const char *name){
  sg_host_t sg_host = sg_host_by_name(name);
  Host *host = new HostCLM03(surf_host_model, name, NULL,
		  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
		  sg_host_edge(sg_host),
		  sg_host_surfcpu(sg_host));
  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
  xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
  return host;
}
Beispiel #14
0
VMPtr VMHL13Model::createVM(const char *name, surf_resource_t host_PM)
{
  VMHL13Ptr ws = new VMHL13(this, name, NULL, host_PM);

  xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, ws);

  /* TODO:
   * - check how network requests are scheduled between distinct processes competing for the same card.
   */
  return ws;
}
Beispiel #15
0
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
                                         jstring jname) {
  msg_host_t host;                /* native host                                          */
  jobject jhost;                /* global reference to the java host instance returned  */

  /* get the C string from the java string */
  if (jname == NULL) {
  	jxbt_throw_null(env,bprintf("No host can have a null name"));
  	return NULL;
  }
  const char *name = (*env)->GetStringUTFChars(env, jname, 0);
  /* get the host by name       (the hosts are created during the grid resolution) */
  host = MSG_get_host_by_name(name);

  if (!host) {                  /* invalid name */
    jxbt_throw_host_not_found(env, name);
    (*env)->ReleaseStringUTFChars(env, jname, name);
    return NULL;
  }
  (*env)->ReleaseStringUTFChars(env, jname, name);

  if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {       /* native host not associated yet with java host */

    /* Instantiate a new java host */
    jhost = jhost_new_instance(env);

    if (!jhost) {
      jxbt_throw_jni(env, "java host instantiation failed");
      return NULL;
    }

    /* get a global reference to the newly created host */
    jhost = jhost_ref(env, jhost);

    if (!jhost) {
      jxbt_throw_jni(env, "new global ref allocation failed");
      return NULL;
    }
    /* Sets the java host name */
    (*env)->SetObjectField(env, jhost, jhost_field_Host_name, jname);
    /* bind the java host and the native host */
    jhost_bind(jhost, host, env);

    /* the native host data field is set with the global reference to the
     * java host returned by this function
     */
    xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
  }

  /* return the global reference to the java host instance */
  return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
}
Beispiel #16
0
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, jclass cls,
                                         jstring jname) {
  msg_storage_t storage;
  jobject jstorage;

  /* get the C string from the java string */
  if (jname == NULL) {
  	jxbt_throw_null(env,bprintf("No host can have a null name"));
  	return NULL;
  }
  const char *name = (*env)->GetStringUTFChars(env, jname, 0);
  storage = MSG_storage_get_by_name(name);

  if (!storage) {                  /* invalid name */
    jxbt_throw_storage_not_found(env, name);
    (*env)->ReleaseStringUTFChars(env, jname, name);
    return NULL;
  }
  (*env)->ReleaseStringUTFChars(env, jname, name);

  if (!xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL)) {       /* native host not associated yet with java host */

    /* Instantiate a new java storage */
    jstorage = jstorage_new_instance(env);

    if (!jstorage) {
      jxbt_throw_jni(env, "java storage instantiation failed");
      return NULL;
    }

    /* get a global reference to the newly created storage */
    jstorage = jstorage_ref(env, jstorage);

    if (!jstorage) {
      jxbt_throw_jni(env, "new global ref allocation failed");
      return NULL;
    }
    /* Sets the java storage name */
    (*env)->SetObjectField(env, jstorage, jstorage_field_Storage_name, jname);
    /* bind the java storage and the native storage */
    jstorage_bind(jstorage, storage, env);

    /* the native storage data field is set with the global reference to the
     * java storage returned by this function
     */
    xbt_lib_set(storage_lib, storage->key, JAVA_STORAGE_LEVEL, (void *) jstorage);
  }

  /* return the global reference to the java storage instance */
  return (jobject) xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL);
}
Beispiel #17
0
static void ns3_add_netcard(simgrid::routing::NetCard* netcard)
{
  const char* id = netcard->name();

  ns3_node_t ns3netcard  = xbt_new0(s_ns3_node_t,1);
  XBT_DEBUG("Interface ns3 add netcard[%d] '%s'",number_of_nodes,id);
  ns3::Ptr<ns3::Node> node =  ns3::CreateObject<ns3::Node> (0);
  stack.Install(node);
  nodes.Add(node);
  ns3netcard->node_num = number_of_nodes++;

  xbt_lib_set(as_router_lib, id, NS3_ASR_LEVEL, ns3netcard );
}
Beispiel #18
0
/* Creates a storage and registers it in SD.
 */
SD_storage_t __SD_storage_create(void *surf_storage, void *data)
{

  SD_storage_priv_t storage;
  const char *name;

  storage = xbt_new(s_SD_storage_priv_t, 1);
  storage->data = data;     /* user data */
  name = surf_resource_name(surf_storage);
  storage->host = surf_storage_get_host(surf_storage_resource_by_name(name));
  xbt_lib_set(storage_lib,name, SD_STORAGE_LEVEL, storage);
  return xbt_lib_get_elm_or_null(storage_lib, name);
}
Beispiel #19
0
/** \ingroup msg_file_management
 * \brief Opens the file whose name is the string pointed to by path
 *
 * \param fullpath is the file location on the storage
 * \param data user data to attach to the file
 *
 * \return An #msg_file_t associated to the file
 */
msg_file_t MSG_file_open(const char* fullpath, void* data)
{
  char *name;
  msg_file_priv_t priv = xbt_new(s_msg_file_priv_t, 1);
  priv->data = data;
  priv->fullpath = xbt_strdup(fullpath);
  priv->simdata = xbt_new0(s_simdata_file_t,1);
  priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
  name = bprintf("%s:%i:%s",MSG_host_get_name(MSG_host_self()),MSG_process_self_PID(),fullpath);
  xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
  msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, name);
  __MSG_file_get_info(fd);
  xbt_free(name);
  return fd;
}
Beispiel #20
0
/* Creates a workstation and registers it in SD.
 */
SD_workstation_t __SD_workstation_create(void *surf_workstation,
                                         void *data)
{

  SD_workstation_priv_t workstation;
  const char *name;

  workstation = xbt_new(s_SD_workstation_priv_t, 1);
  workstation->data = data;     /* user data */
  workstation->access_mode = SD_WORKSTATION_SHARED_ACCESS;      /* default mode is shared */
  workstation->task_fifo = NULL;
  workstation->current_task = NULL;

  name = surf_resource_name(surf_workstation);
  xbt_lib_set(host_lib,name,SD_HOST_LEVEL,workstation);
  return xbt_lib_get_elm_or_null(host_lib,name);
}
Beispiel #21
0
VMHL13::VMHL13(VMModelPtr model, const char* name, xbt_dict_t props,
		                                   surf_resource_t host_PM)
 : VM(model, name, props, NULL, NULL)
{
  HostPtr sub_ws = static_cast<HostPtr>(surf_host_resource_priv(host_PM));

  /* Currently, we assume a VM has no storage. */
  p_storage = NULL;

  /* Currently, a VM uses the network resource of its physical host. In
   * host_lib, this network resource object is referred from two different keys.
   * When deregistering the reference that points the network resource object
   * from the VM name, we have to make sure that the system does not call the
   * free callback for the network resource object. The network resource object
   * is still used by the physical machine. */
  p_netElm = new RoutingEdgeWrapper(static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->getName(), ROUTING_HOST_LEVEL)));
  xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, p_netElm);

  p_subWs = sub_ws;
  p_currentState = SURF_VM_STATE_CREATED;

  // //// CPU  RELATED STUFF ////
  // Roughly, create a vcpu resource by using the values of the sub_cpu one.
  CpuCas01Ptr sub_cpu = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(host_PM));

  /* We can assume one core and cas01 cpu for the first step.
   * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */

  p_cpu = surf_cpu_model_vm->createCpu(name, // name
      sub_cpu->getPowerPeakList(),        // host->power_peak,
      sub_cpu->getPState(),
      1,                          // host->power_scale,
      NULL,                       // host->power_trace,
      1,                          // host->core_amount,
      SURF_RESOURCE_ON,           // host->initial_state,
      NULL,                       // host->state_trace,
      NULL);                       // host->properties,

  /* We create cpu_action corresponding to a VM process on the host operating system. */
  /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
  // vm_ws->cpu_action = surf_cpu_model_pm->extension.cpu.execute(host_PM, GUESTOS_NOISE);
  p_action = sub_cpu->execute(0);

  XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, sub_ws->getName(), xbt_dynar_length(p_storage));
}
Beispiel #22
0
/* Creates a link and registers it in SD.
 */
SD_link_t __SD_link_create(void *surf_link, void *data)
{

  SD_link_t link;
  const char *name;

  link = xbt_new(s_SD_link_t, 1);
  link->surf_link = surf_link;
  link->data = data;            /* user data */
  if (surf_workstation_model->extension.workstation.link_shared(surf_link))
    link->sharing_policy = SD_LINK_SHARED;
  else
    link->sharing_policy = SD_LINK_FATPIPE;

  name = SD_link_get_name(link);
  xbt_lib_set(link_lib,name,SD_LINK_LEVEL,link);

  return link;
}
Beispiel #23
0
CpuPtr CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak,
		                  int pstate, double power_scale,
                          tmgr_trace_t power_trace, int core,
                          e_surf_resource_state_t state_initial,
                          tmgr_trace_t state_trace,
                          xbt_dict_t cpu_properties)
{
  CpuPtr cpu = NULL;
  xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
             "Host '%s' declared several times in the platform file",
             name);
  xbt_assert(xbt_dynar_getfirst_as(power_peak, double) > 0.0,
      "Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
  xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);

  cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);

  return cpu;
}
Beispiel #24
0
static void *cpu_create_resource(const char *name, double power_peak,
                                 double power_scale,
                                 tmgr_trace_t power_trace,
                                 int core,
                                 e_surf_resource_state_t state_initial,
                                 tmgr_trace_t state_trace,
                                 xbt_dict_t cpu_properties)
{
  cpu_Cas01_t cpu = NULL;

  xbt_assert(!surf_cpu_resource_by_name(name),
             "Host '%s' declared several times in the platform file",
             name);
  cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
                                        surf_cpu_model, name,
                                        cpu_properties);
  cpu->power_peak = power_peak;
  xbt_assert(cpu->power_peak > 0, "Power has to be >0");
  cpu->power_scale = power_scale;
  cpu->core = core;
  xbt_assert(core > 0, "Invalid number of cores %d", core);

  if (power_trace)
    cpu->power_event =
        tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);

  cpu->state_current = state_initial;
  if (state_trace)
    cpu->state_event =
        tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);

  cpu->constraint =
      lmm_constraint_new(surf_cpu_model->model_private->maxmin_system, cpu,
                         cpu->core * cpu->power_scale * cpu->power_peak);

  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);

  return cpu;
}
Beispiel #25
0
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jclass cls) {
  jobject jhost;

  msg_host_t host = MSG_host_self();

  if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
    /* the native host not yet associated with the java host instance */

    /* instanciate a new java host instance */
    jhost = jhost_new_instance(env);

    if (!jhost) {
      jxbt_throw_jni(env, "java host instantiation failed");
      return NULL;
    }

    /* get a global reference to the newly created host */
    jhost = jhost_ref(env, jhost);

    if (!jhost) {
      jxbt_throw_jni(env, "global ref allocation failed");
      return NULL;
    }
    /* Sets the host name */
    const char *name = MSG_host_get_name(host);
    jobject jname = (*env)->NewStringUTF(env,name);
    (*env)->SetObjectField(env, jhost, jhost_field_Host_name, jname);
    /* Bind & store it */
    jhost_bind(jhost, host, env);
    xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
  } else {
    jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
  }

  return jhost;
}
Beispiel #26
0
NetworkLinkPtr NetworkCm02Model::createNetworkLink(const char *name,
                                 double bw_initial,
                                 tmgr_trace_t bw_trace,
                                 double lat_initial,
                                 tmgr_trace_t lat_trace,
                                 e_surf_resource_state_t state_initial,
                                 tmgr_trace_t state_trace,
                                 e_surf_link_sharing_policy_t policy,
                                 xbt_dict_t properties)
{
  xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
             "Link '%s' declared several times in the platform file.",
             name);

  NetworkCm02LinkPtr nw_link =
		  new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, history,
				                 state_initial, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);


  xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
  XBT_DEBUG("Create link '%s'",name);

  return nw_link;
}
Beispiel #27
0
/*
 * Update the physical host of the given VM
 */
void VMHL13::migrate(surf_resource_t ind_dst_pm)
{
   /* ind_dst_pm equals to smx_host_t */
   HostPtr ws_dst = static_cast<HostPtr>(surf_host_resource_priv(ind_dst_pm));
   const char *vm_name = getName();
   const char *pm_name_src = p_subWs->getName();
   const char *pm_name_dst = ws_dst->getName();

   xbt_assert(ws_dst);

   /* do something */

   /* update net_elm with that of the destination physical host */
   RoutingEdgePtr old_net_elm = p_netElm;
   RoutingEdgePtr new_net_elm = new RoutingEdgeWrapper(static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, pm_name_dst, ROUTING_HOST_LEVEL)));
   xbt_assert(new_net_elm);

   /* Unregister the current net_elm from host_lib. Do not call the free callback. */
   xbt_lib_unset(host_lib, vm_name, ROUTING_HOST_LEVEL, 0);

   /* Then, resister the new one. */
   p_netElm = new_net_elm;
   xbt_lib_set(host_lib, vm_name, ROUTING_HOST_LEVEL, p_netElm);

   p_subWs = ws_dst;

   /* Update vcpu's action for the new pm */
   {
#if 0
     XBT_INFO("cpu_action->remains %g", p_action->remains);
     XBT_INFO("cost %f remains %f start %f finish %f", p_action->cost,
         p_action->remains,
         p_action->start,
         p_action->finish
         );
     XBT_INFO("cpu_action state %d", surf_action_get_state(p_action));
#endif

     /* create a cpu action bound to the pm model at the destination. */
     CpuActionPtr new_cpu_action = static_cast<CpuActionPtr>(
    		                            static_cast<CpuPtr>(surf_cpu_resource_priv(ind_dst_pm))->execute(0));

     e_surf_action_state_t state = p_action->getState();
     if (state != SURF_ACTION_DONE)
       XBT_CRITICAL("FIXME: may need a proper handling, %d", state);
     if (p_action->getRemainsNoUpdate() > 0)
       XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemainsNoUpdate());

     /* keep the bound value of the cpu action of the VM. */
     double old_bound = p_action->getBound();
     if (old_bound != 0) {
       XBT_DEBUG("migrate VM(%s): set bound (%f) at %s", vm_name, old_bound, pm_name_dst);
       new_cpu_action->setBound(old_bound);
     }

     _XBT_GNUC_UNUSED int ret = p_action->unref();
     xbt_assert(ret == 1, "Bug: some resource still remains");

     p_action = new_cpu_action;
   }

   XBT_DEBUG("migrate VM(%s): change net_elm (%p to %p)", vm_name, old_net_elm, new_net_elm);
   XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
   delete old_net_elm;
}