static void dolog(const char *settings) { XBT_INFO("Test with the settings '%s'", settings); xbt_log_control_set(settings); XBT_DEBUG("val=%d", 1); XBT_WARN("val=%d", 2); XBT_CDEBUG(top, "val=%d%s", 3, "!"); XBT_CRITICAL("false alarm%s%s%s%s%s%s", "", "", "", "", "", "!"); }
/** @brief Get all logging settings from the command line * * xbt_log_control_set() is called on each string we got from cmd line */ void xbt_log_init(int *argc, char **argv) { unsigned help_requested = 0; /* 1: logs; 2: categories */ int i, j; char *opt; // _XBT_LOGV(log).threshold = xbt_log_priority_debug; /* uncomment to set the LOG category to debug directly */ xbt_log_connect_categories(); /* Set logs and init log submodule */ for (j = i = 1; i < *argc; i++) { if (!strncmp(argv[i], "--log=", strlen("--log="))) { opt = strchr(argv[i], '='); opt++; xbt_log_control_set(opt); XBT_DEBUG("Did apply '%s' as log setting", opt); } else if (!strcmp(argv[i], "--help-logs")) { help_requested |= 1; } else if (!strcmp(argv[i], "--help-log-categories")) { help_requested |= 2; } else { argv[j++] = argv[i]; } } if (j < *argc) { argv[j] = NULL; *argc = j; } if (help_requested) { if (help_requested & 1) xbt_log_help(); if (help_requested & 2) xbt_log_help_categories(); exit(0); } }
int main(int argc, char **argv) { unsigned int flag, cursor, cursor2; char *platform_file = NULL, *daxname = NULL, *priority=NULL; int total_nworkstations = 0; const SD_workstation_t *workstations = NULL; xbt_dynar_t daxes = NULL, current_dax = NULL; int completed_daxes = 0; SD_task_t task; scheduling_globals_t globals; WorkstationAttribute attr; double total_cost = 0.0, score = 0.0; SD_init(&argc, argv); /* get rid off some logs that are useless */ xbt_log_control_set("sd_daxparse.thresh:critical"); xbt_log_control_set("surf_workstation.thresh:critical"); xbt_log_control_set("root.fmt:[%9.3r]%e[%13c/%7p]%e%m%n"); globals = new_scheduling_globals(); daxes = xbt_dynar_new(sizeof(xbt_dynar_t), NULL); opterr = 0; while (1){ static struct option long_options[] = { {"alg", 1, 0, 'a'}, {"platform", 1, 0, 'b'}, {"dax", 1, 0, 'c'}, {"priority", 1, 0, 'd'}, {"deadline", 1, 0, 'e'}, {"budget", 1, 0, 'f'}, {"price", 1, 0, 'g'}, {"period", 1, 0, 'h'}, {"uh", 1, 0, 'i'}, {"ul", 1, 0, 'j'}, {"provisioning_delay", 1, 0, 'k'}, {"silent", 0, 0, 'y'}, {"dump", 1, 0, 'z'}, {0, 0, 0, 0} }; int option_index = 0; flag = getopt_long (argc, argv, "", long_options, &option_index); /* Detect the end of the options. */ if (flag == -1) break; switch (flag) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'a': /* Algorithm name */ /* DPDS, WA-DPDS, SPSS, Ours*/ globals->alg = getAlgorithmByName(optarg); break; case 'b': platform_file = optarg; SD_create_environment(platform_file); total_nworkstations = SD_workstation_get_number(); workstations = SD_workstation_get_list(); /* Sort the hosts by name for sake of simplicity */ qsort((void *)workstations,total_nworkstations, sizeof(SD_workstation_t), nameCompareWorkstations); for(cursor=0; cursor<total_nworkstations; cursor++){ SD_workstation_allocate_attribute(workstations[cursor]); } break; case 'c': /* List of DAGs to schedule concurrently (just file names here) */ daxname = optarg; XBT_DEBUG("Loading %s", daxname); current_dax = SD_daxload(daxname); xbt_dynar_foreach(current_dax,cursor,task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ){ SD_task_watch(task, SD_DONE); } SD_task_allocate_attribute(task); SD_task_set_dax_name(task, daxname); } xbt_dynar_push(daxes,¤t_dax); break; case 'd': priority = optarg; if (!strcmp(priority,"random")) globals->priority_method = RANDOM; else if (!strcmp(priority, "sorted")) globals->priority_method = SORTED; else { XBT_ERROR("Unknown priority setting method."); exit(1); } break; case 'e': globals->deadline = atof(optarg); break; case 'f': globals->budget = atof(optarg); break; case 'g': globals->price = atof(optarg); break; case 'h': globals->period = atof(optarg); break; case 'i': globals->uh = atof(optarg); break; case 'j': globals->ul = atof(optarg); break; case 'k': globals->provisioning_delay = atof(optarg); break; case 'y': xbt_log_control_set("root.thresh:critical"); break; case 'z': break; } } /* Display some information about the current run */ XBT_INFO("Algorithm: %s",getAlgorithmName(globals->alg)); XBT_INFO(" Priority method: %s", globals->priority_method ? "SORTED" : "RANDOM"); XBT_INFO(" Dynamic provisioning period: %.0fs", globals->period); XBT_INFO(" Lower utilization threshold: %.2f%%", globals->ul); XBT_INFO(" Upper utilization threshold: %.2f%%", globals->uh); XBT_INFO("Platform: %s (%d potential VMs)", platform_file, SD_workstation_get_number()); XBT_INFO(" VM hourly cost: $%f", globals->price); XBT_INFO(" VM provisioning delay: %.0fs", globals->provisioning_delay); if (ceil(globals->budget/((globals->deadline/3600.)*globals->price))> SD_workstation_get_number()){ XBT_ERROR("The platform file doesn't have enough nodes. Stop here"); exit(1); } /* Assign price and provisioning delay to workstation/VM (for the sake of * simplicity) */ for(cursor=0; cursor<total_nworkstations; cursor++){ SD_workstation_set_price(workstations[cursor], globals->price); SD_workstation_set_provisioning_delay(workstations[cursor], globals->provisioning_delay); } XBT_INFO("Ensemble: %lu DAXes", xbt_dynar_length(daxes)); /* Assign priorities to the DAXes composing the ensemble according to the * chosen method: RANDOM (default) or SORTED. * Then display the result. */ assign_dax_priorities(daxes, globals->priority_method); xbt_dynar_foreach(daxes, cursor, current_dax){ task = get_root(current_dax); XBT_INFO(" %s", SD_task_get_dax_name(task)); XBT_INFO(" Priority: %d", SD_task_get_dax_priority(task)); }
int main(int argc, char **argv) { float rate_no_limit=0.2; float acc_date=0; float acc_date2=0; int testclass; if(argc<3) { fprintf(stderr, "Syntax: <small|medium|big|huge> <count> [test|debug|perf]\n"); return -1; } //what class? if(!strcmp(argv[1],"small")) testclass=0; else if(!strcmp(argv[1],"medium")) testclass=1; else if(!strcmp(argv[1],"big")) testclass=2; else if(!strcmp(argv[1],"huge")) testclass=3; else { fprintf(stderr, "Unknown class \"%s\", aborting!\n",argv[1]); return -2; } //How many times? int testcount=atoi(argv[2]); //Show me everything (debug or performance)! int mode=0; if(argc>=4 && strcmp(argv[3],"test")==0) mode=1; if(argc>=4 && strcmp(argv[3],"debug")==0) mode=2; if(argc>=4 && strcmp(argv[3],"perf")==0) mode=3; if(mode==1) xbt_log_control_set("surf/maxmin.threshold:DEBUG surf/maxmin.fmt:\'[%r]: [%c/%p] %m%n\'\ surf.threshold:DEBUG surf.fmt:\'[%r]: [%c/%p] %m%n\' "); if(mode==2) xbt_log_control_set("surf/maxmin.threshold:DEBUG surf.threshold:DEBUG"); unsigned int nb_cnst= TestClasses[testclass][0]; unsigned int nb_var= TestClasses[testclass][1]; unsigned int pw_base_limit= TestClasses[testclass][2]; unsigned int pw_max_limit= TestClasses[testclass][3]; unsigned int max_share=2; //1<<(pw_base_limit/2+1); //If you want to test concurrency, you need nb_elem >> 2^pw_base_limit: unsigned int nb_elem= (1<<pw_base_limit)+(1<<(8*pw_max_limit/10)); //Otherwise, just set it to a constant value (and set rate_no_limit to 1.0): //nb_elem=200 xbt_init(&argc, argv); for(int i=0;i<testcount;i++){ seedx=i+1; fprintf(stderr, "Starting %i: (%i)\n",i,myrand()%1000); test(nb_cnst, nb_var, nb_elem, pw_base_limit, pw_max_limit, rate_no_limit,max_share,mode); acc_date+=date; acc_date2+=date*date; } float mean_date= acc_date/(float)testcount; float stdev_date= sqrt(acc_date2/(float)testcount-mean_date*mean_date); fprintf(stderr, "%ix One shot execution time for a total of %d constraints, " "%d variables with %d active constraint each, concurrency in [%i,%i] and max concurrency share %i\n", testcount,nb_cnst, nb_var, nb_elem, (1<<pw_base_limit), (1<<pw_base_limit)+(1<<pw_max_limit), max_share); if(mode==3) fprintf(stderr, "Execution time: %g +- %g microseconds \n",mean_date, stdev_date); return 0; }