示例#1
0
void get_string(int argc, char *argv[], int *pos, char *val) {

  if (*pos + 1 >= argc) {
    fprintf(stderr, "\n%s: argument %s expects an extra argument; "
            "none found\n", Progname, argv[*pos]);
    usage_message(stdout);
    exit(1);
  }

  strcpy(val, argv[*pos+1]);

  (*pos)++;

} /* end get_string() */
示例#2
0
/**
 * Error in dependency specification
 *
 * @param fmt the error message format
 */
static void
dep_usage(char const * fmt, ...)
{
    char * msg;

    {
        va_list ap;
        va_start(ap, fmt);
        (void)vasprintf(&msg, fmt, ap);
        va_end(ap);
    }

    usage_message(USAGE_INVAL_DEP_OPT_FMT, msg);
    /* NOTREACHED */
}
示例#3
0
文件: mace4.c 项目: axelrod9/ladr
int main(int argc, char **argv)
{
  struct mace_options opt;
  Plist clauses;
  Mace_results results;

  /* Following says whether to ignore unregognized set/clear/assigns. */
  BOOL prover_compatability_mode = member_args(argc, argv, "-c");

  init_standard_ladr();
  init_mace_options(&opt);  /* We must do this before calling usage_message. */
  init_attrs();

  if (member_args(argc, argv, "help") ||
      member_args(argc, argv, "-help")) {
    usage_message(stderr, &opt);
    exit(1);
  }

  print_banner(argc, argv, PROGRAM_NAME, PROGRAM_VERSION, PROGRAM_DATE, FALSE);
  set_program_name(PROGRAM_NAME);   /* for conditional input */

  signal(SIGINT,  mace4_sig_handler);
  signal(SIGUSR1, mace4_sig_handler);
  signal(SIGSEGV, mace4_sig_handler);

  clauses = read_mace4_input(argc, argv, prover_compatability_mode, &opt);

  print_separator(stdout, "CLAUSES FOR SEARCH", TRUE);
  fwrite_clause_list(stdout, clauses, "mace4_clauses", CL_FORM_BARE);
  print_separator(stdout, "end of clauses for search", TRUE);

  results = mace4(clauses, &opt);

  mace4_exit(results->return_code);  /* print messages and exit */

  exit(0);  /* won't happen */

}  /* main */
示例#4
0
文件: main.c 项目: tajkhan/pluto-osl
int main(int argc, char *argv[])
{
    int i;

    FILE *src_fp;

    int option;
    int option_index = 0;

    char *srcFileName;

    FILE *cloogfp, *outfp;

    if (argc <= 1)  {
        usage_message();
        return 1;
    }

    options = pluto_options_alloc();

    const struct option pluto_options[] =
    {
        {"tile", no_argument, &options->tile, 1},
        {"notile", no_argument, &options->tile, 0},
        {"intratileopt", no_argument, &options->intratileopt, 1},
        {"debug", no_argument, &options->debug, true},
        {"moredebug", no_argument, &options->moredebug, true},
        {"rar", no_argument, &options->rar, 1},
        {"identity", no_argument, &options->identity, 1},
        {"nofuse", no_argument, &options->fuse, NO_FUSE},
        {"maxfuse", no_argument, &options->fuse, MAXIMAL_FUSE},
        {"smartfuse", no_argument, &options->fuse, SMART_FUSE},
        {"parallel", no_argument, &options->parallel, 1},
        {"parallelize", no_argument, &options->parallel, 1},
        {"innerpar", no_argument, &options->innerpar, 1},
        {"unroll", no_argument, &options->unroll, 1},
        {"nounroll", no_argument, &options->unroll, 0},
        {"polyunroll", no_argument, &options->polyunroll, 1},
        {"bee", no_argument, &options->bee, 1},
        {"ufactor", required_argument, 0, 'u'},
        {"prevector", no_argument, &options->prevector, 1},
        {"noprevector", no_argument, &options->prevector, 0},
        {"context", required_argument, 0, 'c'},
        {"cloogf", required_argument, 0, 'F'},
        {"cloogl", required_argument, 0, 'L'},
        {"cloogsh", no_argument, &options->cloogsh, 1},
        {"nocloogbacktrack", no_argument, &options->cloogbacktrack, 0},
        {"forceparallel", required_argument, 0, 'p'},
        {"ft", required_argument, 0, 'f'},
        {"lt", required_argument, 0, 'l'},
        {"multipipe", no_argument, &options->multipipe, 1},
        {"l2tile", no_argument, &options->l2tile, 1},
        {"version", no_argument, 0, 'v'},
        {"help", no_argument, 0, 'h'},
        {"indent", no_argument, 0, 'i'},
        {"silent", no_argument, &options->silent, 1},
        {"lastwriter", no_argument, &options->lastwriter, 1},
        {"nobound", no_argument, &options->nobound, 1},
        {"scalpriv", no_argument, &options->scalpriv, 1},
        {"isldep", no_argument, &options->isldep, 1},
        {"isldepcompact", no_argument, &options->isldepcompact, 1},
        {"readscoplib", no_argument, &options->readscoplib, 1},
        {"islsolve", no_argument, &options->islsolve, 1},
        {0, 0, 0, 0}
    };


    /* Read command-line options */
    while (1) {
        option = getopt_long(argc, argv, "bhiqvf:l:F:L:c:o:", pluto_options,
                &option_index);

        if (option == -1)   {
            break;
        }

        switch (option) {
            case 0:
                break;
            case 'F':
                options->cloogf = atoi(optarg);
                break;
            case 'L':
                options->cloogl = atoi(optarg);
                break;
            case 'b':
                options->bee = 1;
                break;
            case 'c':
                options->context = atoi(optarg);
                break;
            case 'd':
                break;
            case 'f':
                options->ft = atoi(optarg);
                break;
            case 'g':
                break;
            case 'h':
                usage_message();
                return 2;
            case 'i':
                /* Handled in polycc */
                break;
            case 'l':
                options->lt = atoi(optarg);
                break;
            case 'm':
                break;
            case 'n':
                break;
            case 'o':
                options->out_file = strdup(optarg);
                break;
            case 'p':
                options->forceparallel = atoi(optarg);
                break;
            case 'q':
                options->silent = 1;
                break;
            case 's':
                break;
            case 'u':
                options->ufactor = atoi(optarg);
                break;
            case 'v':
                printf("PLUTO %s - An automatic parallelizer and locality optimizer\n\
Copyright (C) 2007--2008  Uday Kumar Bondhugula\n\
This is free software; see the source for copying conditions.  There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n", PLUTO_VERSION);
                pluto_options_free(options);
                return 3;
            default:
                usage_message();
                pluto_options_free(options);
                return 4;
        }
    }


    if (optind <= argc-1)   {
        srcFileName = alloca(strlen(argv[optind])+1);
        strcpy(srcFileName, argv[optind]);
    }else{
        /* No non-option argument was specified */
        usage_message();
        pluto_options_free(options);
        return 5;
    }

    src_fp  = fopen(srcFileName, "r");

    if (!src_fp)   {
        fprintf(stderr, "pluto: error opening source file: '%s'\n", srcFileName);
        pluto_options_free(options);
        return 6;
    }

    /* Extract polyhedral representation from input program */
    scoplib_scop_p scop;

    clan_options_p clanOptions = clan_options_malloc();

    if (options->readscoplib) scop = scoplib_scop_read(src_fp);
    else scop = clan_scop_extract(src_fp, clanOptions);

    if (!scop || !scop->statement)   {
        fprintf(stderr, "Error extracting polyhedra from source file: \'%s'\n",
                srcFileName);
        pluto_options_free(options);
        return 7;
    }
    FILE *srcfp = fopen(".srcfilename", "w");
    if (srcfp)    {
        fprintf(srcfp, "%s\n", srcFileName);
        fclose(srcfp);
    }

    /* IF_DEBUG(clan_scop_print_dot_scop(stdout, scop, clanOptions)); */

    /* Convert clan scop to Pluto program */
    PlutoProg *prog = scop_to_pluto_prog(scop, options);

    clan_options_free(clanOptions);

    /* Backup irregular program portion in .scop. */
    char* irroption = scoplib_scop_tag_content(scop, "<irregular>",
            "</irregular>");

    IF_DEBUG2(pluto_deps_print(stdout, prog));
    IF_DEBUG2(pluto_stmts_print(stdout, prog->stmts, prog->nstmts));


    int dim_sum=0;
    for (i=0; i<prog->nstmts; i++) {
        dim_sum += prog->stmts[i]->dim;
    }

    /* Make options consistent */
    if (options->multipipe == 1 && options->parallel == 0)    {
        fprintf(stdout, "Warning: multipipe needs parallel to be on; turning on parallel\n");
        options->parallel = 1;
    }

    /* Disable pre-vectorization if tile is not on */
    if (options->tile == 0 && options->prevector == 1) {
        /* If code will not be tiled, pre-vectorization does not make
         * sense */
        if (!options->silent)   {
            fprintf(stdout, "[Pluto] Warning: pre-vectorization does not fit (--tile is off)\n");
        }
        options->prevector = 0;
    }

    if (!options->silent)   {
        fprintf(stdout, "[Pluto] Number of statements: %d\n", prog->nstmts);
        fprintf(stdout, "[Pluto] Total number of loops: %d\n", dim_sum);
        fprintf(stdout, "[Pluto] Number of deps: %d\n", prog->ndeps);
        fprintf(stdout, "[Pluto] Maximum domain dimensionality: %d\n", prog->nvar);
        fprintf(stdout, "[Pluto] Number of parameters: %d\n", prog->npar);
    }

    /* Auto transformation */
    if (!options->identity) {
        pluto_auto_transform(prog);
    }
    pluto_detect_transformation_properties(prog);

    if (!options->silent)   {
        fprintf(stdout, "[Pluto] Affine transformations [<iter coeff's> <const>]\n\n");
        /* Print out transformations */
        pluto_transformations_pretty_print(prog);
        pluto_print_hyperplane_properties(prog);
    }

    if (options->tile)   {
        pluto_tile(prog);
    }else{
        if (options->intratileopt) {
            int retval = pluto_intra_tile_optimize(prog, 0); 
            if (retval) {
                /* Detect properties again */
                pluto_detect_transformation_properties(prog);
                if (!options->silent) {
                    printf("[Pluto] after intra tile opt\n");
                    pluto_transformations_pretty_print(prog);
                }
            }
        }
    }

    if (options->parallel && !options->tile && !options->identity)   {
        /* Obtain wavefront/pipelined parallelization by skewing if
         * necessary */
        int nbands;
        Band **bands;
        bands = pluto_get_outermost_permutable_bands(prog, &nbands);
        bool retval = create_tile_schedule(prog, bands, nbands);
        pluto_bands_free(bands, nbands);

        /* If the user hasn't supplied --tile and there is only pipelined
         * parallelism, we will warn the user */
        if (retval)   {
            printf("[Pluto] WARNING: pipelined parallelism exists and --tile is not used.\n");
            printf("use --tile for better parallelization \n");
            IF_DEBUG(fprintf(stdout, "[Pluto] After skewing:\n"););
            IF_DEBUG(pluto_transformations_pretty_print(prog););
示例#5
0
int _tmain(int argc, TCHAR* argv[])
{
	struct params_struct p;
	struct parsestate_struct ps;
	int ret;
	int i;
	int unicode_output=0;
	const TCHAR *optname;

	memset(&ps,0,sizeof(struct parsestate_struct));
	ps.param_type=PT_NONE;
	ps.untagged_param_count=0;
	ps.printversion=0;
	ps.showhelp=0;

#ifdef _UNICODE
	unicode_output=1;
	_setmode(_fileno(stdout),_O_U16TEXT);
#endif
#ifndef IW_NO_LOCALE
	setlocale(LC_CTYPE,"");
	unicode_output = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
#endif

	memset(&p,0,sizeof(struct params_struct));
	p.new_width = -1;
	p.new_height = -1;
	p.depth = -1;
	p.edge_policy = -1;
	p.bkgd_check_size = 16;
	p.bestfit = 0;
	p.offset_r_h=0.0; p.offset_g_h=0.0; p.offset_b_h=0.0;
	p.offset_r_v=0.0; p.offset_g_v=0.0; p.offset_b_v=0.0;
	p.infmt=IWCMD_FMT_UNKNOWN;
	p.outfmt=IWCMD_FMT_UNKNOWN;
	p.unicode_output=unicode_output;
	p.resize_alg_x.blur = 1.0;
	p.resize_alg_y.blur = 1.0;
	p.resize_alg_alpha.blur = 1.0;
	p.pngcmprlevel = -1;

	for(i=1;i<argc;i++) {
		if(argv[i][0]=='-' && ps.param_type==PT_NONE) {
			optname = &argv[i][1];
			// If the second char is also a '-', ignore it.
			if(argv[i][1]=='-')
				optname = &argv[i][2];
			if(!process_option_name(&p, &ps, optname)) {
				return 1;
			}
		}
		else {
			// Process a parameter of the previous option.

			if(!process_option_arg(&p, &ps, argv[i])) {
				return 1;
			}

			ps.param_type = PT_NONE;
		}
	}

	if(ps.showhelp) {
		usage_message(&p);
		return 0;
	}

	if(ps.printversion) {
		do_printversion(&p);
		return 0;
	}

	if(ps.untagged_param_count!=2 || ps.param_type!=PT_NONE) {
		usage_message(&p);
		return 1;
	}

	ret=run(&p);
	return ret?0:1;
}
示例#6
0
文件: pcopy.c 项目: brkorb/pcopy
/**
 * Make a destination name.  If the destination option is not provided,
 * the destination is the base name of the input file.  If the destination
 * is a directory, the base name of the source is always appended.
 * If the destination is a file, then make certain we only copy one file
 * to this destination.
 *
 * @param[in] sname  source file name.
 * @returns   the name of the corresponding output file.
 */
static inline char const *
make_dest_name(char const * sname)
{
    static char const no_dir[] =
        "no directory component in source name '%s'\n"
        "and no destination directory was specified.\n";

    if (! HAVE_OPT(DESTINATION)) {
        char const * p = strrchr(sname, '/');
        if (p == NULL)
            usage_message(no_dir, sname);
        unlink(++p);
        return strdup_or_die(p);
    }

    {
        static bool been_here = false;
        char const * dname = OPT_ARG(DESTINATION);
        struct stat sb;

        if (stat(dname, &sb) == 0) {
            if (S_ISDIR(sb.st_mode)) {
                char const * bn = strrchr(sname, '/');
                char * p;
                bn = bn ? (bn + 1) : sname;
                p  = malloc(strlen(dname) + strlen(bn) + 2);
                if (p == NULL)
                    fserr(PCOPY_EXIT_NO_MEM, "allocating", "destination name");
                sprintf(p, "%s/%s", dname, bn);
                unlink(p);
                return p;
            }
            if (S_ISREG(sb.st_mode)) {
                if (been_here)
                    die(PCOPY_EXIT_BAD_CONFIG,
                        "destination for multiple sources is one file");
                been_here = true;
                unlink(dname);
                return strdup_or_die(dname);
            }
            errno = EINVAL;
            fserr(PCOPY_EXIT_BAD_CONFIG,
                  "invalid destination fs type (not dir or file)", dname);
        }

        /*
         * We could not stat "dname".  It must be a file name.  Make sure any
         * directory part exists.  If we call this routine again, we should
         * successfully stat our destination file and trip over the
         * "been_here" flag.
         */
        dname = strdup_or_die(dname);
        been_here = true;
        {
            static char const bad_stat[] = "stat-ing dir portion";
            char * p = strrchr(dname, '/');
            if (p == NULL) {
                /*
                 * No directory part.  Destination file is for current dir.
                 */
                return dname;
            }

            *p = NUL;
            if (stat(dname, &sb) != 0)
                fserr(PCOPY_EXIT_BAD_CONFIG, bad_stat, OPT_ARG(DESTINATION));
            if (! S_ISDIR(sb.st_mode)) {
                errno = ENOTDIR;
                fserr(PCOPY_EXIT_BAD_CONFIG, bad_stat, OPT_ARG(DESTINATION));
            }
            *p = '/';
        }

        return dname;
    }
}