示例#1
0
int main(int argc, char **argv) {
  int nprocs;
  int rank;
  int num_nets, *net_ids;
  int i;

  //for later random pairing:
  srand(time(NULL));
  
  g_tw_ts_end = s_to_ns(60*60*24*365);
  tw_opt_add(app_opt);
  tw_init(&argc, &argv);

  if (!conf_file_name[0]) {
    fprintf(stderr, "Expected \"codes-config\" option, please see --help.\n");
    MPI_Finalize();
    return 1;
  }

  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
  
  if (configuration_load(conf_file_name, MPI_COMM_WORLD, &config)) {
    fprintf(stderr, "Error loading config file %s.\n", conf_file_name);
    MPI_Finalize();
    return 1;
  }

  model_net_register();
  node_add_lp_type();
  codes_mapping_setup();
  net_ids = model_net_configure(&num_nets);
  assert(num_nets==1);
  net_id = *net_ids;
  free(net_ids);
  if(net_id != TORUS) {
    printf("\n This is written to simulate torus networks.");
    MPI_Finalize();
    return 0;
  }
  num_nodes = codes_mapping_get_lp_count(group_name, 0, "node", NULL, 1);
  configuration_get_value_int(&config, param_group_nm, num_reqs_key, NULL, &num_reqs);
  configuration_get_value_int(&config, param_group_nm, payload_sz_key, NULL, &payload_sz);
  configuration_get_value_int(&config, param_group_nm, num_messages_key, NULL, &num_messages);
  
  tw_run();
  
  model_net_report_stats(net_id);
  
  tw_end();
  free_node_mappings();

  return 0;
}
int main(int argc, char *argv[]) {
	//printf("In main\n");
	g_tw_ts_end = s_to_ns(60 * 60 * 24 * 365); /* one year, in nsecs */

	/* ROSS initialization function calls */
	tw_opt_add(app_opt); /* add user-defined args */
	/* initialize ROSS and parse args. NOTE: tw_init calls MPI_Init */
	tw_init(&argc, &argv);

	if (!conf_file_name[0]) {
		tw_error(TW_LOC,
				"Expected \"codes-config\" option, please see --help.\n");
		return 1;
	}

	/* loading the config file into the codes-mapping utility, giving us the
	 * parsed config object in return.
	 * "config" is a global var defined by codes-mapping */
	if (configuration_load(conf_file_name, MPI_COMM_WORLD, &config)) {
		tw_error(TW_LOC, "Error loading config file %s.\n", conf_file_name);
		return 1;
	}
	lsm_register();
	//lsm_configure();
	/* register model-net LPs with ROSS */
	model_net_register();

	/* register the user LPs */
	node_register();
	forwarder_register();

	/* setup the LPs and codes_mapping structures */
	codes_mapping_setup();

	/* setup the globals */
	int rc = configuration_get_value_int(&config, "server_pings", "num_reqs",
			NULL, &num_reqs);
	if (rc != 0)
		tw_error(TW_LOC, "unable to read server_pings:num_reqs");
	int payload_sz_d;
	rc = configuration_get_value_int(&config, "server_pings", "payload_sz",
			NULL, &payload_sz_d);
	if (rc != 0)
		tw_error(TW_LOC, "unable to read server_pings:payload_sz");
	payload_sz = (uint64_t) payload_sz_d;

	/* get the counts for the client and svr clusters */
	num_client_nodes = codes_mapping_get_lp_count("client_CLUSTER", 0, "node",
			NULL, 1);
	num_svr_nodes = codes_mapping_get_lp_count("svr_CLUSTER", 0, "node", NULL,
			1);
	num_burst_buffer_nodes = codes_mapping_get_lp_count("bb_CLUSTER", 0, "node",
			NULL, 1);
	num_storage_nodes = codes_mapping_get_lp_count("storage_CLUSTER", 0, "node",
			NULL, 1);
	num_client_forwarders = codes_mapping_get_lp_count("client_FORWARDERS", 0,
			"forwarder", NULL, 1);
	num_svr_forwarders = codes_mapping_get_lp_count("svr_FORWARDERS", 0,
			"forwarder", NULL, 1);
	num_burst_buffer_forwarders = codes_mapping_get_lp_count("bb_FORWARDERS", 0,
			"forwarder", NULL, 1);
	num_storage_forwarders = codes_mapping_get_lp_count("storage_FORWARDERS", 0,
			"forwarder", NULL, 1);

	/* Setup the model-net parameters specified in the global config object,
	 * returned are the identifier(s) for the network type.
	 * 1 ID  -> all the same modelnet model
	 * 2 IDs -> clusters are the first id, forwarding network the second
	 * 3 IDs -> client is first, svr and bb second and forwarding network the third
	 * 4 IDs -> cluster client is the first, svr is the second, burst buffer the third and forwarding network the last
	 *          */
	int num_nets;
	int *net_ids = model_net_configure(&num_nets);
	assert(num_nets <= 5);
	if (num_nets == 1) {
		net_id_client = net_ids[0];
		net_id_svr = net_ids[0];
		net_id_bb = net_ids[0];
		net_id_storage = net_ids[0];
		net_id_forwarding = net_ids[0];
	} else if (num_nets == 2) {
		net_id_client = net_ids[0];
		net_id_svr = net_ids[0];
		net_id_bb = net_ids[0];
		net_id_storage = net_ids[0];
		net_id_forwarding = net_ids[1];
	} else if (num_nets == 3) {
		net_id_client = net_ids[0];
		net_id_svr = net_ids[1];
		net_id_bb = net_ids[1];
		net_id_storage = net_ids[1];
		net_id_forwarding = net_ids[2];
	} else if (num_nets == 4) {
		net_id_client = net_ids[0];
		net_id_svr = net_ids[1];
		net_id_bb = net_ids[2];
		net_id_storage = net_ids[2];
		net_id_forwarding = net_ids[3];
	} else {
		net_id_client = net_ids[0];
		net_id_svr = net_ids[1];
		net_id_bb = net_ids[2];
		net_id_storage = net_ids[3];
		net_id_forwarding = net_ids[4];
	}
	free(net_ids);

	configuration_get_value_int(&config, param_group_nm, num_reqs_key, NULL,
			&num_reqs);
	configuration_get_value_int(&config, param_group_nm, payload_sz_key, NULL,
			(int *) &payload_sz);
	configuration_get_value_int(&config, param_group_nm, pvfs_file_sz_key, NULL,
			&pvfs_file_sz); /*Sughosh: added for pvfsfs*/
	configuration_get_value_int(&config, param_group_nm, bb_file_size_key, NULL,
			&bb_file_sz); /*Tony: added for bb*/
	configuration_get_value_int(&config, param_group_nm, bb_capacity_key, NULL,
			&burst_buffer_max_capacity); /*Tony: added for bb*/

	/* begin simulation */
	model_net_report_stats(net_id);
	tw_run();

	tw_end();

	return 0;
}
示例#3
0
static void torus_read_config(
    const char         * anno,
    torus_param        * params) {
    char dim_length_str[MAX_NAME_LENGTH];
    int i;

    // shorthand
    torus_param *p = params;

    configuration_get_value_int(&config, "PARAMS", "n_dims", anno, &p->n_dims);
    if(!p->n_dims) {
        p->n_dims = 4; /* a 4-D torus */
        fprintf(stderr,
                "Warning: Number of dimensions not specified, setting to %d\n",
                p->n_dims);
    }

    configuration_get_value_double(&config, "PARAMS", "link_bandwidth", anno,
                                   &p->link_bandwidth);
    if(!p->link_bandwidth) {
        p->link_bandwidth = 2.0; /*default bg/q configuration */
        fprintf(stderr, "Link bandwidth not specified, setting to %lf\n",
                p->link_bandwidth);
    }

    configuration_get_value_int(&config, "PARAMS", "buffer_size", anno, &p->buffer_size);
    if(!p->buffer_size) {
        p->buffer_size = 2048;
        fprintf(stderr, "Buffer size not specified, setting to %d",
                p->buffer_size);
    }


    configuration_get_value_int(&config, "PARAMS", "chunk_size", anno, &p->chunk_size);
    if(!p->chunk_size) {
        p->chunk_size = 32;
        fprintf(stderr, "Warning: Chunk size not specified, setting to %d\n",
                p->chunk_size);
    }
    configuration_get_value_int(&config, "PARAMS", "num_vc", anno, &p->num_vc);
    if(!p->num_vc) {
        /* by default, we have one for taking packets,
         * another for taking credit*/
        p->num_vc = 1;
        fprintf(stderr, "Warning: num_vc not specified, setting to %d\n",
                p->num_vc);
    }

    int rc = configuration_get_value(&config, "PARAMS", "dim_length", anno,
                                     dim_length_str, MAX_NAME_LENGTH);
    if (rc == 0) {
        tw_error(TW_LOC, "couldn't read PARAMS:dim_length");
    }
    char* token;
    p->dim_length=malloc(p->n_dims*sizeof(*p->dim_length));
    token = strtok(dim_length_str, ",");
    i = 0;
    while(token != NULL)
    {
        sscanf(token, "%d", &p->dim_length[i]);
        if(p->dim_length[i] <= 0)
        {
            tw_error(TW_LOC, "Invalid torus dimension specified "
                     "(%d at pos %d), exiting... ", p->dim_length[i], i);
        }
        i++;
        token = strtok(NULL,",");
    }
    /*int num_nodes = 1;

    for( i = 0; i < p->n_dims; i++)
       num_nodes *= p->dim_length[i];

    configuration_get_value_int(&config, "PARAMS", "num_net_traces", anno, &p->num_net_traces);
    if(!p->num_net_traces) {

    p->num_net_traces = num_nodes;
        fprintf(stderr, "Number of network traces not specified, setting to %d",
                p->num_net_traces);
    }
    // Number of network traces should be <= number of torus network nodes `
    assert(p->num_net_traces <= num_nodes);*/
    // create derived parameters

    // factor is an exclusive prefix product
    p->factor = malloc(p->n_dims * sizeof(int));
    p->factor[0] = 1;
    for(i = 1; i < p->n_dims; i++)
        p->factor[i] = p->factor[i-1] * p->dim_length[i-1];

    p->half_length = malloc(p->n_dims * sizeof(int));
    for (i = 0; i < p->n_dims; i++)
        p->half_length[i] = p->dim_length[i] / 2;

    // some latency numbers
    p->head_delay = (1.0 / p->link_bandwidth) * p->chunk_size;
    p->credit_delay = (1.0 / p->link_bandwidth) * p->chunk_size;
}
示例#4
0
// read the configuration file for a given annotation
static void read_config(ConfigHandle *ch, char const * anno, disk_model_t *model)
{
    char       **values;
    size_t       length;
    int          rc;
    // request sizes
    rc = configuration_get_multivalue(ch, LSM_NAME, "request_sizes", anno,
            &values,&length);
    assert(rc == 1);
    model->request_sizes = (unsigned int*)malloc(sizeof(int)*length);
    assert(model->request_sizes);
    model->bins = length;
    for (size_t i = 0; i < length; i++)
    {
        model->request_sizes[i] = atoi(values[i]);
    }
    free(values);

    // write rates
    rc = configuration_get_multivalue(ch, LSM_NAME, "write_rates", anno,
            &values,&length);
    assert(rc == 1);
    model->write_rates = (double*)malloc(sizeof(double)*length);
    assert(model->write_rates);
    assert(length == model->bins);
    for (size_t i = 0; i < length; i++)
    {
        model->write_rates[i] = strtod(values[i], NULL);
    }
    free(values);

    // read rates
    rc = configuration_get_multivalue(ch, LSM_NAME, "read_rates", anno,
            &values,&length);
    assert(rc == 1);
    model->read_rates = (double*)malloc(sizeof(double)*length);
    assert(model->read_rates);
    assert(model->bins == length);
    for (size_t i = 0; i < length; i++)
    {
        model->read_rates[i] = strtod(values[i], NULL);
    }
    free(values);

    // write overheads
    rc = configuration_get_multivalue(ch, LSM_NAME, "write_overheads", anno,
            &values,&length);
    assert(rc == 1);
    model->write_overheads = (double*)malloc(sizeof(double)*length);
    assert(model->write_overheads);
    assert(model->bins == length);
    for (size_t i = 0; i < length; i++)
    {
        model->write_overheads[i] = strtod(values[i], NULL);
    }
    free(values);

    // read overheades
    rc = configuration_get_multivalue(ch, LSM_NAME, "read_overheads", anno,
            &values,&length);
    assert(rc == 1);
    model->read_overheads = (double*)malloc(sizeof(double)*length);
    assert(model->read_overheads);
    assert(model->bins == length);
    for (size_t i = 0; i < length; i++)
    {
        model->read_overheads[i] = strtod(values[i], NULL);
    }
    free(values);

    // write seek latency
    rc = configuration_get_multivalue(ch, LSM_NAME, "write_seeks", anno,
            &values,&length);
    assert(rc == 1);
    model->write_seeks = (double*)malloc(sizeof(double)*length);
    assert(model->write_seeks);
    assert(model->bins == length);
    for (size_t i = 0; i < length; i++)
    {
        model->write_seeks[i] = strtod(values[i], NULL);
    }
    free(values);

    // read seek latency
    rc = configuration_get_multivalue(ch, LSM_NAME, "read_seeks", anno,
            &values,&length);
    assert(rc == 1);
    model->read_seeks = (double*)malloc(sizeof(double)*length);
    assert(model->read_seeks);
    assert(model->bins == length);
    for (size_t i = 0; i < length; i++)
    {
        model->read_seeks[i] = strtod(values[i], NULL);
    }
    free(values);

    // scheduling parameters (this can fail)
    configuration_get_value_int(ch, LSM_NAME, "enable_scheduler", anno,
            &model->use_sched);
    assert(model->use_sched >= 0);
}
int main(
    int argc,
    char **argv)
{
    int nprocs;
    int rank;
    int num_nets;
    int *net_ids;
    char* anno;

    lp_io_handle handle;

    tw_opt_add(app_opt);
    tw_init(&argc, &argv);
    offset = 1;

    if(argc < 2)
    {
            printf("\n Usage: mpirun <args> --sync=2/3 mapping_file_name.conf (optional --nkp) ");
            MPI_Finalize();
            return 0;
    }

    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

    configuration_load(argv[2], MPI_COMM_WORLD, &config);

    model_net_register();
    svr_add_lp_type();

    codes_mapping_setup();

    net_ids = model_net_configure(&num_nets);
    assert(num_nets==1);
    net_id = *net_ids;
    free(net_ids);

    if(net_id != DRAGONFLY)
    {
	printf("\n The test works with dragonfly model configuration only! ");
        MPI_Finalize();
        return 0;
    }
    num_servers_per_rep = codes_mapping_get_lp_count("MODELNET_GRP", 1, "server",
            NULL, 1);
    configuration_get_value_int(&config, "PARAMS", "num_routers", anno, &num_routers_per_grp);
    
    num_groups = (num_routers_per_grp * (num_routers_per_grp/2) + 1);
    num_nodes = num_groups * num_routers_per_grp * (num_routers_per_grp / 2);
    num_nodes_per_grp = num_routers_per_grp * (num_routers_per_grp / 2);

    if(lp_io_prepare("modelnet-test", LP_IO_UNIQ_SUFFIX, &handle, MPI_COMM_WORLD) < 0)
    {
        return(-1);
    }

    tw_run();
    model_net_report_stats(net_id);

    if(lp_io_flush(handle, MPI_COMM_WORLD) < 0)
    {
        return(-1);
    }

    tw_end();
    return 0;
}