From 3bf7485818e79e9c0832fae8767ee3b93c660dd4 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 2 Jan 2012 16:28:40 +0100 Subject: [PATCH] extract_entire_host_domain: allow some of the user statements to be guarded When we encounter a user statement in print_stmt, the print_user_stmt_list function is called (if set) and from within this function, we call extract_entire_host_domain. The original user statement may however occasionally be followed by guarded user statements, so we need to take this possibility into account. Signed-off-by: Sven Verdoolaege --- cuda.c | 4 ++-- gpucode.c | 30 +++++++++++++++++++++--------- gpucode.h | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cuda.c b/cuda.c index 101bd0a..d5ff1f4 100644 --- a/cuda.c +++ b/cuda.c @@ -2449,7 +2449,7 @@ static void print_kernel_user(struct gpucode_info *code, struct cuda_gen *gen = code->user; isl_set *shared_domain; - shared_domain = extract_entire_host_domain(u); + shared_domain = extract_entire_host_domain(&u->stmt); print_shared_accesses(gen, shared_domain, gen->read, "read", -1); @@ -3905,7 +3905,7 @@ static void print_host_user(struct gpucode_info *code, set_tile_len(gen, u); read_sizes(gen); - host_domain = extract_entire_host_domain(u); + host_domain = extract_entire_host_domain(&u->stmt); local_sched = isl_union_map_intersect_range( isl_union_map_copy(gen->sched), diff --git a/gpucode.c b/gpucode.c index 9460941..aa248f9 100644 --- a/gpucode.c +++ b/gpucode.c @@ -265,22 +265,34 @@ __isl_give isl_set *extract_host_domain(struct clast_user_stmt *u) } /* Extract the set of scattering dimension values for which the given + * statement is executed, where the statement may be either a user statement + * or a guard containing a sequence of (possibly guarded) user statements. + */ +static __isl_give isl_set *extract_nested_host_domain(struct clast_stmt *s) +{ + if (CLAST_STMT_IS_A(s, stmt_user)) { + struct clast_user_stmt *u = (struct clast_user_stmt *) s; + return extract_host_domain(u); + } else if (CLAST_STMT_IS_A(s, stmt_guard)) { + struct clast_guard *g = (struct clast_guard *) s; + return extract_entire_host_domain(g->then); + } else + assert(0); +} + +/* Extract the set of scattering dimension values for which the given * sequence of user statements is executed. - * In principle, this set should be the same for each of the user - * statements in the sequence, but we compute the union just to be safe. + * Some of the user statements in the sequence may be guarded + * so we return the union of this set over all user statements. */ -__isl_give isl_set *extract_entire_host_domain(struct clast_user_stmt *u) +__isl_give isl_set *extract_entire_host_domain(struct clast_stmt *s) { - struct clast_stmt *s; isl_set *host_domain = NULL; - for (s = &u->stmt; s; s = s->next) { + for (; s; s = s->next) { isl_set *set_i; - assert(CLAST_STMT_IS_A(s, stmt_user)); - u = (struct clast_user_stmt *) s; - - set_i = extract_host_domain(u); + set_i = extract_nested_host_domain(s); if (!host_domain) host_domain = set_i; diff --git a/gpucode.h b/gpucode.h index 9362c04..4048cc7 100644 --- a/gpucode.h +++ b/gpucode.h @@ -20,6 +20,6 @@ void print_indent(FILE *dst, int indent); void gpu_print_host_stmt(struct gpucode_info *info, struct clast_stmt *s); __isl_give isl_set *extract_host_domain(struct clast_user_stmt *u); -__isl_give isl_set *extract_entire_host_domain(struct clast_user_stmt *u); +__isl_give isl_set *extract_entire_host_domain(struct clast_stmt *s); #endif -- 2.11.4.GIT