4 #include "gpu_array_tile.h"
6 struct gpu_array_tile
*gpu_array_tile_free(struct gpu_array_tile
*tile
)
13 for (j
= 0; j
< tile
->n
; ++j
) {
14 isl_val_free(tile
->bound
[j
].size
);
15 isl_val_free(tile
->bound
[j
].stride
);
16 isl_aff_free(tile
->bound
[j
].lb
);
17 isl_aff_free(tile
->bound
[j
].shift
);
20 isl_multi_aff_free(tile
->tiling
);
26 /* Create a gpu_array_tile for an array of dimension "n_index".
28 struct gpu_array_tile
*gpu_array_tile_create(isl_ctx
*ctx
, int n_index
)
31 struct gpu_array_tile
*tile
;
33 tile
= isl_calloc_type(ctx
, struct gpu_array_tile
);
38 tile
->bound
= isl_alloc_array(ctx
, struct gpu_array_bound
, n_index
);
40 return gpu_array_tile_free(tile
);
44 for (i
= 0; i
< n_index
; ++i
) {
45 tile
->bound
[i
].size
= NULL
;
46 tile
->bound
[i
].lb
= NULL
;
47 tile
->bound
[i
].stride
= NULL
;
48 tile
->bound
[i
].shift
= NULL
;
54 /* Compute the size of the tile specified by "tile"
55 * in number of elements and return the result.
57 __isl_give isl_val
*gpu_array_tile_size(struct gpu_array_tile
*tile
)
65 size
= isl_val_one(tile
->ctx
);
67 for (i
= 0; i
< tile
->n
; ++i
)
68 size
= isl_val_mul(size
, isl_val_copy(tile
->bound
[i
].size
));