From 6b5587abc439a49b535dbe965bdc037f3743cd95 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 2 Apr 2014 14:10:22 +0200 Subject: [PATCH] explicitly mark kill accesses The access expression argument of a kill operation represents the set of array elements that are killed by the operation. This access expression is marked neither read nor write. Explicitly mark it as a kill access for clarity. The explicit marking will also be useful in printing different labels for the access relation. It is simply called "relation" now, but when we split the relation into may_read, may_write and must_write, then none of these labels are suitable for a kill access. Signed-off-by: Sven Verdoolaege --- emit.c | 21 +++++++++++++-------- expr.c | 36 ++++++++++++++++++++++++++++++++---- expr.h | 5 +++-- include/pet.h | 3 +++ parse.c | 3 +++ tests/autodetect/decl.scop | 3 +-- tests/decl.scop | 6 ++---- tests/decl2.scop | 3 +-- tests/decl3.scop | 3 +-- tests/encapsulate/for_while.scop | 6 ++---- tests/encapsulate/independent5.scop | 6 ++---- tests/encapsulate/inf_break.scop | 6 ++---- tests/for_while_inc2.scop | 6 ++---- tests/for_while_inc3.scop | 6 ++---- tests/for_while_init.scop | 6 ++---- tests/for_while_init2.scop | 6 ++---- tests/for_while_init3.scop | 6 ++---- tests/forward_substitution3.scop | 6 ++---- tests/independent3.scop | 6 ++---- 19 files changed, 79 insertions(+), 64 deletions(-) diff --git a/emit.c b/emit.c index 377beb9..c80a51d 100644 --- a/emit.c +++ b/emit.c @@ -493,14 +493,19 @@ static int emit_access_expr(yaml_emitter_t *emitter, __isl_keep pet_expr *expr) if (expr->acc.ref_id && emit_named_id(emitter, "reference", expr->acc.ref_id) < 0) return -1; - if (emit_string(emitter, "read") < 0) - return -1; - if (emit_int(emitter, expr->acc.read) < 0) - return -1; - if (emit_string(emitter, "write") < 0) - return -1; - if (emit_int(emitter, expr->acc.write) < 0) - return -1; + if (expr->acc.kill) { + if (emit_named_unsigned(emitter, "kill", 1) < 0) + return -1; + } else { + if (emit_string(emitter, "read") < 0) + return -1; + if (emit_int(emitter, expr->acc.read) < 0) + return -1; + if (emit_string(emitter, "write") < 0) + return -1; + if (emit_int(emitter, expr->acc.write) < 0) + return -1; + } return 0; } diff --git a/expr.c b/expr.c index b7b04b0..78cc714 100644 --- a/expr.c +++ b/expr.c @@ -275,6 +275,7 @@ __isl_give pet_expr *pet_expr_kill_from_access_and_index( expr = pet_expr_from_access_and_index(access, index); expr = pet_expr_access_set_read(expr, 0); + expr = pet_expr_access_set_kill(expr, 1); return pet_expr_new_unary(pet_op_kill, expr); error: isl_map_free(access); @@ -491,6 +492,7 @@ static __isl_give pet_expr *pet_expr_dup(__isl_keep pet_expr *expr) isl_map_copy(expr->acc.access)); dup = pet_expr_access_set_read(dup, expr->acc.read); dup = pet_expr_access_set_write(dup, expr->acc.write); + dup = pet_expr_access_set_kill(dup, expr->acc.kill); break; case pet_expr_call: dup = pet_expr_call_set_name(dup, expr->name); @@ -911,6 +913,8 @@ int pet_expr_is_equal(__isl_keep pet_expr *expr1, __isl_keep pet_expr *expr2) return 0; if (expr1->acc.write != expr2->acc.write) return 0; + if (expr1->acc.kill != expr2->acc.kill) + return 0; if (expr1->acc.ref_id != expr2->acc.ref_id) return 0; if (!expr1->acc.index || !expr2->acc.index) @@ -1841,6 +1845,26 @@ __isl_give pet_expr *pet_expr_access_set_write(__isl_take pet_expr *expr, return expr; } +/* Mark "expr" as a kill dependening on "kill". + */ +__isl_give pet_expr *pet_expr_access_set_kill(__isl_take pet_expr *expr, + int kill) +{ + if (!expr) + return pet_expr_free(expr); + if (expr->type != pet_expr_access) + isl_die(pet_expr_get_ctx(expr), isl_error_invalid, + "not an access expression", return pet_expr_free(expr)); + if (expr->acc.kill == kill) + return expr; + expr = pet_expr_cow(expr); + if (!expr) + return NULL; + expr->acc.kill = kill; + + return expr; +} + /* Replace the access relation of "expr" by "access". */ __isl_give pet_expr *pet_expr_access_set_access(__isl_take pet_expr *expr, @@ -3155,10 +3179,14 @@ void pet_expr_dump_with_indent(__isl_keep pet_expr *expr, int indent) isl_multi_pw_aff_dump(expr->acc.index); fprintf(stderr, "%*sdepth: %d\n", indent + 2, "", expr->acc.depth); - fprintf(stderr, "%*sread: %d\n", indent + 2, - "", expr->acc.read); - fprintf(stderr, "%*swrite: %d\n", indent + 2, - "", expr->acc.write); + if (expr->acc.kill) { + fprintf(stderr, "%*skill: 1\n", indent + 2, ""); + } else { + fprintf(stderr, "%*sread: %d\n", indent + 2, + "", expr->acc.read); + fprintf(stderr, "%*swrite: %d\n", indent + 2, + "", expr->acc.write); + } if (expr->acc.access) { fprintf(stderr, "%*saccess: ", indent + 2, ""); isl_map_dump(expr->acc.access); diff --git a/expr.h b/expr.h index 3260b41..97f9b7f 100644 --- a/expr.h +++ b/expr.h @@ -59,9 +59,9 @@ extern "C" { * An access expresssion is marked "read" if it represents a read and * marked "write" if it represents a write. A single access expression * may be marked both read and write. - * It may also be marked neither read or write, in which case it + * Alternatively, the expression may be marked "kill", in which case it * is the argument of a kill operation and represents the set of - * killed array elements. + * killed array elements. Such accesses are marked neither read nor write. * * A double is represented as both an (approximate) value "val" and * a string representation "s". @@ -85,6 +85,7 @@ struct pet_expr { int depth; unsigned read : 1; unsigned write : 1; + unsigned kill : 1; } acc; enum pet_op_type op; char *name; diff --git a/include/pet.h b/include/pet.h index 8c90407..21ae1b7 100644 --- a/include/pet.h +++ b/include/pet.h @@ -173,6 +173,9 @@ __isl_give pet_expr *pet_expr_access_set_read(__isl_take pet_expr *expr, /* Mark "expr" as a write dependening on "write". */ __isl_give pet_expr *pet_expr_access_set_write(__isl_take pet_expr *expr, int write); +/* Mark "expr" as a kill dependening on "kill". */ +__isl_give pet_expr *pet_expr_access_set_kill(__isl_take pet_expr *expr, + int kill); /* Return the reference identifier of access expression "expr". */ __isl_give isl_id *pet_expr_access_get_ref_id(__isl_keep pet_expr *expr); /* Replace the reference identifier of access expression "expr" by "ref_id". */ diff --git a/parse.c b/parse.c index 444f7fa..35f8039 100644 --- a/parse.c +++ b/parse.c @@ -444,6 +444,9 @@ static __isl_give pet_expr *extract_expr_access(isl_ctx *ctx, if (!strcmp((char *) key->data.scalar.value, "write")) expr = pet_expr_access_set_write(expr, extract_int(ctx, document, value)); + if (!strcmp((char *) key->data.scalar.value, "kill")) + expr = pet_expr_access_set_kill(expr, + extract_int(ctx, document, value)); } return expr; diff --git a/tests/autodetect/decl.scop b/tests/autodetect/decl.scop index 685e5e1..e114551 100644 --- a/tests/autodetect/decl.scop +++ b/tests/autodetect/decl.scop @@ -47,8 +47,7 @@ statements: relation: '{ S_1[] -> c[] }' index: '{ S_1[] -> c[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 6 domain: '{ S_2[] }' schedule: '{ S_2[] -> [1, 1] }' diff --git a/tests/decl.scop b/tests/decl.scop index dc5b466..adf675e 100644 --- a/tests/decl.scop +++ b/tests/decl.scop @@ -53,8 +53,7 @@ statements: relation: '[N, K, M] -> { S_1[i, j, k] -> t[] }' index: '[N, K, M] -> { S_1[i, j, k] -> t[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 10 domain: '[N, K, M] -> { S_2[i, j, k] : k <= -1 + K and k >= 0 and j <= -1 + N and j >= 0 and i <= -1 + M and i >= 0 }' @@ -117,5 +116,4 @@ statements: relation: '[N, K, M] -> { S_3[i, j, k] -> t[] }' index: '[N, K, M] -> { S_3[i, j, k] -> t[] }' reference: __pet_ref_7 - read: 0 - write: 0 + kill: 1 diff --git a/tests/decl2.scop b/tests/decl2.scop index b5e4284..a285c88 100644 --- a/tests/decl2.scop +++ b/tests/decl2.scop @@ -24,8 +24,7 @@ statements: index: '{ S_0[] -> A[] }' depth: 1 reference: __pet_ref_0 - read: 0 - write: 0 + kill: 1 - line: 5 domain: '{ S_1[] }' schedule: '{ S_1[] -> [1] }' diff --git a/tests/decl3.scop b/tests/decl3.scop index a02c0e7..521cb46 100644 --- a/tests/decl3.scop +++ b/tests/decl3.scop @@ -44,8 +44,7 @@ statements: index: '{ S_1[] -> A[] }' depth: 1 reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 6 domain: '{ S_2[] }' schedule: '{ S_2[] -> [2] }' diff --git a/tests/encapsulate/for_while.scop b/tests/encapsulate/for_while.scop index e02783e..9642e34 100644 --- a/tests/encapsulate/for_while.scop +++ b/tests/encapsulate/for_while.scop @@ -42,8 +42,7 @@ statements: relation: '[n] -> { S_4[x1] -> x2[] }' index: '[n] -> { S_4[x1] -> x2[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 13 domain: '[n] -> { S_3[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { S_3[x1] -> [0, x1, 1, 1] }' @@ -111,8 +110,7 @@ statements: relation: '[n] -> { S_5[x1] -> x2[] }' index: '[n] -> { S_5[x1] -> x2[] }' reference: __pet_ref_7 - read: 0 - write: 0 + kill: 1 - line: 16 domain: '[n] -> { R[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { R[x1] -> [0, x1, 2] }' diff --git a/tests/encapsulate/independent5.scop b/tests/encapsulate/independent5.scop index 8af786e..99b7dae 100644 --- a/tests/encapsulate/independent5.scop +++ b/tests/encapsulate/independent5.scop @@ -34,8 +34,7 @@ statements: relation: '[n] -> { S_7[i] -> j[] }' index: '[n] -> { S_7[i] -> j[] }' reference: __pet_ref_0 - read: 0 - write: 0 + kill: 1 - line: 6 domain: '[n] -> { S_6[i] : i <= -1 + n and i >= 0 }' schedule: '[n] -> { S_6[i] -> [0, i, 1] }' @@ -106,8 +105,7 @@ statements: relation: '[n] -> { S_8[i] -> j[] }' index: '[n] -> { S_8[i] -> j[] }' reference: __pet_ref_8 - read: 0 - write: 0 + kill: 1 independences: - filter: '[n] -> { S_6[i] -> S_7[i''] : i'' >= 1 + i; S_8[i] -> S_7[i''] : i'' >= 1 + i; S_7[i] -> S_8[i''] : i'' >= 1 + i; S_6[i] -> S_6[i''] : i'' >= 1 + i; S_6[i] diff --git a/tests/encapsulate/inf_break.scop b/tests/encapsulate/inf_break.scop index cadca1c..34408f3 100644 --- a/tests/encapsulate/inf_break.scop +++ b/tests/encapsulate/inf_break.scop @@ -26,8 +26,7 @@ statements: relation: '{ S_5[] -> s[] }' index: '{ S_5[] -> s[] }' reference: __pet_ref_0 - read: 0 - write: 0 + kill: 1 - line: 4 domain: '{ S_4[] }' schedule: '{ S_4[] -> [0, 1] }' @@ -78,5 +77,4 @@ statements: relation: '{ S_6[] -> s[] }' index: '{ S_6[] -> s[] }' reference: __pet_ref_4 - read: 0 - write: 0 + kill: 1 diff --git a/tests/for_while_inc2.scop b/tests/for_while_inc2.scop index 801a4b6..bbc8b9d 100644 --- a/tests/for_while_inc2.scop +++ b/tests/for_while_inc2.scop @@ -48,8 +48,7 @@ statements: relation: '[n] -> { S_5[x1] -> x2[] }' index: '[n] -> { S_5[x1] -> x2[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 13 domain: '[n] -> { S_1[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { S_1[x1] -> [0, x1, 1, 1] }' @@ -165,8 +164,7 @@ statements: relation: '[n] -> { S_6[x1] -> x2[] }' index: '[n] -> { S_6[x1] -> x2[] }' reference: __pet_ref_13 - read: 0 - write: 0 + kill: 1 - line: 16 domain: '[n] -> { R[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { R[x1] -> [0, x1, 2] }' diff --git a/tests/for_while_inc3.scop b/tests/for_while_inc3.scop index d0eb5b1..913ff23 100644 --- a/tests/for_while_inc3.scop +++ b/tests/for_while_inc3.scop @@ -48,8 +48,7 @@ statements: relation: '[n] -> { S_5[x1] -> x2[] }' index: '[n] -> { S_5[x1] -> x2[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 13 domain: '[n] -> { S_1[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { S_1[x1] -> [0, x1, 1, 1] }' @@ -165,8 +164,7 @@ statements: relation: '[n] -> { S_6[x1] -> x2[] }' index: '[n] -> { S_6[x1] -> x2[] }' reference: __pet_ref_13 - read: 0 - write: 0 + kill: 1 - line: 16 domain: '[n] -> { R[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { R[x1] -> [0, x1, 2] }' diff --git a/tests/for_while_init.scop b/tests/for_while_init.scop index a0636d0..74abaee 100644 --- a/tests/for_while_init.scop +++ b/tests/for_while_init.scop @@ -48,8 +48,7 @@ statements: relation: '[n] -> { S_5[x1] -> x2[] }' index: '[n] -> { S_5[x1] -> x2[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 13 domain: '[n] -> { S_1[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { S_1[x1] -> [0, x1, 1, 1] }' @@ -165,8 +164,7 @@ statements: relation: '[n] -> { S_6[x1] -> x2[] }' index: '[n] -> { S_6[x1] -> x2[] }' reference: __pet_ref_13 - read: 0 - write: 0 + kill: 1 - line: 16 domain: '[n] -> { R[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { R[x1] -> [0, x1, 2] }' diff --git a/tests/for_while_init2.scop b/tests/for_while_init2.scop index a1dd2a1..0703fd8 100644 --- a/tests/for_while_init2.scop +++ b/tests/for_while_init2.scop @@ -48,8 +48,7 @@ statements: relation: '[n] -> { S_5[x1] -> x2[] }' index: '[n] -> { S_5[x1] -> x2[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 13 domain: '[n] -> { S_1[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { S_1[x1] -> [0, x1, 1, 1] }' @@ -168,8 +167,7 @@ statements: relation: '[n] -> { S_6[x1] -> x2[] }' index: '[n] -> { S_6[x1] -> x2[] }' reference: __pet_ref_14 - read: 0 - write: 0 + kill: 1 - line: 16 domain: '[n] -> { R[x1] : x1 <= -1 + n and x1 >= 0 }' schedule: '[n] -> { R[x1] -> [0, x1, 2] }' diff --git a/tests/for_while_init3.scop b/tests/for_while_init3.scop index 74ac8fe..20d51ef 100644 --- a/tests/for_while_init3.scop +++ b/tests/for_while_init3.scop @@ -52,8 +52,7 @@ statements: relation: '[n] -> { S_5[i] -> j[] }' index: '[n] -> { S_5[i] -> j[] }' reference: __pet_ref_1 - read: 0 - write: 0 + kill: 1 - line: 8 domain: '[n] -> { S_1[i] : i <= -1 + n and i >= 0 }' schedule: '[n] -> { S_1[i] -> [1, i, 1] }' @@ -158,8 +157,7 @@ statements: relation: '[n] -> { S_6[i] -> j[] }' index: '[n] -> { S_6[i] -> j[] }' reference: __pet_ref_11 - read: 0 - write: 0 + kill: 1 implications: - satisfied: 1 extension: '[n] -> { __pet_test_0[i, t] -> __pet_test_0[i, t''] : t'' <= t and i diff --git a/tests/forward_substitution3.scop b/tests/forward_substitution3.scop index eec627a..0a7329e 100644 --- a/tests/forward_substitution3.scop +++ b/tests/forward_substitution3.scop @@ -33,8 +33,7 @@ statements: relation: '{ S_0[] -> b[] }' index: '{ S_0[] -> b[] }' reference: __pet_ref_0 - read: 0 - write: 0 + kill: 1 - line: 5 domain: '{ S_1[] }' schedule: '{ S_1[] -> [0, 1] }' @@ -64,8 +63,7 @@ statements: relation: '{ S_2[] -> c[] }' index: '{ S_2[] -> c[] }' reference: __pet_ref_2 - read: 0 - write: 0 + kill: 1 - line: 6 domain: '{ S_3[] }' schedule: '{ S_3[] -> [1, 1] }' diff --git a/tests/independent3.scop b/tests/independent3.scop index 5060a14..f182446 100644 --- a/tests/independent3.scop +++ b/tests/independent3.scop @@ -31,8 +31,7 @@ statements: relation: '[n] -> { S_0[i, j] -> t[] }' index: '[n] -> { S_0[i, j] -> t[] }' reference: __pet_ref_0 - read: 0 - write: 0 + kill: 1 - line: 7 domain: '[n] -> { S_1[i, j] : i >= 0 and i <= -1 + n and j <= -1 + n and j >= 0 }' @@ -101,8 +100,7 @@ statements: relation: '[n] -> { S_2[i, j] -> t[] }' index: '[n] -> { S_2[i, j] -> t[] }' reference: __pet_ref_7 - read: 0 - write: 0 + kill: 1 independences: - filter: '[n] -> { S_2[i, j] -> S_2[i, j''] : j'' >= 1 + j; S_0[i, j] -> S_1[i, j''] : j'' >= 1 + j; S_2[i, j] -> S_1[i, j''] : j'' >= 1 + j; S_3[i, j] -> S_1[i, j''] -- 2.11.4.GIT