diff --git a/.gitignore b/.gitignore index 378eac2..7d75298 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build +__pycache__ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8656ff5..c63ccb1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,15 +77,16 @@ add_test(NAME loggopsim_schedgen2_bcast COMMAND LogGOPSim -f schedule.bin) # test liballprof # test liballprof2 +set(ENV{OMPI_MCA_rmaps_base_oversubscribe} "1") #Open MPI might need oversubscription enabled, MPICH doesn't, their cmdline args are not compatible, so this should work for both #c wrapper test add_executable(test_lap2_c ${PROJECT_SOURCE_DIR}/../tests/mpi_helloworld.c) target_link_libraries(test_lap2_c mpipclog) -add_test(NAME trace_lap2_c COMMAND ${MPIEXEC_EXECUTABLE} --oversubscribe ${MPIEXEC_NUMPROC_FLAG} 4 $) +add_test(NAME trace_lap2_c COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 $) add_test(NAME lap2_c_trace_exists COMMAND ${CMAKE_COMMAND} -E cat lap2-trace-rank-1-of-4.txt) # fortran wrapper test add_executable(test_lap2_f ${PROJECT_SOURCE_DIR}/../tests/mpi_helloworld.f90) target_link_libraries(test_lap2_f mpipflog) -add_test(NAME trace_lap2_f COMMAND ${MPIEXEC_EXECUTABLE} --oversubscribe ${MPIEXEC_NUMPROC_FLAG} 4 $) +add_test(NAME trace_lap2_f COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 $) add_test(NAME lap2_f_trace_exists COMMAND ${CMAKE_COMMAND} -E cat lap2-trace-rank-1-of-4.txt ) diff --git a/src/LogGOPSim/loggopsim_cmdline.c b/src/LogGOPSim/loggopsim_cmdline.c new file mode 100644 index 0000000..85907a2 --- /dev/null +++ b/src/LogGOPSim/loggopsim_cmdline.c @@ -0,0 +1,962 @@ +/* + 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 new file mode 100644 index 0000000..24a6725 --- /dev/null +++ b/src/LogGOPSim/loggopsim_cmdline.h @@ -0,0 +1,235 @@ +/** @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.cpp b/src/LogGOPSim/txt2bin.cpp new file mode 100644 index 0000000..620df98 --- /dev/null +++ b/src/LogGOPSim/txt2bin.cpp @@ -0,0 +1,2970 @@ +/* Generated by re2c 3.1 on Sun Oct 15 14:07:10 2023 */ +#line 1 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Goal.hpp" +#include "txt2bin_cmdline.h" + +typedef unsigned int uint; +typedef unsigned char uchar; + +#define BSIZE 10240 + +#define YYCTYPE uchar +#define YYCURSOR cursor +#define YYLIMIT s->lim +#define YYMARKER s->ptr +#define YYFILL(n) {cursor = fill(s, cursor, n);} + +#define RET(i) {s->cur = cursor; return i;} + +gengetopt_args_info args_info; + +typedef struct Scanner { + FILE* fd; + uchar *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof; + uint line; + int rank; + uint32_t curr_rank, num_ranks; + Goal* schedule; + std::map* idtbl; +} Scanner; + +typedef struct Item { + char type; + char *label1; + char *label2; + uint64_t size; + uint32_t target; + uint32_t tag; + uint8_t cpu; + uint8_t nic; +} Item; + +enum OpTypes { + Undefined, + SendOp, + RecvOp, + LoclOp, + StartDependency, + Dependency +}; + +inline uint64_t add_number(unsigned char *s, unsigned char *e) { + + uint64_t num = 0; + --s; + while(++s < e) num = num * 10 + (*s - '0'); + + return num; +} + +inline void insert_id(Scanner *s, char *id, goalop_t op) { + + s->idtbl->insert(std::make_pair(std::string(id), op)); + free(id); +} + +inline goalop_t retrieve_id(Scanner *s, char *id) { + + std::map::iterator it; + it = s->idtbl->find(std::string(id)); + if (it == s->idtbl->end()) { + fprintf(stderr, "A dependency references label %s, which is undefined!\n", id); + exit(EXIT_FAILURE); + } + free(id); + return it->second; +} + +void process_item(Scanner *s, Item *item) { + +/* + printf("Parsed Item:\n"); + printf(" Type: "); + if (item->type == Undefined) printf("Undefined\n"); + if (item->type == SendOp) printf("Send\n"); + if (item->type == RecvOp) printf("Recv\n"); + if (item->type == LoclOp) printf("LoclOp\n"); + if (item->type == StartDependency) printf("IRequires\n"); + if (item->type == Dependency) printf("Requires\n"); + printf(" Label1: %s\n", item->label1); + printf(" Label2: %s\n", item->label2); + printf(" Size: %i\n", item->size); + printf(" Target: %i\n", item->target); + printf(" Tag: %i\n", item->tag); + printf(" CPU: %i\n", item->cpu); + printf(" NIC: %i\n", item->nic); +*/ + + goalop_t op, op2; + + switch (item->type) { + case Undefined: + fprintf(stderr, "Error while parsing, attempt to add a undefined operation\n"); + exit(EXIT_FAILURE); + break; + case SendOp: + op = s->schedule->Send(s->rank, item->target, item->size, item->tag, item->cpu, item->nic); + if (item->label1 != NULL) insert_id(s, item->label1, op); + break; + case RecvOp: + op = s->schedule->Recv(item->target, s->rank, item->size, item->tag, item->cpu, item->nic); + if (item->label1 != NULL) insert_id(s, item->label1, op); + break; + case LoclOp: + op = s->schedule->Calc(s->rank, item->size, item->cpu, item->nic); + if (item->label1 != NULL) insert_id(s, item->label1, op); + break; + case StartDependency: + op = retrieve_id(s, item->label1); + op2 = retrieve_id(s, item->label2); + assert(op != NULL); + assert(op2 != NULL); + s->schedule->StartDependency(op, op2); + break; + case Dependency: + op = retrieve_id(s, item->label1); + op2 = retrieve_id(s, item->label2); + assert(op != NULL); + assert(op2 != NULL); + s->schedule->Dependency(op, op2); + break; + default: + break; + } +} + +inline char* add_label(unsigned char *s, unsigned char *e) { + + char *buf = NULL; + + buf = (char *) malloc((e-s)+1); + memcpy((void *) buf, (void *) s, (size_t) (e-s)); + buf[e-s] = '\0'; + + return buf; + +} + + +uchar *fill(Scanner *s, uchar *cursor, int numtoread) { + + if(!s->eof) { + uint cnt = s->tok - s->bot; + if(cnt){ + if ((s->lim - s->tok) < abs(s->bot - s->tok)) memcpy(s->bot, s->tok, s->lim - s->tok); + else memmove(s->bot, s->tok, s->lim - s->tok); + s->tok = s->bot; + s->ptr -= cnt; + cursor -= cnt; + s->pos -= cnt; + s->lim -= cnt; + } + if((s->top - s->lim) < BSIZE){ + uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar)); + if ((s->lim - s->tok) > abs(s->tok - buf)) memmove(buf, s->tok, s->lim - s->tok); + else memcpy(buf, s->tok, s->lim - s->tok); + s->tok = buf; + s->ptr = &buf[s->ptr - s->bot]; + cursor = &buf[cursor - s->bot]; + s->pos = &buf[s->pos - s->bot]; + s->lim = &buf[s->lim - s->bot]; + s->top = &s->lim[BSIZE]; + free(s->bot); + s->bot = buf; + } + cnt = fread((char*) s->lim, 1, BSIZE, s->fd); + if(cnt != BSIZE) { + s->eof = &s->lim[cnt]; + *(s->eof)++ = '\n'; + } + s->lim += cnt; + //assert(cnt >= numtoread); + } + return cursor; +} + +/* +uchar *fill(Scanner *s, uchar *cursor, int numtoread) { + + static bool firstcall = true; + + if (firstcall) { + + void *buf; + struct stat statbuf; + + int ret = fstat(fileno(s->fd), &statbuf); + buf = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fileno(s->fd), 0); + assert(buf != NULL); + s->lim = (uchar*) buf; + s->lim += statbuf.st_size; + s->eof = s->lim; + return (uchar*) buf; + } + else { + assert(0==1); + } +} +*/ + +int scan(Scanner *s) { + + //uchar *cursor = s->cur; + + static uchar *cursor = NULL; + Item item; + int state; + + for (;;) { + +s_0: + + if ((cursor == s->eof) and (cursor != NULL)) { + fprintf(stderr, "Reached the end of the inputfile - did you forget a closing bracket?\n"); + return s->rank; + } + + s->tok = cursor; + state = 0; + + // printf("Entered s_0\n"); + // if (((s->line % 100) == 0) or (s->line < 100)) printf("Line: %i\n", s->line); + + item.type = Undefined; + item.label1 = NULL; + item.label2 = NULL; + item.cpu = 0; + item.nic = 0; + item.tag = 0; + + +#line 256 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 10) YYFILL(10); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy3; + case '\n': goto yy5; + case '\r': goto yy6; + case '/': goto yy7; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'a': + case 'b': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'o': + case 'p': + case 'q': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + case 'c': goto yy11; + case 'n': goto yy12; + case 'r': goto yy13; + case 's': goto yy14; + case '}': goto yy15; + default: goto yy1; + } +yy1: + ++YYCURSOR; +yy2: +#line 294 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 327 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy3: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy3; + default: goto yy4; + } +yy4: +#line 282 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->tok = cursor; } +#line 340 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy5: + ++YYCURSOR; +#line 292 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; continue; } +#line 345 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy6: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy5; + default: goto yy2; + } +yy7: + yych = *++YYCURSOR; + switch (yych) { + case '*': goto yy16; + case '/': goto yy17; + default: goto yy2; + } +yy8: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy9: + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + default: goto yy10; + } +yy10: +#line 288 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.label1 = add_label(s->tok, cursor); goto s_1; } +#line 433 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy11: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy18; + default: goto yy9; + } +yy12: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy19; + default: goto yy9; + } +yy13: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy20; + case 'e': goto yy21; + default: goto yy9; + } +yy14: + yych = *++YYCURSOR; + switch (yych) { + case 'e': goto yy22; + default: goto yy9; + } +yy15: + ++YYCURSOR; +#line 293 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { if (s->rank == -1) goto s_err; int oldrank = s->rank; s->rank = -1; return oldrank; } +#line 463 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy16: + ++YYCURSOR; +#line 290 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_24; } +#line 468 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy17: + ++YYCURSOR; +#line 289 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_23; } +#line 473 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy18: + yych = *++YYCURSOR; + switch (yych) { + case 'l': goto yy23; + default: goto yy9; + } +yy19: + yych = *++YYCURSOR; + switch (yych) { + case 'm': goto yy24; + default: goto yy9; + } +yy20: + yych = *++YYCURSOR; + switch (yych) { + case 'n': goto yy25; + default: goto yy9; + } +yy21: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy26; + default: goto yy9; + } +yy22: + yych = *++YYCURSOR; + switch (yych) { + case 'n': goto yy27; + default: goto yy9; + } +yy23: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy28; + default: goto yy9; + } +yy24: + yych = *++YYCURSOR; + switch (yych) { + case '_': goto yy30; + default: goto yy9; + } +yy25: + yych = *++YYCURSOR; + switch (yych) { + case 'k': goto yy31; + default: goto yy9; + } +yy26: + yych = *++YYCURSOR; + switch (yych) { + case 'v': goto yy33; + default: goto yy9; + } +yy27: + yych = *++YYCURSOR; + switch (yych) { + case 'd': goto yy35; + default: goto yy9; + } +yy28: + yych = *++YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + default: goto yy29; + } +yy29: +#line 285 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = LoclOp; goto s_3; } +#line 605 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy30: + yych = *++YYCURSOR; + switch (yych) { + case 'r': goto yy37; + default: goto yy9; + } +yy31: + yych = *++YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + default: goto yy32; + } +yy32: +#line 286 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_20; } +#line 683 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy33: + yych = *++YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + default: goto yy34; + } +yy34: +#line 284 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = RecvOp; goto s_2; } +#line 755 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy35: + yych = *++YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + default: goto yy36; + } +yy36: +#line 283 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = SendOp; goto s_2; } +#line 827 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy37: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy38; + default: goto yy9; + } +yy38: + yych = *++YYCURSOR; + switch (yych) { + case 'n': goto yy39; + default: goto yy9; + } +yy39: + yych = *++YYCURSOR; + switch (yych) { + case 'k': goto yy40; + default: goto yy9; + } +yy40: + yych = *++YYCURSOR; + switch (yych) { + case 's': goto yy41; + default: goto yy9; + } +yy41: + yych = *++YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy8; + default: goto yy42; + } +yy42: +#line 287 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_22; } +#line 923 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 295 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_1: + state =1; + + // printf("Entered s_1\n"); + + +#line 936 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 9) YYFILL(9); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy46; + case ':': goto yy48; + case 'i': goto yy49; + case 'r': goto yy50; + default: goto yy44; + } +yy44: + ++YYCURSOR; +yy45: +#line 309 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 954 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy46: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy46; + default: goto yy47; + } +yy47: +#line 305 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_1; } +#line 967 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy48: + ++YYCURSOR; +#line 306 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_4; } +#line 972 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy49: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'r': goto yy51; + default: goto yy45; + } +yy50: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'e': goto yy53; + default: goto yy45; + } +yy51: + yych = *++YYCURSOR; + switch (yych) { + case 'e': goto yy54; + default: goto yy52; + } +yy52: + YYCURSOR = YYMARKER; + goto yy45; +yy53: + yych = *++YYCURSOR; + switch (yych) { + case 'q': goto yy55; + default: goto yy52; + } +yy54: + yych = *++YYCURSOR; + switch (yych) { + case 'q': goto yy56; + default: goto yy52; + } +yy55: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy57; + default: goto yy52; + } +yy56: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy58; + default: goto yy52; + } +yy57: + yych = *++YYCURSOR; + switch (yych) { + case 'i': goto yy59; + default: goto yy52; + } +yy58: + yych = *++YYCURSOR; + switch (yych) { + case 'i': goto yy60; + default: goto yy52; + } +yy59: + yych = *++YYCURSOR; + switch (yych) { + case 'r': goto yy61; + default: goto yy52; + } +yy60: + yych = *++YYCURSOR; + switch (yych) { + case 'r': goto yy62; + default: goto yy52; + } +yy61: + yych = *++YYCURSOR; + switch (yych) { + case 'e': goto yy63; + default: goto yy52; + } +yy62: + yych = *++YYCURSOR; + switch (yych) { + case 'e': goto yy64; + default: goto yy52; + } +yy63: + yych = *++YYCURSOR; + switch (yych) { + case 's': goto yy65; + default: goto yy52; + } +yy64: + yych = *++YYCURSOR; + switch (yych) { + case 's': goto yy66; + default: goto yy52; + } +yy65: + ++YYCURSOR; +#line 307 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = Dependency; goto s_5; } +#line 1070 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy66: + ++YYCURSOR; +#line 308 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = StartDependency; goto s_5; } +#line 1075 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 310 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + assert(0==1); //We should never reach this line + +s_2: + state=2; + + // printf("Entered s_2\n"); + + s->tok = cursor; + +#line 1088 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy69; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy71; + default: goto yy68; + } +yy68: + ++YYCURSOR; +#line 322 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1112 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy69: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy69; + default: goto yy70; + } +yy70: +#line 320 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_2; } +#line 1125 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy71: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy71; + default: goto yy72; + } +yy72: +#line 321 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.size = add_number(s->tok, cursor); goto s_10; } +#line 1146 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 323 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_3: + state = 3; + // printf("Entered s_3\n"); + + s->tok = cursor; + +#line 1159 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy75; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy77; + default: goto yy74; + } +yy74: + ++YYCURSOR; +#line 335 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1183 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy75: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy75; + default: goto yy76; + } +yy76: +#line 333 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_3; } +#line 1196 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy77: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy77; + default: goto yy78; + } +yy78: +#line 334 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.size = add_number(s->tok, cursor); goto s_7; } +#line 1217 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 336 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_4: + state = 4; + // printf("Entered s_4\n"); + + +#line 1229 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy82; + case 'c': goto yy84; + case 'r': goto yy85; + case 's': goto yy86; + default: goto yy80; + } +yy80: + ++YYCURSOR; +yy81: +#line 349 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1247 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy82: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy82; + default: goto yy83; + } +yy83: +#line 345 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_4; } +#line 1260 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy84: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'a': goto yy87; + default: goto yy81; + } +yy85: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'e': goto yy89; + default: goto yy81; + } +yy86: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'e': goto yy90; + default: goto yy81; + } +yy87: + yych = *++YYCURSOR; + switch (yych) { + case 'l': goto yy91; + default: goto yy88; + } +yy88: + YYCURSOR = YYMARKER; + goto yy81; +yy89: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy92; + default: goto yy88; + } +yy90: + yych = *++YYCURSOR; + switch (yych) { + case 'n': goto yy93; + default: goto yy88; + } +yy91: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy94; + default: goto yy88; + } +yy92: + yych = *++YYCURSOR; + switch (yych) { + case 'v': goto yy95; + default: goto yy88; + } +yy93: + yych = *++YYCURSOR; + switch (yych) { + case 'd': goto yy96; + default: goto yy88; + } +yy94: + ++YYCURSOR; +#line 346 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = LoclOp; goto s_3; } +#line 1322 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy95: + ++YYCURSOR; +#line 348 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = RecvOp; goto s_2; } +#line 1327 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy96: + ++YYCURSOR; +#line 347 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.type = SendOp; goto s_2; } +#line 1332 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 350 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + assert(0==1); //We should never reach this line + +s_5: + state =5; + // printf("Entered s_5\n"); + + s->tok = cursor; + +#line 1344 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy99; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy101; + default: goto yy98; + } +yy98: + ++YYCURSOR; +#line 361 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1410 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy99: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy99; + default: goto yy100; + } +yy100: +#line 359 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_5; } +#line 1423 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy101: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto yy101; + default: goto yy102; + } +yy102: +#line 360 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.label2 = add_label(s->tok, cursor); goto s_6; } +#line 1497 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 362 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_6: + state = 6; + // printf("Entered s_6\n"); + + +#line 1509 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy106; + case '\n': goto yy108; + case '\r': goto yy109; + default: goto yy104; + } +yy104: + ++YYCURSOR; +yy105: +#line 373 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1526 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy106: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy106; + default: goto yy107; + } +yy107: +#line 371 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_6; } +#line 1539 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy108: + ++YYCURSOR; +#line 372 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 1544 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy109: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy108; + default: goto yy105; + } + } +#line 374 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_7: + state = 7; + // printf("Entered s_7\n"); + + +#line 1562 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy113; + case '\n': goto yy115; + case '\r': goto yy116; + case 'c': goto yy117; + default: goto yy111; + } +yy111: + ++YYCURSOR; +yy112: +#line 386 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1580 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy113: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy113; + default: goto yy114; + } +yy114: +#line 383 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_7; } +#line 1593 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy115: + ++YYCURSOR; +#line 385 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 1598 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy116: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy115; + default: goto yy112; + } +yy117: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'p': goto yy118; + default: goto yy112; + } +yy118: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy120; + default: goto yy119; + } +yy119: + YYCURSOR = YYMARKER; + goto yy112; +yy120: + ++YYCURSOR; +#line 384 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_8; } +#line 1624 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 387 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_8: + state =8; + // printf("Entered s_8\n"); + + s->tok = cursor; + + +#line 1638 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy123; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy125; + default: goto yy122; + } +yy122: + ++YYCURSOR; +#line 400 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1662 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy123: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy123; + default: goto yy124; + } +yy124: +#line 398 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_8; } +#line 1675 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy125: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy125; + default: goto yy126; + } +yy126: +#line 399 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.cpu = add_number(s->tok, cursor); goto s_9; } +#line 1696 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 401 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_9: + state=9; + // printf("Entered s_9\n"); + + +#line 1708 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy130; + case '\n': goto yy132; + case '\r': goto yy133; + default: goto yy128; + } +yy128: + ++YYCURSOR; +yy129: +#line 412 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1725 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy130: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy130; + default: goto yy131; + } +yy131: +#line 410 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_9; } +#line 1738 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy132: + ++YYCURSOR; +#line 411 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 1743 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy133: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy132; + default: goto yy129; + } + } +#line 413 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_10: + state=10; + // printf("Entered s_10\n"); + + +#line 1761 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy136; + case 'b': goto yy138; + default: goto yy135; + } +yy135: + ++YYCURSOR; +#line 424 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1776 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy136: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy136; + default: goto yy137; + } +yy137: +#line 422 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_10; } +#line 1789 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy138: + ++YYCURSOR; +#line 423 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_11; } +#line 1794 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 425 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_11: + state = 11; + // printf("Entered s_11\n"); + + +#line 1806 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy142; + case 'f': goto yy144; + case 't': goto yy145; + default: goto yy140; + } +yy140: + ++YYCURSOR; +yy141: +#line 437 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1823 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy142: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy142; + default: goto yy143; + } +yy143: +#line 434 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_11; } +#line 1836 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy144: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'r': goto yy146; + default: goto yy141; + } +yy145: + yych = *++YYCURSOR; + switch (yych) { + case 'o': goto yy148; + default: goto yy141; + } +yy146: + yych = *++YYCURSOR; + switch (yych) { + case 'o': goto yy149; + default: goto yy147; + } +yy147: + YYCURSOR = YYMARKER; + goto yy141; +yy148: + ++YYCURSOR; +#line 435 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { if (item.type == SendOp) {goto s_12;} else {goto s_err;}; } +#line 1862 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy149: + yych = *++YYCURSOR; + switch (yych) { + case 'm': goto yy150; + default: goto yy147; + } +yy150: + ++YYCURSOR; +#line 436 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { if (item.type == RecvOp) {goto s_12;} else {goto s_err;}; } +#line 1873 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 438 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_12: + state = 12; + // printf("Entered s_12\n"); + + s->tok = cursor; + + +#line 1887 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy154; + case '-': goto yy156; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy157; + default: goto yy152; + } +yy152: + ++YYCURSOR; +yy153: +#line 452 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1913 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy154: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy154; + default: goto yy155; + } +yy155: +#line 449 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_12; } +#line 1926 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy156: + yych = *++YYCURSOR; + switch (yych) { + case '1': goto yy159; + default: goto yy153; + } +yy157: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy157; + default: goto yy158; + } +yy158: +#line 451 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.target = add_number(s->tok, cursor); goto s_13; } +#line 1953 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy159: + ++YYCURSOR; +#line 450 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + {if (item.type == RecvOp) {item.target = std::numeric_limits::max(); goto s_13;} else {goto s_err;}; } +#line 1958 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 453 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_13: + state = 13; + // printf("Entered s_13\n"); + + +#line 1970 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy163; + case '\n': goto yy165; + case '\r': goto yy166; + case 'c': goto yy167; + case 'n': goto yy168; + case 't': goto yy169; + default: goto yy161; + } +yy161: + ++YYCURSOR; +yy162: +#line 467 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 1990 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy163: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy163; + default: goto yy164; + } +yy164: +#line 462 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_13; } +#line 2003 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy165: + ++YYCURSOR; +#line 466 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 2008 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy166: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy165; + default: goto yy162; + } +yy167: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'p': goto yy170; + default: goto yy162; + } +yy168: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'i': goto yy172; + default: goto yy162; + } +yy169: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'a': goto yy173; + default: goto yy162; + } +yy170: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy174; + default: goto yy171; + } +yy171: + YYCURSOR = YYMARKER; + goto yy162; +yy172: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy175; + default: goto yy171; + } +yy173: + yych = *++YYCURSOR; + switch (yych) { + case 'g': goto yy176; + default: goto yy171; + } +yy174: + ++YYCURSOR; +#line 464 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_16; } +#line 2058 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy175: + ++YYCURSOR; +#line 465 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_18; } +#line 2063 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy176: + ++YYCURSOR; +#line 463 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_14; } +#line 2068 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 468 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_14: + state = 14; + // printf("Entered s_14\n"); + + s->tok = cursor; + + +#line 2082 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy180; + case '-': goto yy182; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy183; + default: goto yy178; + } +yy178: + ++YYCURSOR; +yy179: +#line 482 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2108 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy180: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy180; + default: goto yy181; + } +yy181: +#line 479 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_14; } +#line 2121 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy182: + yych = *++YYCURSOR; + switch (yych) { + case '1': goto yy185; + default: goto yy179; + } +yy183: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy183; + default: goto yy184; + } +yy184: +#line 481 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.tag = add_number(s->tok, cursor); goto s_15; } +#line 2148 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy185: + ++YYCURSOR; +#line 480 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.tag = std::numeric_limits::max(); goto s_15; } +#line 2153 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 483 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_15: + state =15; + // printf("Entered s_15\n"); + + +#line 2165 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy189; + case '\n': goto yy191; + case '\r': goto yy192; + case 'c': goto yy193; + case 'n': goto yy194; + default: goto yy187; + } +yy187: + ++YYCURSOR; +yy188: +#line 496 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2184 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy189: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy189; + default: goto yy190; + } +yy190: +#line 492 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_15; } +#line 2197 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy191: + ++YYCURSOR; +#line 495 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 2202 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy192: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy191; + default: goto yy188; + } +yy193: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'p': goto yy195; + default: goto yy188; + } +yy194: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'i': goto yy197; + default: goto yy188; + } +yy195: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy198; + default: goto yy196; + } +yy196: + YYCURSOR = YYMARKER; + goto yy188; +yy197: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy199; + default: goto yy196; + } +yy198: + ++YYCURSOR; +#line 493 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_16; } +#line 2240 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy199: + ++YYCURSOR; +#line 494 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_18; } +#line 2245 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 497 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_16: + state = 16; + // printf("Entered s_16\n"); + + s->tok = cursor; + + +#line 2259 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy202; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy204; + default: goto yy201; + } +yy201: + ++YYCURSOR; +#line 510 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2283 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy202: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy202; + default: goto yy203; + } +yy203: +#line 508 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_16; } +#line 2296 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy204: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy204; + default: goto yy205; + } +yy205: +#line 509 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.cpu = add_number(s->tok, cursor); goto s_17; } +#line 2317 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 511 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_17: + state = 17; + // printf("Entered s_17\n"); + + +#line 2329 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy209; + case '\n': goto yy211; + case '\r': goto yy212; + case 'n': goto yy213; + default: goto yy207; + } +yy207: + ++YYCURSOR; +yy208: +#line 523 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2347 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy209: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy209; + default: goto yy210; + } +yy210: +#line 520 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_17; } +#line 2360 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy211: + ++YYCURSOR; +#line 522 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 2365 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy212: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy211; + default: goto yy208; + } +yy213: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'i': goto yy214; + default: goto yy208; + } +yy214: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy216; + default: goto yy215; + } +yy215: + YYCURSOR = YYMARKER; + goto yy208; +yy216: + ++YYCURSOR; +#line 521 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_18; } +#line 2391 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 524 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_18: + state = 18; + // printf("Entered s_18\n"); + + s->tok = cursor; + + +#line 2405 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy219; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy221; + default: goto yy218; + } +yy218: + ++YYCURSOR; +#line 537 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2429 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy219: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy219; + default: goto yy220; + } +yy220: +#line 535 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_18; } +#line 2442 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy221: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy221; + default: goto yy222; + } +yy222: +#line 536 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { item.nic = add_number(s->tok, cursor); goto s_19; } +#line 2463 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 538 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_19: + state = 19; + // printf("Entered s_19\n"); + + +#line 2475 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy226; + case '\n': goto yy228; + case '\r': goto yy229; + default: goto yy224; + } +yy224: + ++YYCURSOR; +yy225: +#line 549 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2492 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy226: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy226; + default: goto yy227; + } +yy227: +#line 547 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_19; } +#line 2505 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy228: + ++YYCURSOR; +#line 548 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; process_item(s, &item); continue; } +#line 2510 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy229: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy228; + default: goto yy225; + } + } +#line 550 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_20: + state = 20; + // printf("Entered s_20\n"); + + s->tok = cursor; + + +#line 2530 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy232; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy234; + default: goto yy231; + } +yy231: + ++YYCURSOR; +#line 563 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2554 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy232: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy232; + default: goto yy233; + } +yy233: +#line 561 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_20; } +#line 2567 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy234: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy234; + default: goto yy235; + } +yy235: +#line 562 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->rank = add_number(s->tok, cursor); s->curr_rank = s->rank; goto s_21; } +#line 2588 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 564 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_21: + state = 21; + // printf("Entered s_21\n"); + + +#line 2600 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy238; + case '{': goto yy240; + default: goto yy237; + } +yy237: + ++YYCURSOR; +#line 575 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2615 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy238: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy238; + default: goto yy239; + } +yy239: +#line 573 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_21; } +#line 2628 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy240: + ++YYCURSOR; +#line 574 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_0; } +#line 2633 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 576 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_22: + state = 22; + // printf("Entered s_22\n"); + + s->tok = cursor; + + +#line 2647 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy243; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy245; + default: goto yy242; + } +yy242: + ++YYCURSOR; +#line 589 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_err; } +#line 2671 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy243: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '\t': + case ' ': goto yy243; + default: goto yy244; + } +yy244: +#line 587 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_22; } +#line 2684 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy245: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy245; + default: goto yy246; + } +yy246: +#line 588 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->num_ranks = add_number(s->tok, cursor); goto s_0; } +#line 2705 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 590 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_23: + state = 23; + // printf("Entered s_23\n"); + + +#line 2717 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\n': goto yy250; + case '\r': goto yy251; + default: goto yy248; + } +yy248: + ++YYCURSOR; +yy249: +#line 600 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_23; } +#line 2732 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy250: + ++YYCURSOR; +#line 599 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; continue; } +#line 2737 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy251: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy250; + default: goto yy249; + } + } +#line 601 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_24: + state = 24; + // printf("Entered s_24\n"); + + +#line 2755 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + { + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case '\n': goto yy255; + case '\r': goto yy256; + case '*': goto yy257; + default: goto yy253; + } +yy253: + ++YYCURSOR; +yy254: +#line 612 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { goto s_24; } +#line 2771 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy255: + ++YYCURSOR; +#line 611 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { s->line++; goto s_24; } +#line 2776 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" +yy256: + yych = *++YYCURSOR; + switch (yych) { + case '\n': goto yy255; + default: goto yy254; + } +yy257: + yych = *++YYCURSOR; + switch (yych) { + case '/': goto yy258; + default: goto yy254; + } +yy258: + ++YYCURSOR; +#line 610 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + { continue; } +#line 2793 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.cpp" + } +#line 613 "/Users/tim0s/Work/LogGOPSim/src/LogGOPSim/txt2bin.re" + + + assert(0==1); //We should never reach this line + +s_err: + + fprintf(stderr, "Error in line %i:\n", s->line); + + uchar* nlbef = s->bot; + uchar* nlaft = s->lim; + // find the last newline before the error + uchar* c = cursor-2; + while (c>s->bot) { + c--; + if (*c == '\n') { + nlbef = c; + break; + } + } + // find the next newline after the error + c = cursor-2; + while (clim) { + c++; + if (*c == '\n') { + nlaft = c; + break; + } + } + + for (uchar* c = nlbef+1; c; + + uint32_t numranks = -1; + + while (true) { + + in.schedule = new Goal; + + scan(&in); + + if (in.num_ranks < 1) { + fprintf(stderr, "Parse error: Number of Ranks undefined\n"); + exit(EXIT_FAILURE); + } + + in.idtbl->clear(); + + in.schedule->SetRank(in.curr_rank); + in.schedule->SetNumRanks(in.num_ranks); + in.schedule->SerializeSchedule(args_info.output_arg); + delete in.schedule; + int newprogress = round((((double) in.curr_rank) / in.num_ranks)*100); + if (args_info.progress_given && (newprogress > lastprogress) ) { + lastprogress = newprogress; + printf("Progress %i%% - parsed schedule %i/%i\n", lastprogress, in.curr_rank, in.num_ranks); + } + if (in.curr_rank+1 == in.num_ranks) break; + } + + free(in.bot); + exit(EXIT_SUCCESS); +} diff --git a/src/LogGOPSim/txt2bin_cmdline.c b/src/LogGOPSim/txt2bin_cmdline.c new file mode 100644 index 0000000..a3a3709 --- /dev/null +++ b/src/LogGOPSim/txt2bin_cmdline.c @@ -0,0 +1,600 @@ +/* + 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 new file mode 100644 index 0000000..065e24e --- /dev/null +++ b/src/LogGOPSim/txt2bin_cmdline.h @@ -0,0 +1,184 @@ +/** @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 new file mode 100644 index 0000000..7b00db4 --- /dev/null +++ b/src/Schedgen/schedgen_cmdline.c @@ -0,0 +1,1060 @@ +/* + 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 new file mode 100644 index 0000000..0e46fac --- /dev/null +++ b/src/Schedgen/schedgen_cmdline.h @@ -0,0 +1,260 @@ +/** @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 */ diff --git a/src/Schedgen2/__pycache__/additional_microbenchmarks.cpython-311.pyc b/src/Schedgen2/__pycache__/additional_microbenchmarks.cpython-311.pyc new file mode 100644 index 0000000..bb25b57 Binary files /dev/null and b/src/Schedgen2/__pycache__/additional_microbenchmarks.cpython-311.pyc differ diff --git a/src/Schedgen2/__pycache__/goal.cpython-311.pyc b/src/Schedgen2/__pycache__/goal.cpython-311.pyc new file mode 100644 index 0000000..98a0116 Binary files /dev/null and b/src/Schedgen2/__pycache__/goal.cpython-311.pyc differ diff --git a/src/Schedgen2/__pycache__/mpi_colls.cpython-311.pyc b/src/Schedgen2/__pycache__/mpi_colls.cpython-311.pyc new file mode 100644 index 0000000..84ca672 Binary files /dev/null and b/src/Schedgen2/__pycache__/mpi_colls.cpython-311.pyc differ diff --git a/src/Schedgen2/__pycache__/patterns.cpython-311.pyc b/src/Schedgen2/__pycache__/patterns.cpython-311.pyc new file mode 100644 index 0000000..797b0e3 Binary files /dev/null and b/src/Schedgen2/__pycache__/patterns.cpython-311.pyc differ diff --git a/src/Schedgen2/schedule.goal b/src/Schedgen2/schedule.goal new file mode 100644 index 0000000..99ba26a --- /dev/null +++ b/src/Schedgen2/schedule.goal @@ -0,0 +1,44 @@ +num_ranks 8 + +rank 0 { +l1: send 8b to 1 tag 42001 +l2: send 8b to 2 tag 42001 +l3: send 8b to 4 tag 42001 +} + +rank 1 { +l4: recv 8b from 0 tag 42001 +l5: send 8b to 3 tag 42001 +l6: send 8b to 5 tag 42001 +l5 requires l4 +l6 requires l4 +} + +rank 2 { +l7: recv 8b from 0 tag 42001 +l8: send 8b to 6 tag 42001 +l8 requires l7 +} + +rank 3 { +l9: recv 8b from 1 tag 42001 +l10: send 8b to 7 tag 42001 +l10 requires l9 +} + +rank 4 { +l11: recv 8b from 0 tag 42001 +} + +rank 5 { +l12: recv 8b from 1 tag 42001 +} + +rank 6 { +l13: recv 8b from 2 tag 42001 +} + +rank 7 { +l14: recv 8b from 3 tag 42001 +} + diff --git a/src/liballprof2/gencode.py b/src/liballprof2/gencode.py index c8fa760..8c06820 100755 --- a/src/liballprof2/gencode.py +++ b/src/liballprof2/gencode.py @@ -19,6 +19,62 @@ def parse_semantics(self, semfile): self.semantics = yaml.safe_load(stream) except yaml.YAMLError as exc: print(exc) + + def get_param_names(self, func): + names = [] + params = self.semantics[func]['params'] + for p in params: + names += [p['name']] + return names + + def get_param_argtype(self, argname, funcname): + for p in self.semantics[funcname]['params']: + if p['name'] == argname: + return p['type'] + return None + + def is_ptr_arg(self, argname, funcname): + if self.is_ptr(self.get_param_argtype(argname, funcname)): + return True + else: + return False + + def is_inttype(self, typestr): + """ Check if typestr is a type which we can cast to a long long int without loosing precision """ + if typestr in ['int', 'MPI_Aint', 'MPI_Offset', 'MPI_Count']: + return True + return False + + def is_ptr(self, typestr): + if typestr in [None, ""]: + return True + if ("*" in typestr) or ("[" in typestr): + return True + return False + + + def deref_args(self, expr, funcname): + """ + We use C snippets (which might reference arguments) to describe how many elements arrays contain. + For example a function f might have two arguments, arr and count. And we know (in C syntax) that arr contains count elements. + This function translates expr to Fortran-compatible arguments, where all simple args are pointers, and thus need to be + dereferenced. + """ + params = self.get_param_names(funcname) + for p in params: + if self.is_ptr_arg(p, funcname): + continue + expr_new = "" + m = True + while m: + m = re.match(f"(.*?\W|^){p}($|\W.*)", expr) + if m is None: + break + expr_new += m.group(1)+f"(*{p})" + expr = m.group(2) + expr = expr_new + expr + return expr + def write_prolog(self, mode='c'): if mode == 'fortran': @@ -90,16 +146,7 @@ def get_basetype(self, typestr): elems = elems[:-1] return elems[-1] - def is_inttype(self, typestr): - """ Check if typestr is a type which we can cast to a long long int without loosing precision """ - if typestr in ['int', 'MPI_Aint', 'MPI_Offset', 'MPI_Count']: - return True - return False - - def is_ptr(self, typestr): - if ("*" in typestr) or ("[" in typestr): - return True - return False + def trace_inttype(self, name, typestr, basetype, is_ptr, sep): deref = "" @@ -156,14 +203,30 @@ def tracer_for_simple_arg(self, name, typestr, func, sep=":"): print(f"{typestr} tracer not implemmented (appears in {func}, basetype is {basetype})") return "" + def tracer_for_simple_arg_fortran(self, name, typestr, func, sep=":"): + # strip const, shouldn't make a difference how we trace + if typestr.startswith("const "): + typestr = typestr[6:] + # handle this special case first + if typestr == "int[3]": + return f" WRITE_TRACE(\"[%i,%i,%i]{sep}\", *(&({name})+0), *(&({name})+1), *(&({name})+2));\n" + basetype = self.get_basetype(typestr) + if not self.is_ptr_arg(name, func): + return f" WRITE_TRACE(\"%lli{sep}\", (long long int) *{name});\n" + else: + return f" WRITE_TRACE(\"%lli{sep}\", (long long int) {name});\n" + + def write_argument_tracers(self, func, mode): - if mode == 'fortran': - return # collect all needed prologs (code that we need to decide how many elemnts are in an array, like getting comm size) prologs = [] for sem_param in self.semantics[func]['params']: if ('prolog_elem_count' in sem_param) and (sem_param['prolog_elem_count'] is not None): - prologs.append(sem_param['prolog_elem_count']) + if mode == 'c': + prologs.append(sem_param['prolog_elem_count']) + if mode == 'fortran': + prolog = self.deref_args(sem_param['prolog_elem_count'], func) + prologs.append(prolog) prologs = list(set(prologs)) if len(prologs) > 0: self.outfile.write("\n".join(prologs)+"\n//end of prologs\n") @@ -176,6 +239,8 @@ def write_argument_tracers(self, func, mode): elem_count_expr = "0" if ('elem_count' in sem_param) and (sem_param['elem_count'] is not None): elem_count_expr = sem_param['elem_count'] + if (mode == 'fortran'): + elem_count_expr = self.deref_args(elem_count_expr, func) self.outfile.write(f" WRITE_TRACE(\"%p,%i[\", (void*) {sem_param['name']}, (int) {elem_count_expr});\n") self.outfile.write(f" if (0) {{ }} else {{ \n") self.outfile.write(f" for (int trace_elem_idx=0; trace_elem_idx<{elem_count_expr}; trace_elem_idx++) "+"{\n") @@ -184,13 +249,19 @@ def write_argument_tracers(self, func, mode): name = sem_param['name'] + "[trace_elem_idx]" basetype, brackets = self.split_type(sem_param['type']) typestr = basetype + brackets[2:] - code = self.tracer_for_simple_arg(name, typestr, func, sep=";") + if mode == 'c': + code = self.tracer_for_simple_arg(name, typestr, func, sep=";") + else: + code = self.tracer_for_simple_arg_fortran(name, typestr, func, sep=";") self.outfile.write(" "+code) self.outfile.write(" }\n") self.outfile.write(" WRITE_TRACE(\"]%s\", \":\");\n") self.outfile.write("}\n") else: - code = self.tracer_for_simple_arg(sem_param['name'], sem_param['type'], func, sep=":") + if mode == 'c': + code = self.tracer_for_simple_arg(sem_param['name'], sem_param['type'], func, sep=":") + else: + code = self.tracer_for_simple_arg_fortran(sem_param['name'], sem_param['type'], func, sep=":") self.outfile.write(" " + code) @@ -198,7 +269,10 @@ def produce_fortran_pmpi_prototypes(self): for func in self.semantics: param_signatures = [] for param in self.semantics[func]['params']: - param_signatures.append(f"int* {param['name']}") + argtype = "int*" + if "char" in self.get_param_argtype(param['name'], func): + argtype = "char*" + param_signatures.append(f"{argtype} {param['name']}") param_signatures.append("int* ierr") params = ", ".join(param_signatures) pfunc = f"P{func}" @@ -223,7 +297,10 @@ def produce_tracers(self, mode='c'): type_prefix, type_suffix = self.split_type(param['type']) param_signatures.append(f"{type_prefix} {param['name']}{type_suffix}") elif mode == 'fortran': - param_signatures.append(f"int* {param['name']}") + argtype = "int*" + if "char" in self.get_param_argtype(param['name'], func): + argtype = "char*" + param_signatures.append(f"{argtype} {param['name']}") if mode == 'fortran': param_signatures.append("int* ierr") params = ", ".join(param_signatures) diff --git a/src/liballprof2/gensem.py b/src/liballprof2/gensem.py index 188e093..06b4746 100755 --- a/src/liballprof2/gensem.py +++ b/src/liballprof2/gensem.py @@ -40,8 +40,8 @@ def __init__(self, libclang_path): def get_count_for_param_in_func(self, param, func): # TODO minimize this mapping = {} - GET_NDIMS_CART_COMM = "int ndims; MPI_Cartdim_get(comm, &ndims);" - GET_COMM_SIZE = "int rank, size; MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);" + GET_NDIMS_CART_COMM = "int ndims; PMPI_Cartdim_get(comm, &ndims);" + GET_COMM_SIZE = "int rank, size; PMPI_Comm_size(comm, &size); PMPI_Comm_rank(comm, &rank);" GET_NEIGH_GRAPH_COMM = "int ideg, odeg, wted; MPI_Dist_graph_neighbors_count(comm, &ideg, &odeg, &wted);" mapping[("MPI_Cart_create", "dims")] = "ndims" mapping[("MPI_Cart_create", "periods")] = "ndims"