Last active
July 21, 2017 07:08
-
-
Save annanay25/dfc6b3eff6e389fd5eaf76219a472a48 to your computer and use it in GitHub Desktop.
isl_union_map_coalesce sub-optimally merges 4 pieces in 'test' to 2 pieces. A simpler 1 piece solution is 'orig_simplified'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include "isl/flow.h" | |
#include "isl/ctx.h" | |
#include "isl/val.h" | |
#include "isl/set.h" | |
#include "isl/map.h" | |
#include "isl/union_map.h" | |
#include "isl/union_set.h" | |
#include "isl/flow.h" | |
#include "isl/schedule.h" | |
#include "string.h" | |
#include "assert.h" | |
#define PRINT(name, obj) {isl_printer_start_line(printer); \ | |
isl_printer_print_str(printer, "\n\n" #obj ":\n----\n"); \ | |
isl_printer_print_##name(printer, obj); isl_printer_end_line(printer);} | |
int main() { | |
isl_ctx *ctx = isl_ctx_alloc(); | |
isl_printer *printer = isl_printer_to_str(ctx); | |
isl_union_map *test = isl_union_map_read_from_str(ctx, "{ Stmt_loop_body_reduction[i0, i1] -> MemRef_retval[o0, o1] : (i0 = 1 and i1 = 1 and o0 = 1 and o1 = 1) or (i0 = 0 and i1 = 1 and o0 = 0 and o1 = 1) or (i0 = 1 and i1 = 0 and o0 = 1 and o1 = 0) or (i0 = 0 and i1 = 0 and o0 = 0 and o1 = 0) } "); | |
PRINT(union_map, test); | |
char *test_str = isl_printer_get_str(printer); | |
printf("%s", test_str); | |
isl_printer_flush(printer); | |
isl_union_map *simplified = isl_union_map_coalesce(test); | |
PRINT(union_map, simplified); | |
char *simplified_str = isl_printer_get_str(printer); | |
printf("%s", simplified_str); | |
isl_union_map *orig_simplified = isl_union_map_read_from_str(ctx, "{ Stmt_loop_body_reduction[i0, i1] -> MemRef_retval[o0, o1] : ( 0 <= i0 <=1 and 0 <= i1 <=1 and o0 = i0 and o1 = i1 ) }"); | |
assert(isl_bool_true == isl_union_map_is_equal(simplified, orig_simplified)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
(Assertion is satisfied - hence, it can be further simplified).