From 986b7b853d87181ab433f017004c52a567f60b69 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 17 Apr 2014 17:38:25 +0200 Subject: [PATCH] ppcg_scop: store pointer to pet_scop rather than copying most of its members We will also be able to reuse this pointer inside gpu_prog_alloc in a subsequent commit. Signed-off-by: Sven Verdoolaege --- cpu.c | 9 +++++---- gpu.c | 24 ++++++++++++------------ gpu_print.c | 4 ++-- opencl.c | 4 ++-- ppcg.c | 13 +++---------- ppcg.h | 12 ++---------- print.c | 4 ++-- 7 files changed, 28 insertions(+), 42 deletions(-) diff --git a/cpu.c b/cpu.c index 748b8b5..08de072 100644 --- a/cpu.c +++ b/cpu.c @@ -246,8 +246,8 @@ static struct pet_stmt *find_stmt(struct ppcg_scop *scop, __isl_keep isl_id *id) { int i; - for (i = 0; i < scop->n_stmt; ++i) { - struct pet_stmt *stmt = scop->stmts[i]; + for (i = 0; i < scop->pet->n_stmt; ++i) { + struct pet_stmt *stmt = scop->pet->stmts[i]; isl_id *id_i; id_i = isl_set_get_tuple_id(stmt->domain); @@ -471,8 +471,9 @@ static int any_hidden_declarations(struct ppcg_scop *scop) if (!scop) return 0; - for (i = 0; i < scop->n_array; ++i) - if (scop->arrays[i]->declared && !scop->arrays[i]->exposed) + for (i = 0; i < scop->pet->n_array; ++i) + if (scop->pet->arrays[i]->declared && + !scop->pet->arrays[i]->exposed) return 1; return 0; diff --git a/gpu.c b/gpu.c index a8e8fca..3ff6a3e 100644 --- a/gpu.c +++ b/gpu.c @@ -347,17 +347,17 @@ static struct pet_array *find_array(struct ppcg_scop *scop, id = isl_set_get_tuple_id(accessed); - for (i = 0; i < scop->n_array; ++i) { + for (i = 0; i < scop->pet->n_array; ++i) { isl_id *id_i; - id_i = isl_set_get_tuple_id(scop->arrays[i]->extent); + id_i = isl_set_get_tuple_id(scop->pet->arrays[i]->extent); isl_id_free(id_i); if (id == id_i) break; } isl_id_free(id); - return i < scop->n_array ? scop->arrays[i] : NULL; + return i < scop->pet->n_array ? scop->pet->arrays[i] : NULL; } /* Compute and return the extent of "array", taking into account the set of @@ -521,8 +521,8 @@ static __isl_give isl_union_map *compute_to_inner(struct ppcg_scop *scop) to_inner = isl_union_map_empty(isl_set_get_space(scop->context)); - for (i = 0; i < scop->n_array; ++i) { - struct pet_array *array = scop->arrays[i]; + for (i = 0; i < scop->pet->n_array; ++i) { + struct pet_array *array = scop->pet->arrays[i]; isl_set *set; isl_map *map; @@ -574,8 +574,8 @@ static __isl_give isl_union_map *remove_independences(struct gpu_prog *prog, { int i; - for (i = 0; i < prog->scop->n_independence; ++i) { - struct pet_independence *pi = prog->scop->independences[i]; + for (i = 0; i < prog->scop->pet->n_independence; ++i) { + struct pet_independence *pi = prog->scop->pet->independences[i]; if (isl_union_set_contains(pi->local, array->space)) continue; @@ -5833,15 +5833,15 @@ static struct gpu_stmt *extract_stmts(isl_ctx *ctx, struct ppcg_scop *scop, int i; struct gpu_stmt *stmts; - stmts = isl_calloc_array(ctx, struct gpu_stmt, scop->n_stmt); + stmts = isl_calloc_array(ctx, struct gpu_stmt, scop->pet->n_stmt); if (!stmts) return NULL; - for (i = 0; i < scop->n_stmt; ++i) { + for (i = 0; i < scop->pet->n_stmt; ++i) { struct gpu_stmt *s = &stmts[i]; - s->id = isl_set_get_tuple_id(scop->stmts[i]->domain); - s->stmt = scop->stmts[i]; + s->id = isl_set_get_tuple_id(scop->pet->stmts[i]->domain); + s->stmt = scop->pet->stmts[i]; pet_stmt_extract_accesses(s); } @@ -6019,7 +6019,7 @@ struct gpu_prog *gpu_prog_alloc(isl_ctx *ctx, struct ppcg_scop *scop) prog->ctx = ctx; prog->scop = scop; prog->context = isl_set_copy(scop->context); - prog->n_stmts = scop->n_stmt; + prog->n_stmts = scop->pet->n_stmt; prog->stmts = extract_stmts(ctx, scop, prog->context); prog->read = isl_union_map_copy(scop->reads); prog->may_write = isl_union_map_copy(scop->may_writes); diff --git a/gpu_print.c b/gpu_print.c index 19277fa..2bf246b 100644 --- a/gpu_print.c +++ b/gpu_print.c @@ -225,7 +225,7 @@ __isl_give isl_printer *gpu_print_types(__isl_take isl_printer *p, isl_ctx *ctx; char **name; - n = prog->scop->n_type; + n = prog->scop->pet->n_type; if (n == 0) return p; @@ -237,7 +237,7 @@ __isl_give isl_printer *gpu_print_types(__isl_take isl_printer *p, types->name = name; for (i = 0; i < n; ++i) { - struct pet_type *type = prog->scop->types[i]; + struct pet_type *type = prog->scop->pet->types[i]; if (already_printed(types, type)) continue; diff --git a/opencl.c b/opencl.c index bce39d3..b81fe0c 100644 --- a/opencl.c +++ b/opencl.c @@ -614,8 +614,8 @@ static __isl_give int any_double_elements(struct gpu_prog *prog) if (strcmp(prog->array[i].type, "double") == 0) return 1; - for (i = 0; i < prog->scop->n_type; ++i) { - struct pet_type *type = prog->scop->types[i]; + for (i = 0; i < prog->scop->pet->n_type; ++i) { + struct pet_type *type = prog->scop->pet->types[i]; if (strstr(type->definition, "double")) return 1; diff --git a/ppcg.c b/ppcg.c index 2d57f16..0b5f0e5 100644 --- a/ppcg.c +++ b/ppcg.c @@ -637,18 +637,11 @@ static struct ppcg_scop *ppcg_scop_from_pet_scop(struct pet_scop *scop, ps->must_writes = pet_scop_collect_must_writes(scop); ps->tagged_must_kills = pet_scop_collect_tagged_must_kills(scop); ps->schedule = pet_scop_collect_schedule(scop); - ps->n_type = scop->n_type; - ps->types = scop->types; - ps->n_array = scop->n_array; - ps->arrays = scop->arrays; - ps->n_stmt = scop->n_stmt; - ps->stmts = scop->stmts; - ps->n_independence = scop->n_independence; - ps->independences = scop->independences; + ps->pet = scop; ps->independence = isl_union_map_empty(isl_set_get_space(ps->context)); - for (i = 0; i < ps->n_independence; ++i) + for (i = 0; i < scop->n_independence; ++i) ps->independence = isl_union_map_union(ps->independence, - isl_union_map_copy(ps->independences[i]->filter)); + isl_union_map_copy(scop->independences[i]->filter)); compute_tagger(ps); compute_dependences(ps); diff --git a/ppcg.h b/ppcg.h index b8ae96d..0fbfbce 100644 --- a/ppcg.h +++ b/ppcg.h @@ -58,8 +58,7 @@ int ppcg_extract_base_name(char *name, const char *input); * set of anti and output dependences. * "schedule" represents the (original) schedule. * - * "types", "arrays", "stmts" and "independences" - * are copies of the corresponding elements of the original pet_scop. + * "pet" is the original pet_scop. */ struct ppcg_scop { struct ppcg_options *options; @@ -92,14 +91,7 @@ struct ppcg_scop { isl_union_map *tagged_dep_order; isl_union_map *schedule; - int n_type; - struct pet_type **types; - int n_array; - struct pet_array **arrays; - int n_stmt; - struct pet_stmt **stmts; - int n_independence; - struct pet_independence **independences; + struct pet_scop *pet; }; int ppcg_transform(isl_ctx *ctx, const char *input, FILE *out, diff --git a/print.c b/print.c index dcde64d..6881537 100644 --- a/print.c +++ b/print.c @@ -79,8 +79,8 @@ static __isl_give isl_printer *print_declarations(__isl_take isl_printer *p, if (!scop) return isl_printer_free(p); - for (i = 0; i < scop->n_array; ++i) { - struct pet_array *array = scop->arrays[i]; + for (i = 0; i < scop->pet->n_array; ++i) { + struct pet_array *array = scop->pet->arrays[i]; const char *name; if (!array->declared) -- 2.11.4.GIT