keep track of PPCG git version
[ppcg.git] / ppcg.c
blobd4ab63bd77a85d0ea9661805fa854ed27c9faea3
1 /*
2 * Copyright 2011 INRIA Saclay
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 #include <assert.h>
12 #include <stdio.h>
13 #include <isl/ctx.h>
14 #include <isl/options.h>
15 #include <isl/schedule.h>
16 #include <pet.h>
17 #include "ppcg_options.h"
18 #include "cuda.h"
19 #include "cpu.h"
21 struct options {
22 struct isl_options *isl;
23 struct pet_options *pet;
24 struct ppcg_options *ppcg;
25 char *input;
28 const char *ppcg_version(void);
29 static void print_version(void)
31 printf("%s", ppcg_version());
34 ISL_ARGS_START(struct options, options_args)
35 ISL_ARG_CHILD(struct options, isl, "isl", &isl_options_args, "isl options")
36 ISL_ARG_CHILD(struct options, pet, "pet", &pet_options_args, "pet options")
37 ISL_ARG_CHILD(struct options, ppcg, NULL, &ppcg_options_args, "ppcg options")
38 ISL_ARG_ARG(struct options, input, "input", NULL)
39 ISL_ARG_VERSION(print_version)
40 ISL_ARGS_END
42 ISL_ARG_DEF(options, struct options, options_args)
44 int main(int argc, char **argv)
46 int r;
47 isl_ctx *ctx;
48 struct options *options;
49 struct pet_scop *scop;
51 options = options_new_with_defaults();
52 assert(options);
54 ctx = isl_ctx_alloc_with_options(&options_args, options);
55 isl_options_set_schedule_outer_zero_distance(ctx, 1);
56 argc = options_parse(options, argc, argv, ISL_ARG_ALL);
58 scop = pet_scop_extract_from_C_source(ctx, options->input, NULL);
60 if (options->ppcg->target == PPCG_TARGET_CUDA)
61 r = generate_cuda(ctx, scop, options->ppcg, options->input);
62 else
63 r = generate_cpu(ctx, scop, options->ppcg, options->input);
65 pet_scop_free(scop);
67 isl_ctx_free(ctx);
69 return r;