diff --git a/.gitignore b/.gitignore index 7d75298..7840f38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build __pycache__ +*_cmdline.c +*_cmdline.h diff --git a/src/LogGOPSim/loggopsim_cmdline.c b/src/LogGOPSim/loggopsim_cmdline.c deleted file mode 100644 index 85907a2..0000000 --- a/src/LogGOPSim/loggopsim_cmdline.c +++ /dev/null @@ -1,962 +0,0 @@ -/* - File autogenerated by gengetopt version 2.23 - generated with the following command: - gengetopt -F loggopsim_cmdline -i /Users/tim0s/Work/LogGOPSim/src/LogGOPSim/loggopsim_cmdline.ggo --output-dir /Users/tim0s/Work/LogGOPSim/src/LogGOPSim - - The developers of gengetopt consider the fixed text that goes in all - gengetopt output files to be in the public domain: - we make no copyright claims on it. -*/ - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#ifndef FIX_UNUSED -#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ -#endif - -#include - -#include "loggopsim_cmdline.h" - -const char *gengetopt_args_info_purpose = ""; - -const char *gengetopt_args_info_usage = "Usage: goalsim [OPTION]..."; - -const char *gengetopt_args_info_versiontext = ""; - -const char *gengetopt_args_info_description = ""; - -const char *gengetopt_args_info_help[] = { - " -h, --help Print help and exit", - " --version Print version and exit", - " -f, --filename=STRING Prefix for the filenames which contain the\n schedules", - " --save-mem Map the schedules as MAP_SHARED to enable\n processing of large schedule (larger than main\n memory). This will invalidate the schedules\n during simulation. (default=off)", - " -L, --LogGOPS_L=INT The latency parameter L in the LogGP model\n (default=`2500')", - " -o, --LogGOPS_o=INT The overhead parameter o in the LogGP model\n (default=`1500')", - " -g, --LogGOPS_g=INT The gap per message parameter g in the LogGP model\n (default=`1000')", - " -G, --LogGOPS_G=INT The gap per byte parameter G in the LogGP model\n (default=`6')", - " -S, --LogGOPS_S=INT Datasize at which we change from eager to\n rendezvous protocol (default=`65535')", - " -O, --LogGOPS_O=INT The overhead per byte in LogGOP (default=`0')", - " -V, --vizfile=STRING Name of the output file for visualization data", - " -v, --verbose Enable more verbose output", - " --progress print progress", - " -b, --batchmode enable batchmode (never print detailed host info)", - " --noise-trace=STRING Read Noise from trace ", - " --noise-cosched Co-schedule noise (use same starttime on all\n processes) (default=off)", - " -n, --network-type=STRING Network type (LogGP=no network congestion;\n simple=simple linear model) (possible\n values=\"LogGP\", \"simple\" default=`LogGP')", - " --network-file=STRING Input file for network (annotated dot format)", - " --qstat=STRING Enable PQ and UQ statistics. Argument is output\n filename prefix (default=`Unknown')", - 0 -}; - -typedef enum {ARG_NO - , ARG_FLAG - , ARG_STRING - , ARG_INT -} cmdline_parser_arg_type; - -static -void clear_given (struct gengetopt_args_info *args_info); -static -void clear_args (struct gengetopt_args_info *args_info); - -static int -cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error); - -static int -cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); - -const char *cmdline_parser_network_type_values[] = {"LogGP", "simple", 0}; /*< Possible values for network-type. */ - -static char * -gengetopt_strdup (const char *s); - -static -void clear_given (struct gengetopt_args_info *args_info) -{ - args_info->help_given = 0 ; - args_info->version_given = 0 ; - args_info->filename_given = 0 ; - args_info->save_mem_given = 0 ; - args_info->LogGOPS_L_given = 0 ; - args_info->LogGOPS_o_given = 0 ; - args_info->LogGOPS_g_given = 0 ; - args_info->LogGOPS_G_given = 0 ; - args_info->LogGOPS_S_given = 0 ; - args_info->LogGOPS_O_given = 0 ; - args_info->vizfile_given = 0 ; - args_info->verbose_given = 0 ; - args_info->progress_given = 0 ; - args_info->batchmode_given = 0 ; - args_info->noise_trace_given = 0 ; - args_info->noise_cosched_given = 0 ; - args_info->network_type_given = 0 ; - args_info->network_file_given = 0 ; - args_info->qstat_given = 0 ; -} - -static -void clear_args (struct gengetopt_args_info *args_info) -{ - FIX_UNUSED (args_info); - args_info->filename_arg = NULL; - args_info->filename_orig = NULL; - args_info->save_mem_flag = 0; - args_info->LogGOPS_L_arg = 2500; - args_info->LogGOPS_L_orig = NULL; - args_info->LogGOPS_o_arg = 1500; - args_info->LogGOPS_o_orig = NULL; - args_info->LogGOPS_g_arg = 1000; - args_info->LogGOPS_g_orig = NULL; - args_info->LogGOPS_G_arg = 6; - args_info->LogGOPS_G_orig = NULL; - args_info->LogGOPS_S_arg = 65535; - args_info->LogGOPS_S_orig = NULL; - args_info->LogGOPS_O_arg = 0; - args_info->LogGOPS_O_orig = NULL; - args_info->vizfile_arg = NULL; - args_info->vizfile_orig = NULL; - args_info->noise_trace_arg = NULL; - args_info->noise_trace_orig = NULL; - args_info->noise_cosched_flag = 0; - args_info->network_type_arg = gengetopt_strdup ("LogGP"); - args_info->network_type_orig = NULL; - args_info->network_file_arg = NULL; - args_info->network_file_orig = NULL; - args_info->qstat_arg = gengetopt_strdup ("Unknown"); - args_info->qstat_orig = NULL; - -} - -static -void init_args_info(struct gengetopt_args_info *args_info) -{ - - - args_info->help_help = gengetopt_args_info_help[0] ; - args_info->version_help = gengetopt_args_info_help[1] ; - args_info->filename_help = gengetopt_args_info_help[2] ; - args_info->save_mem_help = gengetopt_args_info_help[3] ; - args_info->LogGOPS_L_help = gengetopt_args_info_help[4] ; - args_info->LogGOPS_o_help = gengetopt_args_info_help[5] ; - args_info->LogGOPS_g_help = gengetopt_args_info_help[6] ; - args_info->LogGOPS_G_help = gengetopt_args_info_help[7] ; - args_info->LogGOPS_S_help = gengetopt_args_info_help[8] ; - args_info->LogGOPS_O_help = gengetopt_args_info_help[9] ; - args_info->vizfile_help = gengetopt_args_info_help[10] ; - args_info->verbose_help = gengetopt_args_info_help[11] ; - args_info->progress_help = gengetopt_args_info_help[12] ; - args_info->batchmode_help = gengetopt_args_info_help[13] ; - args_info->noise_trace_help = gengetopt_args_info_help[14] ; - args_info->noise_cosched_help = gengetopt_args_info_help[15] ; - args_info->network_type_help = gengetopt_args_info_help[16] ; - args_info->network_file_help = gengetopt_args_info_help[17] ; - args_info->qstat_help = gengetopt_args_info_help[18] ; - -} - -void -cmdline_parser_print_version (void) -{ - printf ("%s %s\n", - (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), - CMDLINE_PARSER_VERSION); - - if (strlen(gengetopt_args_info_versiontext) > 0) - printf("\n%s\n", gengetopt_args_info_versiontext); -} - -static void print_help_common(void) -{ - size_t len_purpose = strlen(gengetopt_args_info_purpose); - size_t len_usage = strlen(gengetopt_args_info_usage); - - if (len_usage > 0) { - printf("%s\n", gengetopt_args_info_usage); - } - if (len_purpose > 0) { - printf("%s\n", gengetopt_args_info_purpose); - } - - if (len_usage || len_purpose) { - printf("\n"); - } - - if (strlen(gengetopt_args_info_description) > 0) { - printf("%s\n\n", gengetopt_args_info_description); - } -} - -void -cmdline_parser_print_help (void) -{ - int i = 0; - print_help_common(); - while (gengetopt_args_info_help[i]) - printf("%s\n", gengetopt_args_info_help[i++]); -} - -void -cmdline_parser_init (struct gengetopt_args_info *args_info) -{ - clear_given (args_info); - clear_args (args_info); - init_args_info (args_info); -} - -void -cmdline_parser_params_init(struct cmdline_parser_params *params) -{ - if (params) - { - params->override = 0; - params->initialize = 1; - params->check_required = 1; - params->check_ambiguity = 0; - params->print_errors = 1; - } -} - -struct cmdline_parser_params * -cmdline_parser_params_create(void) -{ - struct cmdline_parser_params *params = - (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); - return params; -} - -static void -free_string_field (char **s) -{ - if (*s) - { - free (*s); - *s = 0; - } -} - - -static void -cmdline_parser_release (struct gengetopt_args_info *args_info) -{ - - free_string_field (&(args_info->filename_arg)); - free_string_field (&(args_info->filename_orig)); - free_string_field (&(args_info->LogGOPS_L_orig)); - free_string_field (&(args_info->LogGOPS_o_orig)); - free_string_field (&(args_info->LogGOPS_g_orig)); - free_string_field (&(args_info->LogGOPS_G_orig)); - free_string_field (&(args_info->LogGOPS_S_orig)); - free_string_field (&(args_info->LogGOPS_O_orig)); - free_string_field (&(args_info->vizfile_arg)); - free_string_field (&(args_info->vizfile_orig)); - free_string_field (&(args_info->noise_trace_arg)); - free_string_field (&(args_info->noise_trace_orig)); - free_string_field (&(args_info->network_type_arg)); - free_string_field (&(args_info->network_type_orig)); - free_string_field (&(args_info->network_file_arg)); - free_string_field (&(args_info->network_file_orig)); - free_string_field (&(args_info->qstat_arg)); - free_string_field (&(args_info->qstat_orig)); - - - - clear_given (args_info); -} - -/** - * @param val the value to check - * @param values the possible values - * @return the index of the matched value: - * -1 if no value matched, - * -2 if more than one value has matched - */ -static int -check_possible_values(const char *val, const char *values[]) -{ - int i, found, last; - size_t len; - - if (!val) /* otherwise strlen() crashes below */ - return -1; /* -1 means no argument for the option */ - - found = last = 0; - - for (i = 0, len = strlen(val); values[i]; ++i) - { - if (strncmp(val, values[i], len) == 0) - { - ++found; - last = i; - if (strlen(values[i]) == len) - return i; /* exact macth no need to check more */ - } - } - - if (found == 1) /* one match: OK */ - return last; - - return (found ? -2 : -1); /* return many values or none matched */ -} - - -static void -write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) -{ - int found = -1; - if (arg) { - if (values) { - found = check_possible_values(arg, values); - } - if (found >= 0) - fprintf(outfile, "%s=\"%s\" # %s\n", opt, arg, values[found]); - else - fprintf(outfile, "%s=\"%s\"\n", opt, arg); - } else { - fprintf(outfile, "%s\n", opt); - } -} - - -int -cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) -{ - int i = 0; - - if (!outfile) - { - fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); - return EXIT_FAILURE; - } - - if (args_info->help_given) - write_into_file(outfile, "help", 0, 0 ); - if (args_info->version_given) - write_into_file(outfile, "version", 0, 0 ); - if (args_info->filename_given) - write_into_file(outfile, "filename", args_info->filename_orig, 0); - if (args_info->save_mem_given) - write_into_file(outfile, "save-mem", 0, 0 ); - if (args_info->LogGOPS_L_given) - write_into_file(outfile, "LogGOPS_L", args_info->LogGOPS_L_orig, 0); - if (args_info->LogGOPS_o_given) - write_into_file(outfile, "LogGOPS_o", args_info->LogGOPS_o_orig, 0); - if (args_info->LogGOPS_g_given) - write_into_file(outfile, "LogGOPS_g", args_info->LogGOPS_g_orig, 0); - if (args_info->LogGOPS_G_given) - write_into_file(outfile, "LogGOPS_G", args_info->LogGOPS_G_orig, 0); - if (args_info->LogGOPS_S_given) - write_into_file(outfile, "LogGOPS_S", args_info->LogGOPS_S_orig, 0); - if (args_info->LogGOPS_O_given) - write_into_file(outfile, "LogGOPS_O", args_info->LogGOPS_O_orig, 0); - if (args_info->vizfile_given) - write_into_file(outfile, "vizfile", args_info->vizfile_orig, 0); - if (args_info->verbose_given) - write_into_file(outfile, "verbose", 0, 0 ); - if (args_info->progress_given) - write_into_file(outfile, "progress", 0, 0 ); - if (args_info->batchmode_given) - write_into_file(outfile, "batchmode", 0, 0 ); - if (args_info->noise_trace_given) - write_into_file(outfile, "noise-trace", args_info->noise_trace_orig, 0); - if (args_info->noise_cosched_given) - write_into_file(outfile, "noise-cosched", 0, 0 ); - if (args_info->network_type_given) - write_into_file(outfile, "network-type", args_info->network_type_orig, cmdline_parser_network_type_values); - if (args_info->network_file_given) - write_into_file(outfile, "network-file", args_info->network_file_orig, 0); - if (args_info->qstat_given) - write_into_file(outfile, "qstat", args_info->qstat_orig, 0); - - - i = EXIT_SUCCESS; - return i; -} - -int -cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) -{ - FILE *outfile; - int i = 0; - - outfile = fopen(filename, "w"); - - if (!outfile) - { - fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); - return EXIT_FAILURE; - } - - i = cmdline_parser_dump(outfile, args_info); - fclose (outfile); - - return i; -} - -void -cmdline_parser_free (struct gengetopt_args_info *args_info) -{ - cmdline_parser_release (args_info); -} - -/** @brief replacement of strdup, which is not standard */ -char * -gengetopt_strdup (const char *s) -{ - char *result = 0; - if (!s) - return result; - - result = (char*)malloc(strlen(s) + 1); - if (result == (char*)0) - return (char*)0; - strcpy(result, s); - return result; -} - -int -cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) -{ - return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); -} - -int -cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params) -{ - int result; - result = cmdline_parser_internal (argc, argv, args_info, params, 0); - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) -{ - int result; - struct cmdline_parser_params params; - - params.override = override; - params.initialize = initialize; - params.check_required = check_required; - params.check_ambiguity = 0; - params.print_errors = 1; - - result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) -{ - int result = EXIT_SUCCESS; - - if (cmdline_parser_required2(args_info, prog_name, 0) > 0) - result = EXIT_FAILURE; - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) -{ - int error_occurred = 0; - FIX_UNUSED (additional_error); - - /* checks for required options */ - if (! args_info->filename_given) - { - fprintf (stderr, "%s: '--filename' ('-f') option required%s\n", prog_name, (additional_error ? additional_error : "")); - error_occurred = 1; - } - - - /* checks for dependences among options */ - - return error_occurred; -} - - -static char *package_name = 0; - -/** - * @brief updates an option - * @param field the generic pointer to the field to update - * @param orig_field the pointer to the orig field - * @param field_given the pointer to the number of occurrence of this option - * @param prev_given the pointer to the number of occurrence already seen - * @param value the argument for this option (if null no arg was specified) - * @param possible_values the possible values for this option (if specified) - * @param default_value the default value (in case the option only accepts fixed values) - * @param arg_type the type of this option - * @param check_ambiguity @see cmdline_parser_params.check_ambiguity - * @param override @see cmdline_parser_params.override - * @param no_free whether to free a possible previous value - * @param multiple_option whether this is a multiple option - * @param long_opt the corresponding long option - * @param short_opt the corresponding short option (or '-' if none) - * @param additional_error possible further error specification - */ -static -int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, - char *value, const char *possible_values[], - const char *default_value, - cmdline_parser_arg_type arg_type, - int check_ambiguity, int override, - int no_free, int multiple_option, - const char *long_opt, char short_opt, - const char *additional_error) -{ - char *stop_char = 0; - const char *val = value; - int found; - char **string_field; - FIX_UNUSED (field); - - stop_char = 0; - found = 0; - - if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) - { - if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", - package_name, long_opt, short_opt, - (additional_error ? additional_error : "")); - else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", - package_name, long_opt, - (additional_error ? additional_error : "")); - return 1; /* failure */ - } - - if (possible_values && (found = check_possible_values((value ? value : default_value), possible_values)) < 0) - { - if (short_opt != '-') - fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s' (`-%c')%s\n", - package_name, (found == -2) ? "ambiguous" : "invalid", value, long_opt, short_opt, - (additional_error ? additional_error : "")); - else - fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s'%s\n", - package_name, (found == -2) ? "ambiguous" : "invalid", value, long_opt, - (additional_error ? additional_error : "")); - return 1; /* failure */ - } - - if (field_given && *field_given && ! override) - return 0; - if (prev_given) - (*prev_given)++; - if (field_given) - (*field_given)++; - if (possible_values) - val = possible_values[found]; - - switch(arg_type) { - case ARG_FLAG: - *((int *)field) = !*((int *)field); - break; - case ARG_INT: - if (val) *((int *)field) = strtol (val, &stop_char, 0); - break; - case ARG_STRING: - if (val) { - string_field = (char **)field; - if (!no_free && *string_field) - free (*string_field); /* free previous string */ - *string_field = gengetopt_strdup (val); - } - break; - default: - break; - }; - - /* check numeric conversion */ - switch(arg_type) { - case ARG_INT: - if (val && !(stop_char && *stop_char == '\0')) { - fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); - return 1; /* failure */ - } - break; - default: - ; - }; - - /* store the original value */ - switch(arg_type) { - case ARG_NO: - case ARG_FLAG: - break; - default: - if (value && orig_field) { - if (no_free) { - *orig_field = value; - } else { - if (*orig_field) - free (*orig_field); /* free previous string */ - *orig_field = gengetopt_strdup (value); - } - } - }; - - return 0; /* OK */ -} - - -int -cmdline_parser_internal ( - int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error) -{ - int c; /* Character of the parsed option. */ - - int error_occurred = 0; - struct gengetopt_args_info local_args_info; - - int override; - int initialize; - int check_required; - int check_ambiguity; - - package_name = argv[0]; - - /* TODO: Why is this here? It is not used anywhere. */ - override = params->override; - FIX_UNUSED(override); - - initialize = params->initialize; - check_required = params->check_required; - - /* TODO: Why is this here? It is not used anywhere. */ - check_ambiguity = params->check_ambiguity; - FIX_UNUSED(check_ambiguity); - - if (initialize) - cmdline_parser_init (args_info); - - cmdline_parser_init (&local_args_info); - - optarg = 0; - optind = 0; - opterr = params->print_errors; - optopt = '?'; - - while (1) - { - int option_index = 0; - - static struct option long_options[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 0 }, - { "filename", 1, NULL, 'f' }, - { "save-mem", 0, NULL, 0 }, - { "LogGOPS_L", 1, NULL, 'L' }, - { "LogGOPS_o", 1, NULL, 'o' }, - { "LogGOPS_g", 1, NULL, 'g' }, - { "LogGOPS_G", 1, NULL, 'G' }, - { "LogGOPS_S", 1, NULL, 'S' }, - { "LogGOPS_O", 1, NULL, 'O' }, - { "vizfile", 1, NULL, 'V' }, - { "verbose", 0, NULL, 'v' }, - { "progress", 0, NULL, 0 }, - { "batchmode", 0, NULL, 'b' }, - { "noise-trace", 1, NULL, 0 }, - { "noise-cosched", 0, NULL, 0 }, - { "network-type", 1, NULL, 'n' }, - { "network-file", 1, NULL, 0 }, - { "qstat", 1, NULL, 0 }, - { 0, 0, 0, 0 } - }; - - c = getopt_long (argc, argv, "hf:L:o:g:G:S:O:V:vbn:", long_options, &option_index); - - if (c == -1) break; /* Exit from `while (1)' loop. */ - - switch (c) - { - case 'h': /* Print help and exit. */ - cmdline_parser_print_help (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); - - case 'f': /* Prefix for the filenames which contain the schedules. */ - - - if (update_arg( (void *)&(args_info->filename_arg), - &(args_info->filename_orig), &(args_info->filename_given), - &(local_args_info.filename_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "filename", 'f', - additional_error)) - goto failure; - - break; - case 'L': /* The latency parameter L in the LogGP model. */ - - - if (update_arg( (void *)&(args_info->LogGOPS_L_arg), - &(args_info->LogGOPS_L_orig), &(args_info->LogGOPS_L_given), - &(local_args_info.LogGOPS_L_given), optarg, 0, "2500", ARG_INT, - check_ambiguity, override, 0, 0, - "LogGOPS_L", 'L', - additional_error)) - goto failure; - - break; - case 'o': /* The overhead parameter o in the LogGP model. */ - - - if (update_arg( (void *)&(args_info->LogGOPS_o_arg), - &(args_info->LogGOPS_o_orig), &(args_info->LogGOPS_o_given), - &(local_args_info.LogGOPS_o_given), optarg, 0, "1500", ARG_INT, - check_ambiguity, override, 0, 0, - "LogGOPS_o", 'o', - additional_error)) - goto failure; - - break; - case 'g': /* The gap per message parameter g in the LogGP model. */ - - - if (update_arg( (void *)&(args_info->LogGOPS_g_arg), - &(args_info->LogGOPS_g_orig), &(args_info->LogGOPS_g_given), - &(local_args_info.LogGOPS_g_given), optarg, 0, "1000", ARG_INT, - check_ambiguity, override, 0, 0, - "LogGOPS_g", 'g', - additional_error)) - goto failure; - - break; - case 'G': /* The gap per byte parameter G in the LogGP model. */ - - - if (update_arg( (void *)&(args_info->LogGOPS_G_arg), - &(args_info->LogGOPS_G_orig), &(args_info->LogGOPS_G_given), - &(local_args_info.LogGOPS_G_given), optarg, 0, "6", ARG_INT, - check_ambiguity, override, 0, 0, - "LogGOPS_G", 'G', - additional_error)) - goto failure; - - break; - case 'S': /* Datasize at which we change from eager to rendezvous protocol. */ - - - if (update_arg( (void *)&(args_info->LogGOPS_S_arg), - &(args_info->LogGOPS_S_orig), &(args_info->LogGOPS_S_given), - &(local_args_info.LogGOPS_S_given), optarg, 0, "65535", ARG_INT, - check_ambiguity, override, 0, 0, - "LogGOPS_S", 'S', - additional_error)) - goto failure; - - break; - case 'O': /* The overhead per byte in LogGOP. */ - - - if (update_arg( (void *)&(args_info->LogGOPS_O_arg), - &(args_info->LogGOPS_O_orig), &(args_info->LogGOPS_O_given), - &(local_args_info.LogGOPS_O_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "LogGOPS_O", 'O', - additional_error)) - goto failure; - - break; - case 'V': /* Name of the output file for visualization data. */ - - - if (update_arg( (void *)&(args_info->vizfile_arg), - &(args_info->vizfile_orig), &(args_info->vizfile_given), - &(local_args_info.vizfile_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "vizfile", 'V', - additional_error)) - goto failure; - - break; - case 'v': /* Enable more verbose output. */ - - - if (update_arg( 0 , - 0 , &(args_info->verbose_given), - &(local_args_info.verbose_given), optarg, 0, 0, ARG_NO, - check_ambiguity, override, 0, 0, - "verbose", 'v', - additional_error)) - goto failure; - - break; - case 'b': /* enable batchmode (never print detailed host info). */ - - - if (update_arg( 0 , - 0 , &(args_info->batchmode_given), - &(local_args_info.batchmode_given), optarg, 0, 0, ARG_NO, - check_ambiguity, override, 0, 0, - "batchmode", 'b', - additional_error)) - goto failure; - - break; - case 'n': /* Network type (LogGP=no network congestion; simple=simple linear model). */ - - - if (update_arg( (void *)&(args_info->network_type_arg), - &(args_info->network_type_orig), &(args_info->network_type_given), - &(local_args_info.network_type_given), optarg, cmdline_parser_network_type_values, "LogGP", ARG_STRING, - check_ambiguity, override, 0, 0, - "network-type", 'n', - additional_error)) - goto failure; - - break; - - case 0: /* Long option with no short option */ - if (strcmp (long_options[option_index].name, "version") == 0) { - cmdline_parser_print_version (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); - } - - /* Map the schedules as MAP_SHARED to enable processing of large schedule (larger than main memory). This will invalidate the schedules during simulation.. */ - if (strcmp (long_options[option_index].name, "save-mem") == 0) - { - - - if (update_arg((void *)&(args_info->save_mem_flag), 0, &(args_info->save_mem_given), - &(local_args_info.save_mem_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "save-mem", '-', - additional_error)) - goto failure; - - } - /* print progress. */ - else if (strcmp (long_options[option_index].name, "progress") == 0) - { - - - if (update_arg( 0 , - 0 , &(args_info->progress_given), - &(local_args_info.progress_given), optarg, 0, 0, ARG_NO, - check_ambiguity, override, 0, 0, - "progress", '-', - additional_error)) - goto failure; - - } - /* Read Noise from trace . */ - else if (strcmp (long_options[option_index].name, "noise-trace") == 0) - { - - - if (update_arg( (void *)&(args_info->noise_trace_arg), - &(args_info->noise_trace_orig), &(args_info->noise_trace_given), - &(local_args_info.noise_trace_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "noise-trace", '-', - additional_error)) - goto failure; - - } - /* Co-schedule noise (use same starttime on all processes). */ - else if (strcmp (long_options[option_index].name, "noise-cosched") == 0) - { - - - if (update_arg((void *)&(args_info->noise_cosched_flag), 0, &(args_info->noise_cosched_given), - &(local_args_info.noise_cosched_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "noise-cosched", '-', - additional_error)) - goto failure; - - } - /* Input file for network (annotated dot format). */ - else if (strcmp (long_options[option_index].name, "network-file") == 0) - { - - - if (update_arg( (void *)&(args_info->network_file_arg), - &(args_info->network_file_orig), &(args_info->network_file_given), - &(local_args_info.network_file_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "network-file", '-', - additional_error)) - goto failure; - - } - /* Enable PQ and UQ statistics. Argument is output filename prefix. */ - else if (strcmp (long_options[option_index].name, "qstat") == 0) - { - - - if (update_arg( (void *)&(args_info->qstat_arg), - &(args_info->qstat_orig), &(args_info->qstat_given), - &(local_args_info.qstat_given), optarg, 0, "Unknown", ARG_STRING, - check_ambiguity, override, 0, 0, - "qstat", '-', - additional_error)) - goto failure; - - } - - break; - case '?': /* Invalid option. */ - /* `getopt_long' already printed an error message. */ - goto failure; - - default: /* bug: option not considered. */ - fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); - abort (); - } /* switch */ - } /* while */ - - - - if (check_required) - { - error_occurred += cmdline_parser_required2 (args_info, argv[0], additional_error); - } - - cmdline_parser_release (&local_args_info); - - if ( error_occurred ) - return (EXIT_FAILURE); - - return 0; - -failure: - - cmdline_parser_release (&local_args_info); - return (EXIT_FAILURE); -} -/* vim: set ft=c noet ts=8 sts=8 sw=8 tw=80 nojs spell : */ diff --git a/src/LogGOPSim/loggopsim_cmdline.h b/src/LogGOPSim/loggopsim_cmdline.h deleted file mode 100644 index 24a6725..0000000 --- a/src/LogGOPSim/loggopsim_cmdline.h +++ /dev/null @@ -1,235 +0,0 @@ -/** @file loggopsim_cmdline.h - * @brief The header file for the command line option parser - * generated by GNU Gengetopt version 2.23 - * http://www.gnu.org/software/gengetopt. - * DO NOT modify this file, since it can be overwritten - * @author GNU Gengetopt */ - -#ifndef LOGGOPSIM_CMDLINE_H -#define LOGGOPSIM_CMDLINE_H - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include /* for FILE */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef CMDLINE_PARSER_PACKAGE -/** @brief the program name (used for printing errors) */ -#define CMDLINE_PARSER_PACKAGE "goalsim" -#endif - -#ifndef CMDLINE_PARSER_PACKAGE_NAME -/** @brief the complete program name (used for help and version) */ -#define CMDLINE_PARSER_PACKAGE_NAME "goalsim" -#endif - -#ifndef CMDLINE_PARSER_VERSION -/** @brief the program version */ -#define CMDLINE_PARSER_VERSION "0.1" -#endif - -/** @brief Where the command line options are stored */ -struct gengetopt_args_info -{ - const char *help_help; /**< @brief Print help and exit help description. */ - const char *version_help; /**< @brief Print version and exit help description. */ - char * filename_arg; /**< @brief Prefix for the filenames which contain the schedules. */ - char * filename_orig; /**< @brief Prefix for the filenames which contain the schedules original value given at command line. */ - const char *filename_help; /**< @brief Prefix for the filenames which contain the schedules help description. */ - int save_mem_flag; /**< @brief Map the schedules as MAP_SHARED to enable processing of large schedule (larger than main memory). This will invalidate the schedules during simulation. (default=off). */ - const char *save_mem_help; /**< @brief Map the schedules as MAP_SHARED to enable processing of large schedule (larger than main memory). This will invalidate the schedules during simulation. help description. */ - int LogGOPS_L_arg; /**< @brief The latency parameter L in the LogGP model (default='2500'). */ - char * LogGOPS_L_orig; /**< @brief The latency parameter L in the LogGP model original value given at command line. */ - const char *LogGOPS_L_help; /**< @brief The latency parameter L in the LogGP model help description. */ - int LogGOPS_o_arg; /**< @brief The overhead parameter o in the LogGP model (default='1500'). */ - char * LogGOPS_o_orig; /**< @brief The overhead parameter o in the LogGP model original value given at command line. */ - const char *LogGOPS_o_help; /**< @brief The overhead parameter o in the LogGP model help description. */ - int LogGOPS_g_arg; /**< @brief The gap per message parameter g in the LogGP model (default='1000'). */ - char * LogGOPS_g_orig; /**< @brief The gap per message parameter g in the LogGP model original value given at command line. */ - const char *LogGOPS_g_help; /**< @brief The gap per message parameter g in the LogGP model help description. */ - int LogGOPS_G_arg; /**< @brief The gap per byte parameter G in the LogGP model (default='6'). */ - char * LogGOPS_G_orig; /**< @brief The gap per byte parameter G in the LogGP model original value given at command line. */ - const char *LogGOPS_G_help; /**< @brief The gap per byte parameter G in the LogGP model help description. */ - int LogGOPS_S_arg; /**< @brief Datasize at which we change from eager to rendezvous protocol (default='65535'). */ - char * LogGOPS_S_orig; /**< @brief Datasize at which we change from eager to rendezvous protocol original value given at command line. */ - const char *LogGOPS_S_help; /**< @brief Datasize at which we change from eager to rendezvous protocol help description. */ - int LogGOPS_O_arg; /**< @brief The overhead per byte in LogGOP (default='0'). */ - char * LogGOPS_O_orig; /**< @brief The overhead per byte in LogGOP original value given at command line. */ - const char *LogGOPS_O_help; /**< @brief The overhead per byte in LogGOP help description. */ - char * vizfile_arg; /**< @brief Name of the output file for visualization data. */ - char * vizfile_orig; /**< @brief Name of the output file for visualization data original value given at command line. */ - const char *vizfile_help; /**< @brief Name of the output file for visualization data help description. */ - const char *verbose_help; /**< @brief Enable more verbose output help description. */ - const char *progress_help; /**< @brief print progress help description. */ - const char *batchmode_help; /**< @brief enable batchmode (never print detailed host info) help description. */ - char * noise_trace_arg; /**< @brief Read Noise from trace . */ - char * noise_trace_orig; /**< @brief Read Noise from trace original value given at command line. */ - const char *noise_trace_help; /**< @brief Read Noise from trace help description. */ - int noise_cosched_flag; /**< @brief Co-schedule noise (use same starttime on all processes) (default=off). */ - const char *noise_cosched_help; /**< @brief Co-schedule noise (use same starttime on all processes) help description. */ - char * network_type_arg; /**< @brief Network type (LogGP=no network congestion; simple=simple linear model) (default='LogGP'). */ - char * network_type_orig; /**< @brief Network type (LogGP=no network congestion; simple=simple linear model) original value given at command line. */ - const char *network_type_help; /**< @brief Network type (LogGP=no network congestion; simple=simple linear model) help description. */ - char * network_file_arg; /**< @brief Input file for network (annotated dot format). */ - char * network_file_orig; /**< @brief Input file for network (annotated dot format) original value given at command line. */ - const char *network_file_help; /**< @brief Input file for network (annotated dot format) help description. */ - char * qstat_arg; /**< @brief Enable PQ and UQ statistics. Argument is output filename prefix (default='Unknown'). */ - char * qstat_orig; /**< @brief Enable PQ and UQ statistics. Argument is output filename prefix original value given at command line. */ - const char *qstat_help; /**< @brief Enable PQ and UQ statistics. Argument is output filename prefix help description. */ - - unsigned int help_given ; /**< @brief Whether help was given. */ - unsigned int version_given ; /**< @brief Whether version was given. */ - unsigned int filename_given ; /**< @brief Whether filename was given. */ - unsigned int save_mem_given ; /**< @brief Whether save-mem was given. */ - unsigned int LogGOPS_L_given ; /**< @brief Whether LogGOPS_L was given. */ - unsigned int LogGOPS_o_given ; /**< @brief Whether LogGOPS_o was given. */ - unsigned int LogGOPS_g_given ; /**< @brief Whether LogGOPS_g was given. */ - unsigned int LogGOPS_G_given ; /**< @brief Whether LogGOPS_G was given. */ - unsigned int LogGOPS_S_given ; /**< @brief Whether LogGOPS_S was given. */ - unsigned int LogGOPS_O_given ; /**< @brief Whether LogGOPS_O was given. */ - unsigned int vizfile_given ; /**< @brief Whether vizfile was given. */ - unsigned int verbose_given ; /**< @brief Whether verbose was given. */ - unsigned int progress_given ; /**< @brief Whether progress was given. */ - unsigned int batchmode_given ; /**< @brief Whether batchmode was given. */ - unsigned int noise_trace_given ; /**< @brief Whether noise-trace was given. */ - unsigned int noise_cosched_given ; /**< @brief Whether noise-cosched was given. */ - unsigned int network_type_given ; /**< @brief Whether network-type was given. */ - unsigned int network_file_given ; /**< @brief Whether network-file was given. */ - unsigned int qstat_given ; /**< @brief Whether qstat was given. */ - -} ; - -/** @brief The additional parameters to pass to parser functions */ -struct cmdline_parser_params -{ - int override; /**< @brief whether to override possibly already present options (default 0) */ - int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ - int check_required; /**< @brief whether to check that all required options were provided (default 1) */ - int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ - int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ -} ; - -/** @brief the purpose string of the program */ -extern const char *gengetopt_args_info_purpose; -/** @brief the usage string of the program */ -extern const char *gengetopt_args_info_usage; -/** @brief the description string of the program */ -extern const char *gengetopt_args_info_description; -/** @brief all the lines making the help output */ -extern const char *gengetopt_args_info_help[]; - -/** - * The command line parser - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser (int argc, char **argv, - struct gengetopt_args_info *args_info); - -/** - * The command line parser (version with additional parameters - deprecated) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param override whether to override possibly already present options - * @param initialize whether to initialize the option structure my_args_info - * @param check_required whether to check that all required options were provided - * @return 0 if everything went fine, NON 0 if an error took place - * @deprecated use cmdline_parser_ext() instead - */ -int cmdline_parser2 (int argc, char **argv, - struct gengetopt_args_info *args_info, - int override, int initialize, int check_required); - -/** - * The command line parser (version with additional parameters) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param params additional parameters for the parser - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_ext (int argc, char **argv, - struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params); - -/** - * Save the contents of the option struct into an already open FILE stream. - * @param outfile the stream where to dump options - * @param args_info the option struct to dump - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_dump(FILE *outfile, - struct gengetopt_args_info *args_info); - -/** - * Save the contents of the option struct into a (text) file. - * This file can be read by the config file parser (if generated by gengetopt) - * @param filename the file where to save - * @param args_info the option struct to save - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_file_save(const char *filename, - struct gengetopt_args_info *args_info); - -/** - * Print the help - */ -void cmdline_parser_print_help(void); -/** - * Print the version - */ -void cmdline_parser_print_version(void); - -/** - * Initializes all the fields a cmdline_parser_params structure - * to their default values - * @param params the structure to initialize - */ -void cmdline_parser_params_init(struct cmdline_parser_params *params); - -/** - * Allocates dynamically a cmdline_parser_params structure and initializes - * all its fields to their default values - * @return the created and initialized cmdline_parser_params structure - */ -struct cmdline_parser_params *cmdline_parser_params_create(void); - -/** - * Initializes the passed gengetopt_args_info structure's fields - * (also set default values for options that have a default) - * @param args_info the structure to initialize - */ -void cmdline_parser_init (struct gengetopt_args_info *args_info); -/** - * Deallocates the string fields of the gengetopt_args_info structure - * (but does not deallocate the structure itself) - * @param args_info the structure to deallocate - */ -void cmdline_parser_free (struct gengetopt_args_info *args_info); - -/** - * Checks that all the required options were specified - * @param args_info the structure to check - * @param prog_name the name of the program that will be used to print - * possible errors - * @return - */ -int cmdline_parser_required (struct gengetopt_args_info *args_info, - const char *prog_name); - -extern const char *cmdline_parser_network_type_values[]; /**< @brief Possible values for network-type. */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* LOGGOPSIM_CMDLINE_H */ diff --git a/src/LogGOPSim/txt2bin_cmdline.c b/src/LogGOPSim/txt2bin_cmdline.c deleted file mode 100644 index a3a3709..0000000 --- a/src/LogGOPSim/txt2bin_cmdline.c +++ /dev/null @@ -1,600 +0,0 @@ -/* - File autogenerated by gengetopt version 2.23 - generated with the following command: - gengetopt -F txt2bin_cmdline -i /Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin_cmdline.ggo --output-dir /Users/tim0s/Work/LogGOPSim/src/LogGOPSim - - The developers of gengetopt consider the fixed text that goes in all - gengetopt output files to be in the public domain: - we make no copyright claims on it. -*/ - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#ifndef FIX_UNUSED -#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ -#endif - -#include - -#include "txt2bin_cmdline.h" - -const char *gengetopt_args_info_purpose = ""; - -const char *gengetopt_args_info_usage = "Usage: goalsim [OPTION]..."; - -const char *gengetopt_args_info_versiontext = ""; - -const char *gengetopt_args_info_description = ""; - -const char *gengetopt_args_info_help[] = { - " -h, --help Print help and exit", - " -V, --version Print version and exit", - " -i, --input=filename Input file, textfile containing GOAL schedules", - " -o, --output=filename Output file, will contain the binary representation of\n the GOAL schedules", - " -p, --progress Print progress information while parsing the schedule\n (default=off)", - 0 -}; - -typedef enum {ARG_NO - , ARG_FLAG - , ARG_STRING -} cmdline_parser_arg_type; - -static -void clear_given (struct gengetopt_args_info *args_info); -static -void clear_args (struct gengetopt_args_info *args_info); - -static int -cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error); - -static int -cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); - -static char * -gengetopt_strdup (const char *s); - -static -void clear_given (struct gengetopt_args_info *args_info) -{ - args_info->help_given = 0 ; - args_info->version_given = 0 ; - args_info->input_given = 0 ; - args_info->output_given = 0 ; - args_info->progress_given = 0 ; -} - -static -void clear_args (struct gengetopt_args_info *args_info) -{ - FIX_UNUSED (args_info); - args_info->input_arg = NULL; - args_info->input_orig = NULL; - args_info->output_arg = NULL; - args_info->output_orig = NULL; - args_info->progress_flag = 0; - -} - -static -void init_args_info(struct gengetopt_args_info *args_info) -{ - - - args_info->help_help = gengetopt_args_info_help[0] ; - args_info->version_help = gengetopt_args_info_help[1] ; - args_info->input_help = gengetopt_args_info_help[2] ; - args_info->output_help = gengetopt_args_info_help[3] ; - args_info->progress_help = gengetopt_args_info_help[4] ; - -} - -void -cmdline_parser_print_version (void) -{ - printf ("%s %s\n", - (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), - CMDLINE_PARSER_VERSION); - - if (strlen(gengetopt_args_info_versiontext) > 0) - printf("\n%s\n", gengetopt_args_info_versiontext); -} - -static void print_help_common(void) -{ - size_t len_purpose = strlen(gengetopt_args_info_purpose); - size_t len_usage = strlen(gengetopt_args_info_usage); - - if (len_usage > 0) { - printf("%s\n", gengetopt_args_info_usage); - } - if (len_purpose > 0) { - printf("%s\n", gengetopt_args_info_purpose); - } - - if (len_usage || len_purpose) { - printf("\n"); - } - - if (strlen(gengetopt_args_info_description) > 0) { - printf("%s\n\n", gengetopt_args_info_description); - } -} - -void -cmdline_parser_print_help (void) -{ - int i = 0; - print_help_common(); - while (gengetopt_args_info_help[i]) - printf("%s\n", gengetopt_args_info_help[i++]); -} - -void -cmdline_parser_init (struct gengetopt_args_info *args_info) -{ - clear_given (args_info); - clear_args (args_info); - init_args_info (args_info); -} - -void -cmdline_parser_params_init(struct cmdline_parser_params *params) -{ - if (params) - { - params->override = 0; - params->initialize = 1; - params->check_required = 1; - params->check_ambiguity = 0; - params->print_errors = 1; - } -} - -struct cmdline_parser_params * -cmdline_parser_params_create(void) -{ - struct cmdline_parser_params *params = - (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); - return params; -} - -static void -free_string_field (char **s) -{ - if (*s) - { - free (*s); - *s = 0; - } -} - - -static void -cmdline_parser_release (struct gengetopt_args_info *args_info) -{ - - free_string_field (&(args_info->input_arg)); - free_string_field (&(args_info->input_orig)); - free_string_field (&(args_info->output_arg)); - free_string_field (&(args_info->output_orig)); - - - - clear_given (args_info); -} - - -static void -write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) -{ - FIX_UNUSED (values); - if (arg) { - fprintf(outfile, "%s=\"%s\"\n", opt, arg); - } else { - fprintf(outfile, "%s\n", opt); - } -} - - -int -cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) -{ - int i = 0; - - if (!outfile) - { - fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); - return EXIT_FAILURE; - } - - if (args_info->help_given) - write_into_file(outfile, "help", 0, 0 ); - if (args_info->version_given) - write_into_file(outfile, "version", 0, 0 ); - if (args_info->input_given) - write_into_file(outfile, "input", args_info->input_orig, 0); - if (args_info->output_given) - write_into_file(outfile, "output", args_info->output_orig, 0); - if (args_info->progress_given) - write_into_file(outfile, "progress", 0, 0 ); - - - i = EXIT_SUCCESS; - return i; -} - -int -cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) -{ - FILE *outfile; - int i = 0; - - outfile = fopen(filename, "w"); - - if (!outfile) - { - fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); - return EXIT_FAILURE; - } - - i = cmdline_parser_dump(outfile, args_info); - fclose (outfile); - - return i; -} - -void -cmdline_parser_free (struct gengetopt_args_info *args_info) -{ - cmdline_parser_release (args_info); -} - -/** @brief replacement of strdup, which is not standard */ -char * -gengetopt_strdup (const char *s) -{ - char *result = 0; - if (!s) - return result; - - result = (char*)malloc(strlen(s) + 1); - if (result == (char*)0) - return (char*)0; - strcpy(result, s); - return result; -} - -int -cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) -{ - return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); -} - -int -cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params) -{ - int result; - result = cmdline_parser_internal (argc, argv, args_info, params, 0); - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) -{ - int result; - struct cmdline_parser_params params; - - params.override = override; - params.initialize = initialize; - params.check_required = check_required; - params.check_ambiguity = 0; - params.print_errors = 1; - - result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) -{ - int result = EXIT_SUCCESS; - - if (cmdline_parser_required2(args_info, prog_name, 0) > 0) - result = EXIT_FAILURE; - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) -{ - int error_occurred = 0; - FIX_UNUSED (additional_error); - - /* checks for required options */ - if (! args_info->input_given) - { - fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); - error_occurred = 1; - } - - if (! args_info->output_given) - { - fprintf (stderr, "%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error : "")); - error_occurred = 1; - } - - - /* checks for dependences among options */ - - return error_occurred; -} - - -static char *package_name = 0; - -/** - * @brief updates an option - * @param field the generic pointer to the field to update - * @param orig_field the pointer to the orig field - * @param field_given the pointer to the number of occurrence of this option - * @param prev_given the pointer to the number of occurrence already seen - * @param value the argument for this option (if null no arg was specified) - * @param possible_values the possible values for this option (if specified) - * @param default_value the default value (in case the option only accepts fixed values) - * @param arg_type the type of this option - * @param check_ambiguity @see cmdline_parser_params.check_ambiguity - * @param override @see cmdline_parser_params.override - * @param no_free whether to free a possible previous value - * @param multiple_option whether this is a multiple option - * @param long_opt the corresponding long option - * @param short_opt the corresponding short option (or '-' if none) - * @param additional_error possible further error specification - */ -static -int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, - char *value, const char *possible_values[], - const char *default_value, - cmdline_parser_arg_type arg_type, - int check_ambiguity, int override, - int no_free, int multiple_option, - const char *long_opt, char short_opt, - const char *additional_error) -{ - char *stop_char = 0; - const char *val = value; - int found; - char **string_field; - FIX_UNUSED (field); - - stop_char = 0; - found = 0; - - if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) - { - if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", - package_name, long_opt, short_opt, - (additional_error ? additional_error : "")); - else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", - package_name, long_opt, - (additional_error ? additional_error : "")); - return 1; /* failure */ - } - - FIX_UNUSED (default_value); - - if (field_given && *field_given && ! override) - return 0; - if (prev_given) - (*prev_given)++; - if (field_given) - (*field_given)++; - if (possible_values) - val = possible_values[found]; - - switch(arg_type) { - case ARG_FLAG: - *((int *)field) = !*((int *)field); - break; - case ARG_STRING: - if (val) { - string_field = (char **)field; - if (!no_free && *string_field) - free (*string_field); /* free previous string */ - *string_field = gengetopt_strdup (val); - } - break; - default: - break; - }; - - FIX_UNUSED(stop_char); - - /* store the original value */ - switch(arg_type) { - case ARG_NO: - case ARG_FLAG: - break; - default: - if (value && orig_field) { - if (no_free) { - *orig_field = value; - } else { - if (*orig_field) - free (*orig_field); /* free previous string */ - *orig_field = gengetopt_strdup (value); - } - } - }; - - return 0; /* OK */ -} - - -int -cmdline_parser_internal ( - int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error) -{ - int c; /* Character of the parsed option. */ - - int error_occurred = 0; - struct gengetopt_args_info local_args_info; - - int override; - int initialize; - int check_required; - int check_ambiguity; - - package_name = argv[0]; - - /* TODO: Why is this here? It is not used anywhere. */ - override = params->override; - FIX_UNUSED(override); - - initialize = params->initialize; - check_required = params->check_required; - - /* TODO: Why is this here? It is not used anywhere. */ - check_ambiguity = params->check_ambiguity; - FIX_UNUSED(check_ambiguity); - - if (initialize) - cmdline_parser_init (args_info); - - cmdline_parser_init (&local_args_info); - - optarg = 0; - optind = 0; - opterr = params->print_errors; - optopt = '?'; - - while (1) - { - int option_index = 0; - - static struct option long_options[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, - { "input", 1, NULL, 'i' }, - { "output", 1, NULL, 'o' }, - { "progress", 0, NULL, 'p' }, - { 0, 0, 0, 0 } - }; - - c = getopt_long (argc, argv, "hVi:o:p", long_options, &option_index); - - if (c == -1) break; /* Exit from `while (1)' loop. */ - - switch (c) - { - case 'h': /* Print help and exit. */ - cmdline_parser_print_help (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); - - case 'V': /* Print version and exit. */ - cmdline_parser_print_version (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); - - case 'i': /* Input file, textfile containing GOAL schedules. */ - - - if (update_arg( (void *)&(args_info->input_arg), - &(args_info->input_orig), &(args_info->input_given), - &(local_args_info.input_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "input", 'i', - additional_error)) - goto failure; - - break; - case 'o': /* Output file, will contain the binary representation of the GOAL schedules. */ - - - if (update_arg( (void *)&(args_info->output_arg), - &(args_info->output_orig), &(args_info->output_given), - &(local_args_info.output_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "output", 'o', - additional_error)) - goto failure; - - break; - case 'p': /* Print progress information while parsing the schedule. */ - - - if (update_arg((void *)&(args_info->progress_flag), 0, &(args_info->progress_given), - &(local_args_info.progress_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "progress", 'p', - additional_error)) - goto failure; - - break; - - case 0: /* Long option with no short option */ - case '?': /* Invalid option. */ - /* `getopt_long' already printed an error message. */ - goto failure; - - default: /* bug: option not considered. */ - fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); - abort (); - } /* switch */ - } /* while */ - - - - if (check_required) - { - error_occurred += cmdline_parser_required2 (args_info, argv[0], additional_error); - } - - cmdline_parser_release (&local_args_info); - - if ( error_occurred ) - return (EXIT_FAILURE); - - return 0; - -failure: - - cmdline_parser_release (&local_args_info); - return (EXIT_FAILURE); -} -/* vim: set ft=c noet ts=8 sts=8 sw=8 tw=80 nojs spell : */ diff --git a/src/LogGOPSim/txt2bin_cmdline.h b/src/LogGOPSim/txt2bin_cmdline.h deleted file mode 100644 index 065e24e..0000000 --- a/src/LogGOPSim/txt2bin_cmdline.h +++ /dev/null @@ -1,184 +0,0 @@ -/** @file txt2bin_cmdline.h - * @brief The header file for the command line option parser - * generated by GNU Gengetopt version 2.23 - * http://www.gnu.org/software/gengetopt. - * DO NOT modify this file, since it can be overwritten - * @author GNU Gengetopt */ - -#ifndef TXT2BIN_CMDLINE_H -#define TXT2BIN_CMDLINE_H - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include /* for FILE */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef CMDLINE_PARSER_PACKAGE -/** @brief the program name (used for printing errors) */ -#define CMDLINE_PARSER_PACKAGE "goalsim" -#endif - -#ifndef CMDLINE_PARSER_PACKAGE_NAME -/** @brief the complete program name (used for help and version) */ -#define CMDLINE_PARSER_PACKAGE_NAME "goalsim" -#endif - -#ifndef CMDLINE_PARSER_VERSION -/** @brief the program version */ -#define CMDLINE_PARSER_VERSION "0.1" -#endif - -/** @brief Where the command line options are stored */ -struct gengetopt_args_info -{ - const char *help_help; /**< @brief Print help and exit help description. */ - const char *version_help; /**< @brief Print version and exit help description. */ - char * input_arg; /**< @brief Input file, textfile containing GOAL schedules. */ - char * input_orig; /**< @brief Input file, textfile containing GOAL schedules original value given at command line. */ - const char *input_help; /**< @brief Input file, textfile containing GOAL schedules help description. */ - char * output_arg; /**< @brief Output file, will contain the binary representation of the GOAL schedules. */ - char * output_orig; /**< @brief Output file, will contain the binary representation of the GOAL schedules original value given at command line. */ - const char *output_help; /**< @brief Output file, will contain the binary representation of the GOAL schedules help description. */ - int progress_flag; /**< @brief Print progress information while parsing the schedule (default=off). */ - const char *progress_help; /**< @brief Print progress information while parsing the schedule help description. */ - - unsigned int help_given ; /**< @brief Whether help was given. */ - unsigned int version_given ; /**< @brief Whether version was given. */ - unsigned int input_given ; /**< @brief Whether input was given. */ - unsigned int output_given ; /**< @brief Whether output was given. */ - unsigned int progress_given ; /**< @brief Whether progress was given. */ - -} ; - -/** @brief The additional parameters to pass to parser functions */ -struct cmdline_parser_params -{ - int override; /**< @brief whether to override possibly already present options (default 0) */ - int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ - int check_required; /**< @brief whether to check that all required options were provided (default 1) */ - int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ - int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ -} ; - -/** @brief the purpose string of the program */ -extern const char *gengetopt_args_info_purpose; -/** @brief the usage string of the program */ -extern const char *gengetopt_args_info_usage; -/** @brief the description string of the program */ -extern const char *gengetopt_args_info_description; -/** @brief all the lines making the help output */ -extern const char *gengetopt_args_info_help[]; - -/** - * The command line parser - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser (int argc, char **argv, - struct gengetopt_args_info *args_info); - -/** - * The command line parser (version with additional parameters - deprecated) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param override whether to override possibly already present options - * @param initialize whether to initialize the option structure my_args_info - * @param check_required whether to check that all required options were provided - * @return 0 if everything went fine, NON 0 if an error took place - * @deprecated use cmdline_parser_ext() instead - */ -int cmdline_parser2 (int argc, char **argv, - struct gengetopt_args_info *args_info, - int override, int initialize, int check_required); - -/** - * The command line parser (version with additional parameters) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param params additional parameters for the parser - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_ext (int argc, char **argv, - struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params); - -/** - * Save the contents of the option struct into an already open FILE stream. - * @param outfile the stream where to dump options - * @param args_info the option struct to dump - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_dump(FILE *outfile, - struct gengetopt_args_info *args_info); - -/** - * Save the contents of the option struct into a (text) file. - * This file can be read by the config file parser (if generated by gengetopt) - * @param filename the file where to save - * @param args_info the option struct to save - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_file_save(const char *filename, - struct gengetopt_args_info *args_info); - -/** - * Print the help - */ -void cmdline_parser_print_help(void); -/** - * Print the version - */ -void cmdline_parser_print_version(void); - -/** - * Initializes all the fields a cmdline_parser_params structure - * to their default values - * @param params the structure to initialize - */ -void cmdline_parser_params_init(struct cmdline_parser_params *params); - -/** - * Allocates dynamically a cmdline_parser_params structure and initializes - * all its fields to their default values - * @return the created and initialized cmdline_parser_params structure - */ -struct cmdline_parser_params *cmdline_parser_params_create(void); - -/** - * Initializes the passed gengetopt_args_info structure's fields - * (also set default values for options that have a default) - * @param args_info the structure to initialize - */ -void cmdline_parser_init (struct gengetopt_args_info *args_info); -/** - * Deallocates the string fields of the gengetopt_args_info structure - * (but does not deallocate the structure itself) - * @param args_info the structure to deallocate - */ -void cmdline_parser_free (struct gengetopt_args_info *args_info); - -/** - * Checks that all the required options were specified - * @param args_info the structure to check - * @param prog_name the name of the program that will be used to print - * possible errors - * @return - */ -int cmdline_parser_required (struct gengetopt_args_info *args_info, - const char *prog_name); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* TXT2BIN_CMDLINE_H */ diff --git a/src/Schedgen/schedgen_cmdline.c b/src/Schedgen/schedgen_cmdline.c deleted file mode 100644 index 7b00db4..0000000 --- a/src/Schedgen/schedgen_cmdline.c +++ /dev/null @@ -1,1060 +0,0 @@ -/* - File autogenerated by gengetopt version 2.23 - generated with the following command: - gengetopt -F schedgen_cmdline -i /Users/tim0s/Work/LogGOPSim/src/Schedgen/schedgen_cmdline.ggo --output-dir /Users/tim0s/Work/LogGOPSim/src/Schedgen - - The developers of gengetopt consider the fixed text that goes in all - gengetopt output files to be in the public domain: - we make no copyright claims on it. -*/ - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#ifndef FIX_UNUSED -#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ -#endif - -#include - -#include "schedgen_cmdline.h" - -const char *gengetopt_args_info_purpose = ""; - -const char *gengetopt_args_info_usage = "Usage: schedgen [OPTION]..."; - -const char *gengetopt_args_info_versiontext = ""; - -const char *gengetopt_args_info_description = ""; - -const char *gengetopt_args_info_help[] = { - " -h, --help Print help and exit", - " -V, --version Print version and exit", - " -p, --ptrn=STRING Name of the communication pattern that should be\n used to generate a schedule (possible\n values=\"binomialtreereduce\",\n \"binarytreebcast\", \"binomialtreebcast\",\n \"nwaydissemination\", \"pipelinedring\",\n \"pipelinedringdep\", \"doublering\",\n \"gather\", \"scatter\", \"linbarrier\",\n \"trace\", \"dissemination\", \"random_bisect\",\n \"random_bisect_fd_sym\", \"linear_alltoall\",\n \"linear_alltoallv\", \"allreduce_recdoub\",\n \"allreduce_ring\", \"resnet\",\n \"chained_dissem\" default=`binomialtreebcast')", - " -s, --commsize=INT Number of nodes that should be used in the\n communication pattern (default=`8')", - " --timemult=INT Time multiplier, relative to microsecond (e.g.,\n nanoseconds -> 1000) (default=`1000')", - " -d, --datasize=INT Number of bytes that are transmitted in the\n communication patttern in a basic step\n (default=`1')", - " -o, --filename=STRING Filename for the name of the generated schedule\n (default=`schedule.goal')", - " --nway=INT Fanout for the n-way dissemination pattern\n (default=`1')", - " --root=INT Root node for certain patterns (default=`0')", - " --segmentsize=INT Segment size for pipelined pattern (default=`1')", - " --nb=INT nonblocking execution of collectives (provide\n length of local operation) (default=`0')", - " --nb-poll=INT polling interval for nonblocking execution\n (default=`0')", - " --cpu=INT select CPU to execute computation (default=`0')", - " --rpl-dep-cmp=INT replaces dependencies with fixed computation\n (parameter represents computation time. If -1,\n does not replace dependencies.) (default=`-1')", - " --a2av-skew-ratio=INT In the alltoallv pattern, each chunk of data sent\n by each rank is of a random size. The size of\n the chunk with id 'root' is of size 'datasize'.\n All the other chunks are of random size, and\n a2av-skew-ratio times smaller. (default=`1')", - " --outcast Generates outcast in the alltoallv pattern.\n (default=off)", - " --traces=STRING Tracefile for rank 0 (others are autodetected)", - " --traces-start=STRING file with start lines in trace files (is updated\n after run if trace-nops is given)", - " --traces-nops=INT number of operations to write to file (0=all)\n (default=`0')", - " --traces-extr=INT extrapolation factor for traces (default=`1')", - " --traces-print=INT print each operation (default=`0')", - " --traces-nop2p do not consider point-to-point communication\n (default=off)", - " --traces-nocolls do not consider collective communication\n (default=off)", - " --traces-nbcify=INT turn blocking collectives into non-blocking colls,\n time to pre-post NBCs (default=`0')", - 0 -}; - -typedef enum {ARG_NO - , ARG_FLAG - , ARG_STRING - , ARG_INT -} cmdline_parser_arg_type; - -static -void clear_given (struct gengetopt_args_info *args_info); -static -void clear_args (struct gengetopt_args_info *args_info); - -static int -cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error); - - -const char *cmdline_parser_ptrn_values[] = {"binomialtreereduce", "binarytreebcast", "binomialtreebcast", "nwaydissemination", "pipelinedring", "pipelinedringdep", "doublering", "gather", "scatter", "linbarrier", "trace", "dissemination", "random_bisect", "random_bisect_fd_sym", "linear_alltoall", "linear_alltoallv", "allreduce_recdoub", "allreduce_ring", "resnet", "chained_dissem", 0}; /*< Possible values for ptrn. */ - -static char * -gengetopt_strdup (const char *s); - -static -void clear_given (struct gengetopt_args_info *args_info) -{ - args_info->help_given = 0 ; - args_info->version_given = 0 ; - args_info->ptrn_given = 0 ; - args_info->commsize_given = 0 ; - args_info->timemult_given = 0 ; - args_info->datasize_given = 0 ; - args_info->filename_given = 0 ; - args_info->nway_given = 0 ; - args_info->root_given = 0 ; - args_info->segmentsize_given = 0 ; - args_info->nb_given = 0 ; - args_info->nb_poll_given = 0 ; - args_info->cpu_given = 0 ; - args_info->rpl_dep_cmp_given = 0 ; - args_info->a2av_skew_ratio_given = 0 ; - args_info->outcast_given = 0 ; - args_info->traces_given = 0 ; - args_info->traces_start_given = 0 ; - args_info->traces_nops_given = 0 ; - args_info->traces_extr_given = 0 ; - args_info->traces_print_given = 0 ; - args_info->traces_nop2p_given = 0 ; - args_info->traces_nocolls_given = 0 ; - args_info->traces_nbcify_given = 0 ; -} - -static -void clear_args (struct gengetopt_args_info *args_info) -{ - FIX_UNUSED (args_info); - args_info->ptrn_arg = gengetopt_strdup ("binomialtreebcast"); - args_info->ptrn_orig = NULL; - args_info->commsize_arg = 8; - args_info->commsize_orig = NULL; - args_info->timemult_arg = 1000; - args_info->timemult_orig = NULL; - args_info->datasize_arg = 1; - args_info->datasize_orig = NULL; - args_info->filename_arg = gengetopt_strdup ("schedule.goal"); - args_info->filename_orig = NULL; - args_info->nway_arg = 1; - args_info->nway_orig = NULL; - args_info->root_arg = 0; - args_info->root_orig = NULL; - args_info->segmentsize_arg = 1; - args_info->segmentsize_orig = NULL; - args_info->nb_arg = 0; - args_info->nb_orig = NULL; - args_info->nb_poll_arg = 0; - args_info->nb_poll_orig = NULL; - args_info->cpu_arg = 0; - args_info->cpu_orig = NULL; - args_info->rpl_dep_cmp_arg = -1; - args_info->rpl_dep_cmp_orig = NULL; - args_info->a2av_skew_ratio_arg = 1; - args_info->a2av_skew_ratio_orig = NULL; - args_info->outcast_flag = 0; - args_info->traces_arg = NULL; - args_info->traces_orig = NULL; - args_info->traces_start_arg = NULL; - args_info->traces_start_orig = NULL; - args_info->traces_nops_arg = 0; - args_info->traces_nops_orig = NULL; - args_info->traces_extr_arg = 1; - args_info->traces_extr_orig = NULL; - args_info->traces_print_arg = 0; - args_info->traces_print_orig = NULL; - args_info->traces_nop2p_flag = 0; - args_info->traces_nocolls_flag = 0; - args_info->traces_nbcify_arg = 0; - args_info->traces_nbcify_orig = NULL; - -} - -static -void init_args_info(struct gengetopt_args_info *args_info) -{ - - - args_info->help_help = gengetopt_args_info_help[0] ; - args_info->version_help = gengetopt_args_info_help[1] ; - args_info->ptrn_help = gengetopt_args_info_help[2] ; - args_info->commsize_help = gengetopt_args_info_help[3] ; - args_info->timemult_help = gengetopt_args_info_help[4] ; - args_info->datasize_help = gengetopt_args_info_help[5] ; - args_info->filename_help = gengetopt_args_info_help[6] ; - args_info->nway_help = gengetopt_args_info_help[7] ; - args_info->root_help = gengetopt_args_info_help[8] ; - args_info->segmentsize_help = gengetopt_args_info_help[9] ; - args_info->nb_help = gengetopt_args_info_help[10] ; - args_info->nb_poll_help = gengetopt_args_info_help[11] ; - args_info->cpu_help = gengetopt_args_info_help[12] ; - args_info->rpl_dep_cmp_help = gengetopt_args_info_help[13] ; - args_info->a2av_skew_ratio_help = gengetopt_args_info_help[14] ; - args_info->outcast_help = gengetopt_args_info_help[15] ; - args_info->traces_help = gengetopt_args_info_help[16] ; - args_info->traces_start_help = gengetopt_args_info_help[17] ; - args_info->traces_nops_help = gengetopt_args_info_help[18] ; - args_info->traces_extr_help = gengetopt_args_info_help[19] ; - args_info->traces_print_help = gengetopt_args_info_help[20] ; - args_info->traces_nop2p_help = gengetopt_args_info_help[21] ; - args_info->traces_nocolls_help = gengetopt_args_info_help[22] ; - args_info->traces_nbcify_help = gengetopt_args_info_help[23] ; - -} - -void -cmdline_parser_print_version (void) -{ - printf ("%s %s\n", - (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), - CMDLINE_PARSER_VERSION); - - if (strlen(gengetopt_args_info_versiontext) > 0) - printf("\n%s\n", gengetopt_args_info_versiontext); -} - -static void print_help_common(void) -{ - size_t len_purpose = strlen(gengetopt_args_info_purpose); - size_t len_usage = strlen(gengetopt_args_info_usage); - - if (len_usage > 0) { - printf("%s\n", gengetopt_args_info_usage); - } - if (len_purpose > 0) { - printf("%s\n", gengetopt_args_info_purpose); - } - - if (len_usage || len_purpose) { - printf("\n"); - } - - if (strlen(gengetopt_args_info_description) > 0) { - printf("%s\n\n", gengetopt_args_info_description); - } -} - -void -cmdline_parser_print_help (void) -{ - int i = 0; - print_help_common(); - while (gengetopt_args_info_help[i]) - printf("%s\n", gengetopt_args_info_help[i++]); -} - -void -cmdline_parser_init (struct gengetopt_args_info *args_info) -{ - clear_given (args_info); - clear_args (args_info); - init_args_info (args_info); -} - -void -cmdline_parser_params_init(struct cmdline_parser_params *params) -{ - if (params) - { - params->override = 0; - params->initialize = 1; - params->check_required = 1; - params->check_ambiguity = 0; - params->print_errors = 1; - } -} - -struct cmdline_parser_params * -cmdline_parser_params_create(void) -{ - struct cmdline_parser_params *params = - (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); - return params; -} - -static void -free_string_field (char **s) -{ - if (*s) - { - free (*s); - *s = 0; - } -} - - -static void -cmdline_parser_release (struct gengetopt_args_info *args_info) -{ - - free_string_field (&(args_info->ptrn_arg)); - free_string_field (&(args_info->ptrn_orig)); - free_string_field (&(args_info->commsize_orig)); - free_string_field (&(args_info->timemult_orig)); - free_string_field (&(args_info->datasize_orig)); - free_string_field (&(args_info->filename_arg)); - free_string_field (&(args_info->filename_orig)); - free_string_field (&(args_info->nway_orig)); - free_string_field (&(args_info->root_orig)); - free_string_field (&(args_info->segmentsize_orig)); - free_string_field (&(args_info->nb_orig)); - free_string_field (&(args_info->nb_poll_orig)); - free_string_field (&(args_info->cpu_orig)); - free_string_field (&(args_info->rpl_dep_cmp_orig)); - free_string_field (&(args_info->a2av_skew_ratio_orig)); - free_string_field (&(args_info->traces_arg)); - free_string_field (&(args_info->traces_orig)); - free_string_field (&(args_info->traces_start_arg)); - free_string_field (&(args_info->traces_start_orig)); - free_string_field (&(args_info->traces_nops_orig)); - free_string_field (&(args_info->traces_extr_orig)); - free_string_field (&(args_info->traces_print_orig)); - free_string_field (&(args_info->traces_nbcify_orig)); - - - - clear_given (args_info); -} - -/** - * @param val the value to check - * @param values the possible values - * @return the index of the matched value: - * -1 if no value matched, - * -2 if more than one value has matched - */ -static int -check_possible_values(const char *val, const char *values[]) -{ - int i, found, last; - size_t len; - - if (!val) /* otherwise strlen() crashes below */ - return -1; /* -1 means no argument for the option */ - - found = last = 0; - - for (i = 0, len = strlen(val); values[i]; ++i) - { - if (strncmp(val, values[i], len) == 0) - { - ++found; - last = i; - if (strlen(values[i]) == len) - return i; /* exact macth no need to check more */ - } - } - - if (found == 1) /* one match: OK */ - return last; - - return (found ? -2 : -1); /* return many values or none matched */ -} - - -static void -write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) -{ - int found = -1; - if (arg) { - if (values) { - found = check_possible_values(arg, values); - } - if (found >= 0) - fprintf(outfile, "%s=\"%s\" # %s\n", opt, arg, values[found]); - else - fprintf(outfile, "%s=\"%s\"\n", opt, arg); - } else { - fprintf(outfile, "%s\n", opt); - } -} - - -int -cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) -{ - int i = 0; - - if (!outfile) - { - fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); - return EXIT_FAILURE; - } - - if (args_info->help_given) - write_into_file(outfile, "help", 0, 0 ); - if (args_info->version_given) - write_into_file(outfile, "version", 0, 0 ); - if (args_info->ptrn_given) - write_into_file(outfile, "ptrn", args_info->ptrn_orig, cmdline_parser_ptrn_values); - if (args_info->commsize_given) - write_into_file(outfile, "commsize", args_info->commsize_orig, 0); - if (args_info->timemult_given) - write_into_file(outfile, "timemult", args_info->timemult_orig, 0); - if (args_info->datasize_given) - write_into_file(outfile, "datasize", args_info->datasize_orig, 0); - if (args_info->filename_given) - write_into_file(outfile, "filename", args_info->filename_orig, 0); - if (args_info->nway_given) - write_into_file(outfile, "nway", args_info->nway_orig, 0); - if (args_info->root_given) - write_into_file(outfile, "root", args_info->root_orig, 0); - if (args_info->segmentsize_given) - write_into_file(outfile, "segmentsize", args_info->segmentsize_orig, 0); - if (args_info->nb_given) - write_into_file(outfile, "nb", args_info->nb_orig, 0); - if (args_info->nb_poll_given) - write_into_file(outfile, "nb-poll", args_info->nb_poll_orig, 0); - if (args_info->cpu_given) - write_into_file(outfile, "cpu", args_info->cpu_orig, 0); - if (args_info->rpl_dep_cmp_given) - write_into_file(outfile, "rpl-dep-cmp", args_info->rpl_dep_cmp_orig, 0); - if (args_info->a2av_skew_ratio_given) - write_into_file(outfile, "a2av-skew-ratio", args_info->a2av_skew_ratio_orig, 0); - if (args_info->outcast_given) - write_into_file(outfile, "outcast", 0, 0 ); - if (args_info->traces_given) - write_into_file(outfile, "traces", args_info->traces_orig, 0); - if (args_info->traces_start_given) - write_into_file(outfile, "traces-start", args_info->traces_start_orig, 0); - if (args_info->traces_nops_given) - write_into_file(outfile, "traces-nops", args_info->traces_nops_orig, 0); - if (args_info->traces_extr_given) - write_into_file(outfile, "traces-extr", args_info->traces_extr_orig, 0); - if (args_info->traces_print_given) - write_into_file(outfile, "traces-print", args_info->traces_print_orig, 0); - if (args_info->traces_nop2p_given) - write_into_file(outfile, "traces-nop2p", 0, 0 ); - if (args_info->traces_nocolls_given) - write_into_file(outfile, "traces-nocolls", 0, 0 ); - if (args_info->traces_nbcify_given) - write_into_file(outfile, "traces-nbcify", args_info->traces_nbcify_orig, 0); - - - i = EXIT_SUCCESS; - return i; -} - -int -cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) -{ - FILE *outfile; - int i = 0; - - outfile = fopen(filename, "w"); - - if (!outfile) - { - fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); - return EXIT_FAILURE; - } - - i = cmdline_parser_dump(outfile, args_info); - fclose (outfile); - - return i; -} - -void -cmdline_parser_free (struct gengetopt_args_info *args_info) -{ - cmdline_parser_release (args_info); -} - -/** @brief replacement of strdup, which is not standard */ -char * -gengetopt_strdup (const char *s) -{ - char *result = 0; - if (!s) - return result; - - result = (char*)malloc(strlen(s) + 1); - if (result == (char*)0) - return (char*)0; - strcpy(result, s); - return result; -} - -int -cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) -{ - return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); -} - -int -cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params) -{ - int result; - result = cmdline_parser_internal (argc, argv, args_info, params, 0); - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) -{ - int result; - struct cmdline_parser_params params; - - params.override = override; - params.initialize = initialize; - params.check_required = check_required; - params.check_ambiguity = 0; - params.print_errors = 1; - - result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); - - if (result == EXIT_FAILURE) - { - cmdline_parser_free (args_info); - exit (EXIT_FAILURE); - } - - return result; -} - -int -cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) -{ - FIX_UNUSED (args_info); - FIX_UNUSED (prog_name); - return EXIT_SUCCESS; -} - - -static char *package_name = 0; - -/** - * @brief updates an option - * @param field the generic pointer to the field to update - * @param orig_field the pointer to the orig field - * @param field_given the pointer to the number of occurrence of this option - * @param prev_given the pointer to the number of occurrence already seen - * @param value the argument for this option (if null no arg was specified) - * @param possible_values the possible values for this option (if specified) - * @param default_value the default value (in case the option only accepts fixed values) - * @param arg_type the type of this option - * @param check_ambiguity @see cmdline_parser_params.check_ambiguity - * @param override @see cmdline_parser_params.override - * @param no_free whether to free a possible previous value - * @param multiple_option whether this is a multiple option - * @param long_opt the corresponding long option - * @param short_opt the corresponding short option (or '-' if none) - * @param additional_error possible further error specification - */ -static -int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, - char *value, const char *possible_values[], - const char *default_value, - cmdline_parser_arg_type arg_type, - int check_ambiguity, int override, - int no_free, int multiple_option, - const char *long_opt, char short_opt, - const char *additional_error) -{ - char *stop_char = 0; - const char *val = value; - int found; - char **string_field; - FIX_UNUSED (field); - - stop_char = 0; - found = 0; - - if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) - { - if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", - package_name, long_opt, short_opt, - (additional_error ? additional_error : "")); - else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", - package_name, long_opt, - (additional_error ? additional_error : "")); - return 1; /* failure */ - } - - if (possible_values && (found = check_possible_values((value ? value : default_value), possible_values)) < 0) - { - if (short_opt != '-') - fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s' (`-%c')%s\n", - package_name, (found == -2) ? "ambiguous" : "invalid", value, long_opt, short_opt, - (additional_error ? additional_error : "")); - else - fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s'%s\n", - package_name, (found == -2) ? "ambiguous" : "invalid", value, long_opt, - (additional_error ? additional_error : "")); - return 1; /* failure */ - } - - if (field_given && *field_given && ! override) - return 0; - if (prev_given) - (*prev_given)++; - if (field_given) - (*field_given)++; - if (possible_values) - val = possible_values[found]; - - switch(arg_type) { - case ARG_FLAG: - *((int *)field) = !*((int *)field); - break; - case ARG_INT: - if (val) *((int *)field) = strtol (val, &stop_char, 0); - break; - case ARG_STRING: - if (val) { - string_field = (char **)field; - if (!no_free && *string_field) - free (*string_field); /* free previous string */ - *string_field = gengetopt_strdup (val); - } - break; - default: - break; - }; - - /* check numeric conversion */ - switch(arg_type) { - case ARG_INT: - if (val && !(stop_char && *stop_char == '\0')) { - fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); - return 1; /* failure */ - } - break; - default: - ; - }; - - /* store the original value */ - switch(arg_type) { - case ARG_NO: - case ARG_FLAG: - break; - default: - if (value && orig_field) { - if (no_free) { - *orig_field = value; - } else { - if (*orig_field) - free (*orig_field); /* free previous string */ - *orig_field = gengetopt_strdup (value); - } - } - }; - - return 0; /* OK */ -} - - -int -cmdline_parser_internal ( - int argc, char **argv, struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params, const char *additional_error) -{ - int c; /* Character of the parsed option. */ - - int error_occurred = 0; - struct gengetopt_args_info local_args_info; - - int override; - int initialize; - int check_required; - int check_ambiguity; - - package_name = argv[0]; - - /* TODO: Why is this here? It is not used anywhere. */ - override = params->override; - FIX_UNUSED(override); - - initialize = params->initialize; - check_required = params->check_required; - - /* TODO: Why is this here? It is not used anywhere. */ - check_ambiguity = params->check_ambiguity; - FIX_UNUSED(check_ambiguity); - - if (initialize) - cmdline_parser_init (args_info); - - cmdline_parser_init (&local_args_info); - - optarg = 0; - optind = 0; - opterr = params->print_errors; - optopt = '?'; - - while (1) - { - int option_index = 0; - - static struct option long_options[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, - { "ptrn", 1, NULL, 'p' }, - { "commsize", 1, NULL, 's' }, - { "timemult", 1, NULL, 0 }, - { "datasize", 1, NULL, 'd' }, - { "filename", 1, NULL, 'o' }, - { "nway", 1, NULL, 0 }, - { "root", 1, NULL, 0 }, - { "segmentsize", 1, NULL, 0 }, - { "nb", 1, NULL, 0 }, - { "nb-poll", 1, NULL, 0 }, - { "cpu", 1, NULL, 0 }, - { "rpl-dep-cmp", 1, NULL, 0 }, - { "a2av-skew-ratio", 1, NULL, 0 }, - { "outcast", 0, NULL, 0 }, - { "traces", 1, NULL, 0 }, - { "traces-start", 1, NULL, 0 }, - { "traces-nops", 1, NULL, 0 }, - { "traces-extr", 1, NULL, 0 }, - { "traces-print", 1, NULL, 0 }, - { "traces-nop2p", 0, NULL, 0 }, - { "traces-nocolls", 0, NULL, 0 }, - { "traces-nbcify", 1, NULL, 0 }, - { 0, 0, 0, 0 } - }; - - c = getopt_long (argc, argv, "hVp:s:d:o:", long_options, &option_index); - - if (c == -1) break; /* Exit from `while (1)' loop. */ - - switch (c) - { - case 'h': /* Print help and exit. */ - cmdline_parser_print_help (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); - - case 'V': /* Print version and exit. */ - cmdline_parser_print_version (); - cmdline_parser_free (&local_args_info); - exit (EXIT_SUCCESS); - - case 'p': /* Name of the communication pattern that should be used to generate a schedule. */ - - - if (update_arg( (void *)&(args_info->ptrn_arg), - &(args_info->ptrn_orig), &(args_info->ptrn_given), - &(local_args_info.ptrn_given), optarg, cmdline_parser_ptrn_values, "binomialtreebcast", ARG_STRING, - check_ambiguity, override, 0, 0, - "ptrn", 'p', - additional_error)) - goto failure; - - break; - case 's': /* Number of nodes that should be used in the communication pattern. */ - - - if (update_arg( (void *)&(args_info->commsize_arg), - &(args_info->commsize_orig), &(args_info->commsize_given), - &(local_args_info.commsize_given), optarg, 0, "8", ARG_INT, - check_ambiguity, override, 0, 0, - "commsize", 's', - additional_error)) - goto failure; - - break; - case 'd': /* Number of bytes that are transmitted in the communication patttern in a basic step. */ - - - if (update_arg( (void *)&(args_info->datasize_arg), - &(args_info->datasize_orig), &(args_info->datasize_given), - &(local_args_info.datasize_given), optarg, 0, "1", ARG_INT, - check_ambiguity, override, 0, 0, - "datasize", 'd', - additional_error)) - goto failure; - - break; - case 'o': /* Filename for the name of the generated schedule. */ - - - if (update_arg( (void *)&(args_info->filename_arg), - &(args_info->filename_orig), &(args_info->filename_given), - &(local_args_info.filename_given), optarg, 0, "schedule.goal", ARG_STRING, - check_ambiguity, override, 0, 0, - "filename", 'o', - additional_error)) - goto failure; - - break; - - case 0: /* Long option with no short option */ - /* Time multiplier, relative to microsecond (e.g., nanoseconds -> 1000). */ - if (strcmp (long_options[option_index].name, "timemult") == 0) - { - - - if (update_arg( (void *)&(args_info->timemult_arg), - &(args_info->timemult_orig), &(args_info->timemult_given), - &(local_args_info.timemult_given), optarg, 0, "1000", ARG_INT, - check_ambiguity, override, 0, 0, - "timemult", '-', - additional_error)) - goto failure; - - } - /* Fanout for the n-way dissemination pattern. */ - else if (strcmp (long_options[option_index].name, "nway") == 0) - { - - - if (update_arg( (void *)&(args_info->nway_arg), - &(args_info->nway_orig), &(args_info->nway_given), - &(local_args_info.nway_given), optarg, 0, "1", ARG_INT, - check_ambiguity, override, 0, 0, - "nway", '-', - additional_error)) - goto failure; - - } - /* Root node for certain patterns. */ - else if (strcmp (long_options[option_index].name, "root") == 0) - { - - - if (update_arg( (void *)&(args_info->root_arg), - &(args_info->root_orig), &(args_info->root_given), - &(local_args_info.root_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "root", '-', - additional_error)) - goto failure; - - } - /* Segment size for pipelined pattern. */ - else if (strcmp (long_options[option_index].name, "segmentsize") == 0) - { - - - if (update_arg( (void *)&(args_info->segmentsize_arg), - &(args_info->segmentsize_orig), &(args_info->segmentsize_given), - &(local_args_info.segmentsize_given), optarg, 0, "1", ARG_INT, - check_ambiguity, override, 0, 0, - "segmentsize", '-', - additional_error)) - goto failure; - - } - /* nonblocking execution of collectives (provide length of local operation). */ - else if (strcmp (long_options[option_index].name, "nb") == 0) - { - - - if (update_arg( (void *)&(args_info->nb_arg), - &(args_info->nb_orig), &(args_info->nb_given), - &(local_args_info.nb_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "nb", '-', - additional_error)) - goto failure; - - } - /* polling interval for nonblocking execution. */ - else if (strcmp (long_options[option_index].name, "nb-poll") == 0) - { - - - if (update_arg( (void *)&(args_info->nb_poll_arg), - &(args_info->nb_poll_orig), &(args_info->nb_poll_given), - &(local_args_info.nb_poll_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "nb-poll", '-', - additional_error)) - goto failure; - - } - /* select CPU to execute computation. */ - else if (strcmp (long_options[option_index].name, "cpu") == 0) - { - - - if (update_arg( (void *)&(args_info->cpu_arg), - &(args_info->cpu_orig), &(args_info->cpu_given), - &(local_args_info.cpu_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "cpu", '-', - additional_error)) - goto failure; - - } - /* replaces dependencies with fixed computation (parameter represents computation time. If -1, does not replace dependencies.). */ - else if (strcmp (long_options[option_index].name, "rpl-dep-cmp") == 0) - { - - - if (update_arg( (void *)&(args_info->rpl_dep_cmp_arg), - &(args_info->rpl_dep_cmp_orig), &(args_info->rpl_dep_cmp_given), - &(local_args_info.rpl_dep_cmp_given), optarg, 0, "-1", ARG_INT, - check_ambiguity, override, 0, 0, - "rpl-dep-cmp", '-', - additional_error)) - goto failure; - - } - /* In the alltoallv pattern, each chunk of data sent by each rank is of a random size. The size of the chunk with id 'root' is of size 'datasize'. All the other chunks are of random size, and a2av-skew-ratio times smaller.. */ - else if (strcmp (long_options[option_index].name, "a2av-skew-ratio") == 0) - { - - - if (update_arg( (void *)&(args_info->a2av_skew_ratio_arg), - &(args_info->a2av_skew_ratio_orig), &(args_info->a2av_skew_ratio_given), - &(local_args_info.a2av_skew_ratio_given), optarg, 0, "1", ARG_INT, - check_ambiguity, override, 0, 0, - "a2av-skew-ratio", '-', - additional_error)) - goto failure; - - } - /* Generates outcast in the alltoallv pattern.. */ - else if (strcmp (long_options[option_index].name, "outcast") == 0) - { - - - if (update_arg((void *)&(args_info->outcast_flag), 0, &(args_info->outcast_given), - &(local_args_info.outcast_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "outcast", '-', - additional_error)) - goto failure; - - } - /* Tracefile for rank 0 (others are autodetected). */ - else if (strcmp (long_options[option_index].name, "traces") == 0) - { - - - if (update_arg( (void *)&(args_info->traces_arg), - &(args_info->traces_orig), &(args_info->traces_given), - &(local_args_info.traces_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "traces", '-', - additional_error)) - goto failure; - - } - /* file with start lines in trace files (is updated after run if trace-nops is given). */ - else if (strcmp (long_options[option_index].name, "traces-start") == 0) - { - - - if (update_arg( (void *)&(args_info->traces_start_arg), - &(args_info->traces_start_orig), &(args_info->traces_start_given), - &(local_args_info.traces_start_given), optarg, 0, 0, ARG_STRING, - check_ambiguity, override, 0, 0, - "traces-start", '-', - additional_error)) - goto failure; - - } - /* number of operations to write to file (0=all). */ - else if (strcmp (long_options[option_index].name, "traces-nops") == 0) - { - - - if (update_arg( (void *)&(args_info->traces_nops_arg), - &(args_info->traces_nops_orig), &(args_info->traces_nops_given), - &(local_args_info.traces_nops_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "traces-nops", '-', - additional_error)) - goto failure; - - } - /* extrapolation factor for traces. */ - else if (strcmp (long_options[option_index].name, "traces-extr") == 0) - { - - - if (update_arg( (void *)&(args_info->traces_extr_arg), - &(args_info->traces_extr_orig), &(args_info->traces_extr_given), - &(local_args_info.traces_extr_given), optarg, 0, "1", ARG_INT, - check_ambiguity, override, 0, 0, - "traces-extr", '-', - additional_error)) - goto failure; - - } - /* print each operation. */ - else if (strcmp (long_options[option_index].name, "traces-print") == 0) - { - - - if (update_arg( (void *)&(args_info->traces_print_arg), - &(args_info->traces_print_orig), &(args_info->traces_print_given), - &(local_args_info.traces_print_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "traces-print", '-', - additional_error)) - goto failure; - - } - /* do not consider point-to-point communication. */ - else if (strcmp (long_options[option_index].name, "traces-nop2p") == 0) - { - - - if (update_arg((void *)&(args_info->traces_nop2p_flag), 0, &(args_info->traces_nop2p_given), - &(local_args_info.traces_nop2p_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "traces-nop2p", '-', - additional_error)) - goto failure; - - } - /* do not consider collective communication. */ - else if (strcmp (long_options[option_index].name, "traces-nocolls") == 0) - { - - - if (update_arg((void *)&(args_info->traces_nocolls_flag), 0, &(args_info->traces_nocolls_given), - &(local_args_info.traces_nocolls_given), optarg, 0, 0, ARG_FLAG, - check_ambiguity, override, 1, 0, "traces-nocolls", '-', - additional_error)) - goto failure; - - } - /* turn blocking collectives into non-blocking colls, time to pre-post NBCs. */ - else if (strcmp (long_options[option_index].name, "traces-nbcify") == 0) - { - - - if (update_arg( (void *)&(args_info->traces_nbcify_arg), - &(args_info->traces_nbcify_orig), &(args_info->traces_nbcify_given), - &(local_args_info.traces_nbcify_given), optarg, 0, "0", ARG_INT, - check_ambiguity, override, 0, 0, - "traces-nbcify", '-', - additional_error)) - goto failure; - - } - - break; - case '?': /* Invalid option. */ - /* `getopt_long' already printed an error message. */ - goto failure; - - default: /* bug: option not considered. */ - fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); - abort (); - } /* switch */ - } /* while */ - - - - FIX_UNUSED(check_required); - - cmdline_parser_release (&local_args_info); - - if ( error_occurred ) - return (EXIT_FAILURE); - - return 0; - -failure: - - cmdline_parser_release (&local_args_info); - return (EXIT_FAILURE); -} -/* vim: set ft=c noet ts=8 sts=8 sw=8 tw=80 nojs spell : */ diff --git a/src/Schedgen/schedgen_cmdline.h b/src/Schedgen/schedgen_cmdline.h deleted file mode 100644 index 0e46fac..0000000 --- a/src/Schedgen/schedgen_cmdline.h +++ /dev/null @@ -1,260 +0,0 @@ -/** @file schedgen_cmdline.h - * @brief The header file for the command line option parser - * generated by GNU Gengetopt version 2.23 - * http://www.gnu.org/software/gengetopt. - * DO NOT modify this file, since it can be overwritten - * @author GNU Gengetopt */ - -#ifndef SCHEDGEN_CMDLINE_H -#define SCHEDGEN_CMDLINE_H - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include /* for FILE */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef CMDLINE_PARSER_PACKAGE -/** @brief the program name (used for printing errors) */ -#define CMDLINE_PARSER_PACKAGE "schedgen" -#endif - -#ifndef CMDLINE_PARSER_PACKAGE_NAME -/** @brief the complete program name (used for help and version) */ -#define CMDLINE_PARSER_PACKAGE_NAME "schedgen" -#endif - -#ifndef CMDLINE_PARSER_VERSION -/** @brief the program version */ -#define CMDLINE_PARSER_VERSION "0.1" -#endif - -/** @brief Where the command line options are stored */ -struct gengetopt_args_info -{ - const char *help_help; /**< @brief Print help and exit help description. */ - const char *version_help; /**< @brief Print version and exit help description. */ - char * ptrn_arg; /**< @brief Name of the communication pattern that should be used to generate a schedule (default='binomialtreebcast'). */ - char * ptrn_orig; /**< @brief Name of the communication pattern that should be used to generate a schedule original value given at command line. */ - const char *ptrn_help; /**< @brief Name of the communication pattern that should be used to generate a schedule help description. */ - int commsize_arg; /**< @brief Number of nodes that should be used in the communication pattern (default='8'). */ - char * commsize_orig; /**< @brief Number of nodes that should be used in the communication pattern original value given at command line. */ - const char *commsize_help; /**< @brief Number of nodes that should be used in the communication pattern help description. */ - int timemult_arg; /**< @brief Time multiplier, relative to microsecond (e.g., nanoseconds -> 1000) (default='1000'). */ - char * timemult_orig; /**< @brief Time multiplier, relative to microsecond (e.g., nanoseconds -> 1000) original value given at command line. */ - const char *timemult_help; /**< @brief Time multiplier, relative to microsecond (e.g., nanoseconds -> 1000) help description. */ - int datasize_arg; /**< @brief Number of bytes that are transmitted in the communication patttern in a basic step (default='1'). */ - char * datasize_orig; /**< @brief Number of bytes that are transmitted in the communication patttern in a basic step original value given at command line. */ - const char *datasize_help; /**< @brief Number of bytes that are transmitted in the communication patttern in a basic step help description. */ - char * filename_arg; /**< @brief Filename for the name of the generated schedule (default='schedule.goal'). */ - char * filename_orig; /**< @brief Filename for the name of the generated schedule original value given at command line. */ - const char *filename_help; /**< @brief Filename for the name of the generated schedule help description. */ - int nway_arg; /**< @brief Fanout for the n-way dissemination pattern (default='1'). */ - char * nway_orig; /**< @brief Fanout for the n-way dissemination pattern original value given at command line. */ - const char *nway_help; /**< @brief Fanout for the n-way dissemination pattern help description. */ - int root_arg; /**< @brief Root node for certain patterns (default='0'). */ - char * root_orig; /**< @brief Root node for certain patterns original value given at command line. */ - const char *root_help; /**< @brief Root node for certain patterns help description. */ - int segmentsize_arg; /**< @brief Segment size for pipelined pattern (default='1'). */ - char * segmentsize_orig; /**< @brief Segment size for pipelined pattern original value given at command line. */ - const char *segmentsize_help; /**< @brief Segment size for pipelined pattern help description. */ - int nb_arg; /**< @brief nonblocking execution of collectives (provide length of local operation) (default='0'). */ - char * nb_orig; /**< @brief nonblocking execution of collectives (provide length of local operation) original value given at command line. */ - const char *nb_help; /**< @brief nonblocking execution of collectives (provide length of local operation) help description. */ - int nb_poll_arg; /**< @brief polling interval for nonblocking execution (default='0'). */ - char * nb_poll_orig; /**< @brief polling interval for nonblocking execution original value given at command line. */ - const char *nb_poll_help; /**< @brief polling interval for nonblocking execution help description. */ - int cpu_arg; /**< @brief select CPU to execute computation (default='0'). */ - char * cpu_orig; /**< @brief select CPU to execute computation original value given at command line. */ - const char *cpu_help; /**< @brief select CPU to execute computation help description. */ - int rpl_dep_cmp_arg; /**< @brief replaces dependencies with fixed computation (parameter represents computation time. If -1, does not replace dependencies.) (default='-1'). */ - char * rpl_dep_cmp_orig; /**< @brief replaces dependencies with fixed computation (parameter represents computation time. If -1, does not replace dependencies.) original value given at command line. */ - const char *rpl_dep_cmp_help; /**< @brief replaces dependencies with fixed computation (parameter represents computation time. If -1, does not replace dependencies.) help description. */ - int a2av_skew_ratio_arg; /**< @brief In the alltoallv pattern, each chunk of data sent by each rank is of a random size. The size of the chunk with id 'root' is of size 'datasize'. All the other chunks are of random size, and a2av-skew-ratio times smaller. (default='1'). */ - char * a2av_skew_ratio_orig; /**< @brief In the alltoallv pattern, each chunk of data sent by each rank is of a random size. The size of the chunk with id 'root' is of size 'datasize'. All the other chunks are of random size, and a2av-skew-ratio times smaller. original value given at command line. */ - const char *a2av_skew_ratio_help; /**< @brief In the alltoallv pattern, each chunk of data sent by each rank is of a random size. The size of the chunk with id 'root' is of size 'datasize'. All the other chunks are of random size, and a2av-skew-ratio times smaller. help description. */ - int outcast_flag; /**< @brief Generates outcast in the alltoallv pattern. (default=off). */ - const char *outcast_help; /**< @brief Generates outcast in the alltoallv pattern. help description. */ - char * traces_arg; /**< @brief Tracefile for rank 0 (others are autodetected). */ - char * traces_orig; /**< @brief Tracefile for rank 0 (others are autodetected) original value given at command line. */ - const char *traces_help; /**< @brief Tracefile for rank 0 (others are autodetected) help description. */ - char * traces_start_arg; /**< @brief file with start lines in trace files (is updated after run if trace-nops is given). */ - char * traces_start_orig; /**< @brief file with start lines in trace files (is updated after run if trace-nops is given) original value given at command line. */ - const char *traces_start_help; /**< @brief file with start lines in trace files (is updated after run if trace-nops is given) help description. */ - int traces_nops_arg; /**< @brief number of operations to write to file (0=all) (default='0'). */ - char * traces_nops_orig; /**< @brief number of operations to write to file (0=all) original value given at command line. */ - const char *traces_nops_help; /**< @brief number of operations to write to file (0=all) help description. */ - int traces_extr_arg; /**< @brief extrapolation factor for traces (default='1'). */ - char * traces_extr_orig; /**< @brief extrapolation factor for traces original value given at command line. */ - const char *traces_extr_help; /**< @brief extrapolation factor for traces help description. */ - int traces_print_arg; /**< @brief print each operation (default='0'). */ - char * traces_print_orig; /**< @brief print each operation original value given at command line. */ - const char *traces_print_help; /**< @brief print each operation help description. */ - int traces_nop2p_flag; /**< @brief do not consider point-to-point communication (default=off). */ - const char *traces_nop2p_help; /**< @brief do not consider point-to-point communication help description. */ - int traces_nocolls_flag; /**< @brief do not consider collective communication (default=off). */ - const char *traces_nocolls_help; /**< @brief do not consider collective communication help description. */ - int traces_nbcify_arg; /**< @brief turn blocking collectives into non-blocking colls, time to pre-post NBCs (default='0'). */ - char * traces_nbcify_orig; /**< @brief turn blocking collectives into non-blocking colls, time to pre-post NBCs original value given at command line. */ - const char *traces_nbcify_help; /**< @brief turn blocking collectives into non-blocking colls, time to pre-post NBCs help description. */ - - unsigned int help_given ; /**< @brief Whether help was given. */ - unsigned int version_given ; /**< @brief Whether version was given. */ - unsigned int ptrn_given ; /**< @brief Whether ptrn was given. */ - unsigned int commsize_given ; /**< @brief Whether commsize was given. */ - unsigned int timemult_given ; /**< @brief Whether timemult was given. */ - unsigned int datasize_given ; /**< @brief Whether datasize was given. */ - unsigned int filename_given ; /**< @brief Whether filename was given. */ - unsigned int nway_given ; /**< @brief Whether nway was given. */ - unsigned int root_given ; /**< @brief Whether root was given. */ - unsigned int segmentsize_given ; /**< @brief Whether segmentsize was given. */ - unsigned int nb_given ; /**< @brief Whether nb was given. */ - unsigned int nb_poll_given ; /**< @brief Whether nb-poll was given. */ - unsigned int cpu_given ; /**< @brief Whether cpu was given. */ - unsigned int rpl_dep_cmp_given ; /**< @brief Whether rpl-dep-cmp was given. */ - unsigned int a2av_skew_ratio_given ; /**< @brief Whether a2av-skew-ratio was given. */ - unsigned int outcast_given ; /**< @brief Whether outcast was given. */ - unsigned int traces_given ; /**< @brief Whether traces was given. */ - unsigned int traces_start_given ; /**< @brief Whether traces-start was given. */ - unsigned int traces_nops_given ; /**< @brief Whether traces-nops was given. */ - unsigned int traces_extr_given ; /**< @brief Whether traces-extr was given. */ - unsigned int traces_print_given ; /**< @brief Whether traces-print was given. */ - unsigned int traces_nop2p_given ; /**< @brief Whether traces-nop2p was given. */ - unsigned int traces_nocolls_given ; /**< @brief Whether traces-nocolls was given. */ - unsigned int traces_nbcify_given ; /**< @brief Whether traces-nbcify was given. */ - -} ; - -/** @brief The additional parameters to pass to parser functions */ -struct cmdline_parser_params -{ - int override; /**< @brief whether to override possibly already present options (default 0) */ - int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ - int check_required; /**< @brief whether to check that all required options were provided (default 1) */ - int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ - int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ -} ; - -/** @brief the purpose string of the program */ -extern const char *gengetopt_args_info_purpose; -/** @brief the usage string of the program */ -extern const char *gengetopt_args_info_usage; -/** @brief the description string of the program */ -extern const char *gengetopt_args_info_description; -/** @brief all the lines making the help output */ -extern const char *gengetopt_args_info_help[]; - -/** - * The command line parser - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser (int argc, char **argv, - struct gengetopt_args_info *args_info); - -/** - * The command line parser (version with additional parameters - deprecated) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param override whether to override possibly already present options - * @param initialize whether to initialize the option structure my_args_info - * @param check_required whether to check that all required options were provided - * @return 0 if everything went fine, NON 0 if an error took place - * @deprecated use cmdline_parser_ext() instead - */ -int cmdline_parser2 (int argc, char **argv, - struct gengetopt_args_info *args_info, - int override, int initialize, int check_required); - -/** - * The command line parser (version with additional parameters) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param params additional parameters for the parser - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_ext (int argc, char **argv, - struct gengetopt_args_info *args_info, - struct cmdline_parser_params *params); - -/** - * Save the contents of the option struct into an already open FILE stream. - * @param outfile the stream where to dump options - * @param args_info the option struct to dump - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_dump(FILE *outfile, - struct gengetopt_args_info *args_info); - -/** - * Save the contents of the option struct into a (text) file. - * This file can be read by the config file parser (if generated by gengetopt) - * @param filename the file where to save - * @param args_info the option struct to save - * @return 0 if everything went fine, NON 0 if an error took place - */ -int cmdline_parser_file_save(const char *filename, - struct gengetopt_args_info *args_info); - -/** - * Print the help - */ -void cmdline_parser_print_help(void); -/** - * Print the version - */ -void cmdline_parser_print_version(void); - -/** - * Initializes all the fields a cmdline_parser_params structure - * to their default values - * @param params the structure to initialize - */ -void cmdline_parser_params_init(struct cmdline_parser_params *params); - -/** - * Allocates dynamically a cmdline_parser_params structure and initializes - * all its fields to their default values - * @return the created and initialized cmdline_parser_params structure - */ -struct cmdline_parser_params *cmdline_parser_params_create(void); - -/** - * Initializes the passed gengetopt_args_info structure's fields - * (also set default values for options that have a default) - * @param args_info the structure to initialize - */ -void cmdline_parser_init (struct gengetopt_args_info *args_info); -/** - * Deallocates the string fields of the gengetopt_args_info structure - * (but does not deallocate the structure itself) - * @param args_info the structure to deallocate - */ -void cmdline_parser_free (struct gengetopt_args_info *args_info); - -/** - * Checks that all the required options were specified - * @param args_info the structure to check - * @param prog_name the name of the program that will be used to print - * possible errors - * @return - */ -int cmdline_parser_required (struct gengetopt_args_info *args_info, - const char *prog_name); - -extern const char *cmdline_parser_ptrn_values[]; /**< @brief Possible values for ptrn. */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* SCHEDGEN_CMDLINE_H */