brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 8bf02ea Raw
86 lines · c
1/*2 * Copyright 2017      Sven Verdoolaege3 *4 * Use of this software is governed by the MIT license5 *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_END26 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 whether48 * they are equivalent.49 * Return EXIT_SUCCESS if they are and EXIT_FAILURE if they are not50 * 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(&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 72	equal = isl_schedule_plain_is_equal(s1, s2);73	if (equal < 0)74		return EXIT_FAILURE;75	if (!equal)76		die("schedules differ");77 78	isl_schedule_free(s1);79	isl_schedule_free(s2);80	fclose(input1);81	fclose(input2);82	isl_ctx_free(ctx);83 84	return EXIT_SUCCESS;85}86