Polly 19.0.0git
schedule_cmp.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 Sven Verdoolaege
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege.
7 */
8
9#include <stdlib.h>
10
11#include <isl/arg.h>
12#include <isl/options.h>
13#include <isl/schedule.h>
14
15struct options {
16 struct isl_options *isl;
17 char *schedule1;
18 char *schedule2;
19};
20
21ISL_ARGS_START(struct options, options_args)
22ISL_ARG_CHILD(struct options, isl, "isl", &isl_options_args, "isl options")
23ISL_ARG_ARG(struct options, schedule1, "schedule1", NULL)
24ISL_ARG_ARG(struct options, schedule2, "schedule2", NULL)
26
27ISL_ARG_DEF(options, struct options, options_args)
28
29static void die(const char *msg)
30{
31 fprintf(stderr, "%s\n", msg);
32 exit(EXIT_FAILURE);
33}
34
35static FILE *open_or_die(const char *filename)
36{
37 FILE *file;
38
39 file = fopen(filename, "r");
40 if (!file) {
41 fprintf(stderr, "Unable to open %s\n", filename);
42 exit(EXIT_FAILURE);
43 }
44 return file;
45}
46
47/* Given two YAML descriptions of isl_schedule objects, check whether
48 * they are equivalent.
49 * Return EXIT_SUCCESS if they are and EXIT_FAILURE if they are not
50 * or if anything else went wrong.
51 */
52int main(int argc, char **argv)
53{
54 isl_ctx *ctx;
55 struct options *options;
56 FILE *input1, *input2;
58 isl_schedule *s1, *s2;
59
60 options = options_new_with_defaults();
61 if (!options)
62 return EXIT_FAILURE;
63
64 ctx = isl_ctx_alloc_with_options(&options_args, options);
65 argc = options_parse(options, argc, argv, ISL_ARG_ALL);
66
67 input1 = open_or_die(options->schedule1);
68 input2 = open_or_die(options->schedule2);
69 s1 = isl_schedule_read_from_file(ctx, input1);
70 s2 = isl_schedule_read_from_file(ctx, input2);
71
73 if (equal < 0)
74 return EXIT_FAILURE;
75 if (!equal)
76 die("schedules differ");
77
80 fclose(input1);
81 fclose(input2);
82 isl_ctx_free(ctx);
83
84 return EXIT_SUCCESS;
85}
#define ISL_ARG_DEF(prefix, st, args)
Definition: arg.h:302
#define ISL_ARG_ARG(st, f, a, d)
Definition: arg.h:124
#define ISL_ARG_CHILD(st, f, l, c, h)
Definition: arg.h:264
#define ISL_ARG_ALL
Definition: arg.h:288
#define ISL_ARGS_START(s, name)
Definition: arg.h:113
#define ISL_ARGS_END
Definition: arg.h:117
isl_ctx * isl_ctx_alloc_with_options(struct isl_args *args, __isl_take void *opt)
isl_bool
Definition: ctx.h:89
void isl_ctx_free(isl_ctx *ctx)
Definition: isl_ctx.c:288
int equal
Definition: isl_test.c:7868
#define die(msg)
Definition: isl_test_cpp.cc:35
These are automatically generated checked C++ bindings for isl.
Definition: ISLTools.h:45
__isl_null isl_schedule * isl_schedule_free(__isl_take isl_schedule *sched)
Definition: isl_schedule.c:121
__isl_give isl_schedule * isl_schedule_read_from_file(isl_ctx *ctx, FILE *input)
isl_bool isl_schedule_plain_is_equal(__isl_keep isl_schedule *schedule1, __isl_keep isl_schedule *schedule2)
Definition: isl_schedule.c:175
static FILE * open_or_die(const char *filename)
Definition: schedule_cmp.c:35
char * schedule1
Definition: schedule_cmp.c:17
struct isl_options * isl
Definition: codegen.c:34
char * schedule2
Definition: schedule_cmp.c:18