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)
25ISL_ARGS_END
26
27ISL_ARG_DEF(options, struct options, options_args)
28
29static void die(const char *msg)
30{
31 fprintf(stderr, format: "%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: filename, modes: "r");
40 if (!file) {
41 fprintf(stderr, format: "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;
57 isl_bool equal;
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(args: &options_args, opt: options);
65 argc = options_parse(opt: options, argc, argv, ISL_ARG_ALL);
66
67 input1 = open_or_die(filename: options->schedule1);
68 input2 = open_or_die(filename: options->schedule2);
69 s1 = isl_schedule_read_from_file(ctx, input: input1);
70 s2 = isl_schedule_read_from_file(ctx, input: input2);
71
72 equal = isl_schedule_plain_is_equal(schedule1: s1, schedule2: s2);
73 if (equal < 0)
74 return EXIT_FAILURE;
75 if (!equal)
76 die(msg: "schedules differ");
77
78 isl_schedule_free(sched: s1);
79 isl_schedule_free(sched: s2);
80 fclose(stream: input1);
81 fclose(stream: input2);
82 isl_ctx_free(ctx);
83
84 return EXIT_SUCCESS;
85}
86

source code of polly/lib/External/isl/schedule_cmp.c