int main(int argc, char **argv)
{
- sg_host_t w1, w2;
- const sg_host_t *workstations;
int i, j;
- int list_size;
xbt_os_timer_t timer = xbt_os_timer_new();
- /* SD initialization */
SD_init(&argc, argv);
-
- /* creation of the environment */
SD_create_environment(argv[1]);
- workstations = sg_host_list();
- list_size = sg_host_count();
+ sg_host_t *workstations = sg_host_list();
+ int list_size = sg_host_count();
/* Random number initialization */
srand( (int) (xbt_os_time()*1000) );
- do{
+ do {
i = rand()%list_size;
j = rand()%list_size;
- }while(i==j);
+ } while(i==j);
- w1 = workstations[i];
- w2 = workstations[j];
+ sg_host_t w1 = workstations[i];
+ sg_host_t w2 = workstations[j];
printf("%d\tand\t%d\t\t",i,j);
xbt_os_cputimer_start(timer);
printf("%f\n", xbt_os_timer_elapsed(timer) );
+ xbt_free(workstations);
SD_exit();
return 0;
int main(int argc, char **argv)
{
xbt_os_timer_t timer = xbt_os_timer_new();
-
- /* initialization of SD */
SD_init(&argc, argv);
/* creation of the environment, timed */
/* Display the result and exit after cleanup */
printf( "%f\n", xbt_os_timer_elapsed(timer) );
- printf("Workstation number: %zu, link number: %d\n",
- sg_host_count(), sg_link_count());
+ printf("Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count());
if(argv[2]){
printf("Wait for %ss\n",argv[2]);
sleep(atoi(argv[2]));
"SimDag test basic_link_test");
static int cmp_link(const void*a, const void*b) {
- const char *nameA = sg_link_name(*(SD_link_t*)a);
- const char *nameB = sg_link_name(*(SD_link_t*)b);
- return strcmp( nameA, nameB );
+ return strcmp(sg_link_name(*(SD_link_t*)a) , sg_link_name(*(SD_link_t*)b));
}
int main(int argc, char **argv)
{
- int i;
const char *user_data = "some user_data";
- const SD_link_t *links;
/* initialization of SD */
SD_init(&argc, argv);
/* creation of the environment */
SD_create_environment(argv[1]);
- links = sg_link_list();
+ const SD_link_t *links = sg_link_list();
int count = sg_link_count();
XBT_INFO("Link count: %d", count);
qsort((void *)links, count, sizeof(SD_link_t), cmp_link);
- for(i=0; i < count; i++){
- XBT_INFO("%s: latency = %.5f, bandwidth = %f",
- sg_link_name(links[i]),
- sg_link_latency(links[i]),
- sg_link_bandwidth(links[i]));
+ for (int i=0; i < count; i++){
+ XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]), sg_link_latency(links[i]), sg_link_bandwidth(links[i]));
sg_link_data_set(links[i], (void*) user_data);
- if(strcmp(user_data, (const char*)sg_link_data(links[i]))){
- XBT_ERROR("User data was corrupted.");
- }
+ xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted.");
}
SD_exit();
int main(int argc, char **argv)
{
- /* SD initialization */
-
- sg_host_t w1, w2;
- sg_host_t *workstations;
- SD_link_t *route;
- const char *name1;
- const char *name2;
- int route_size, i, j, k;
- int list_size;
-
SD_init(&argc, argv);
/* creation of the environment */
SD_create_environment(argv[1]);
- printf("Workstation number: %zu, link number: %d\n",
- sg_host_count(), sg_link_count());
+ printf("Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count());
- workstations = sg_host_list();
+ sg_host_t *workstations = sg_host_list();
if (argc >= 3) {
if (!strcmp(argv[2], "ONE_LINK")) {
- w1 = workstations[0];
- w2 = workstations[1];
- name1 = sg_host_get_name(w1);
- name2 = sg_host_get_name(w2);
+ sg_host_t w1 = workstations[0];
+ sg_host_t w2 = workstations[1];
+ const char *name1 = sg_host_get_name(w1);
+ const char *name2 = sg_host_get_name(w2);
printf("Route between %s and %s\n", name1, name2);
- route = SD_route_get_list(w1, w2);
- route_size = SD_route_get_size(w1, w2);
+ SD_link_t *route = SD_route_get_list(w1, w2);
+ int route_size = SD_route_get_size(w1, w2);
printf("Route size %d\n", route_size);
- for (i = 0; i < route_size; i++) {
- printf(" Link %s: latency = %f, bandwidth = %f\n",
- sg_link_name(route[i]),
- sg_link_latency(route[i]),
- sg_link_bandwidth(route[i]));
- }
- printf("Route latency = %f, route bandwidth = %f\n",
- SD_route_get_latency(w1, w2),
- SD_route_get_bandwidth(w1, w2));
+ for (int i = 0; i < route_size; i++)
+ printf(" Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]), sg_link_latency(route[i]), sg_link_bandwidth(route[i]));
+ printf("Route latency = %f, route bandwidth = %f\n", SD_route_get_latency(w1, w2), SD_route_get_bandwidth(w1, w2));
xbt_free(route);
}
if (!strcmp(argv[2], "FULL_LINK")) {
- list_size = sg_host_count();
- for (i = 0; i < list_size; i++) {
- w1 = workstations[i];
- name1 = sg_host_get_name(w1);
- for (j = 0; j < list_size; j++) {
- w2 = workstations[j];
- name2 = sg_host_get_name(w2);
- printf("Route between %s and %s\n", name1, name2);
- route = SD_route_get_list(w1, w2);
- route_size = SD_route_get_size(w1, w2);
- printf(" Route size %d\n", route_size);
- for (k = 0; k < route_size; k++) {
- printf(" Link %s: latency = %f, bandwidth = %f\n",
- sg_link_name(route[k]),
- sg_link_latency(route[k]),
- sg_link_bandwidth(route[k]));
+ int list_size = sg_host_count();
+ for (int i = 0; i < list_size; i++) {
+ sg_host_t w1 = workstations[i];
+ const char *name1 = sg_host_get_name(w1);
+ for (int j = 0; j < list_size; j++) {
+ sg_host_t w2 = workstations[j];
+ const char *name2 = sg_host_get_name(w2);
+ printf("Route between %s and %s\n", name1, name2);
+ SD_link_t *route = SD_route_get_list(w1, w2);
+ int route_size = SD_route_get_size(w1, w2);
+ printf(" Route size %d\n", route_size);
+ for (int k = 0; k < route_size; k++) {
+ printf(" Link %s: latency = %f, bandwidth = %f\n",
+ sg_link_name(route[k]), sg_link_latency(route[k]), sg_link_bandwidth(route[k]));
+ }
+ printf(" Route latency = %f, route bandwidth = %f\n", SD_route_get_latency(w1, w2), SD_route_get_bandwidth(w1, w2));
+ xbt_free(route);
}
- printf(" Route latency = %f, route bandwidth = %f\n",
- SD_route_get_latency(w1, w2),
- SD_route_get_bandwidth(w1, w2));
- xbt_free(route);
}
- }
- }
- if (!strcmp(argv[2], "PROP")) {
- printf("SG_TEST_mem: %s\n",
- sg_host_get_property_value(sg_host_by_name("host1"),
- "SG_TEST_mem"));
}
+ if (!strcmp(argv[2], "PROP"))
+ printf("SG_TEST_mem: %s\n", sg_host_get_property_value(sg_host_by_name("host1"), "SG_TEST_mem"));
}
xbt_free(workstations);
int main(int argc, char **argv)
{
- int res;
- xbt_dynar_t all_hosts;
- msg_host_t first_host;
MSG_init(&argc, argv);
MSG_create_environment(argv[1]);
MSG_function_register("host", host);
- all_hosts = MSG_hosts_as_dynar();
- first_host = xbt_dynar_pop_as(all_hosts,msg_host_t);
- MSG_process_create( "host", host, NULL, first_host);
+ xbt_dynar_t all_hosts = MSG_hosts_as_dynar();
+ MSG_process_create( "host", host, NULL, xbt_dynar_pop_as(all_hosts,msg_host_t));
xbt_dynar_free(&all_hosts);
- res = MSG_main();
+ int res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());
return res != MSG_OK;
size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib);
- printf("Workstation number: %zu, link number: %d, elmts number: %d\n",
- sg_host_count(), sg_link_count(), size);
-
- xbt_dict_foreach(host_list, cursor, key, data) {
- printf(" - Seen: \"%s\" is type : %d\n", key,
- (int) routing_get_network_element_type(key));
- }
-
- xbt_lib_foreach(as_router_lib, cursor, key, data) {
- printf(" - Seen: \"%s\" is type : %d\n", key,
- (int) routing_get_network_element_type(key));
- }
+ printf("Workstation number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size);
+
+ xbt_dict_foreach(host_list, cursor, key, data)
+ printf(" - Seen: \"%s\" is type : %d\n", key, (int) routing_get_network_element_type(key));
+
+ xbt_lib_foreach(as_router_lib, cursor, key, data)
+ printf(" - Seen: \"%s\" is type : %d\n", key, (int) routing_get_network_element_type(key));
SD_exit();
return 0;