Commit 8a150cf2 authored by Swann Perarnau's avatar Swann Perarnau

[refactor/feature] change tilings to use uuids

Using variable arguments on the tile id for retrieving tiling info makes
the API difficult to use when more than one tile must be used at the
same time.

We change the API to use a tileid, with the assumption that any valuable
tiling will be able to define a workable uuid scheme.
parent 24a640a2
...@@ -325,8 +325,8 @@ struct aml_tiling_ops { ...@@ -325,8 +325,8 @@ struct aml_tiling_ops {
struct aml_tiling_iterator *, int); struct aml_tiling_iterator *, int);
int (*destroy_iterator)(struct aml_tiling_data *, int (*destroy_iterator)(struct aml_tiling_data *,
struct aml_tiling_iterator *); struct aml_tiling_iterator *);
size_t (*tilesize)(struct aml_tiling_data *, va_list); size_t (*tilesize)(struct aml_tiling_data *, int);
void* (*tilestart)(struct aml_tiling_data *, void *, va_list); void* (*tilestart)(struct aml_tiling_data *, void *, int);
}; };
struct aml_tiling { struct aml_tiling {
...@@ -334,10 +334,8 @@ struct aml_tiling { ...@@ -334,10 +334,8 @@ struct aml_tiling {
struct aml_tiling_data *data; struct aml_tiling_data *data;
}; };
size_t aml_tiling_tilesize(struct aml_tiling *, ...); size_t aml_tiling_tilesize(struct aml_tiling *, int);
size_t aml_tiling_vtilesize(struct aml_tiling *, va_list); void* aml_tiling_tilestart(struct aml_tiling *, void *, int);
void* aml_tiling_tilestart(struct aml_tiling *, void *, ...);
void* aml_tiling_vtilestart(struct aml_tiling *, void *, va_list);
int aml_tiling_create_iterator(struct aml_tiling *, int aml_tiling_create_iterator(struct aml_tiling *,
...@@ -419,11 +417,11 @@ struct aml_binding_data; ...@@ -419,11 +417,11 @@ struct aml_binding_data;
struct aml_binding_ops { struct aml_binding_ops {
int (*nbpages)(struct aml_binding_data *, struct aml_tiling *, int (*nbpages)(struct aml_binding_data *, struct aml_tiling *,
void *, va_list); void *, int);
int (*pages)(struct aml_binding_data *, void **, struct aml_tiling *, int (*pages)(struct aml_binding_data *, void **, struct aml_tiling *,
void *, va_list); void *, int);
int (*nodes)(struct aml_binding_data *, int *, struct aml_tiling *, int (*nodes)(struct aml_binding_data *, int *, struct aml_tiling *,
void *, va_list); void *, int);
}; };
struct aml_binding { struct aml_binding {
...@@ -431,9 +429,9 @@ struct aml_binding { ...@@ -431,9 +429,9 @@ struct aml_binding {
struct aml_binding_data *data; struct aml_binding_data *data;
}; };
int aml_binding_nbpages(struct aml_binding *, struct aml_tiling *, void*, ...); int aml_binding_nbpages(struct aml_binding *, struct aml_tiling *, void*, int);
int aml_binding_pages(struct aml_binding *, void **, struct aml_tiling *, void*, ...); int aml_binding_pages(struct aml_binding *, void **, struct aml_tiling *, void*, int);
int aml_binding_nodes(struct aml_binding *, int *, struct aml_tiling *, void *, ...); int aml_binding_nodes(struct aml_binding *, int *, struct aml_tiling *, void *, int);
#define AML_BINDING_TYPE_SINGLE 0 #define AML_BINDING_TYPE_SINGLE 0
#define AML_BINDING_TYPE_INTERLEAVE 1 #define AML_BINDING_TYPE_INTERLEAVE 1
......
...@@ -8,44 +8,29 @@ ...@@ -8,44 +8,29 @@
******************************************************************************/ ******************************************************************************/
int aml_binding_nbpages(struct aml_binding *binding, int aml_binding_nbpages(struct aml_binding *binding,
struct aml_tiling *tiling, void *ptr, ...) struct aml_tiling *tiling, void *ptr, int tileid)
{ {
assert(binding != NULL); assert(binding != NULL);
assert(tiling != NULL); assert(tiling != NULL);
va_list ap; return binding->ops->nbpages(binding->data, tiling, ptr, tileid);
int ret;
va_start(ap, ptr);
ret = binding->ops->nbpages(binding->data, tiling, ptr, ap);
va_end(ap);
return ret;
} }
int aml_binding_pages(struct aml_binding *binding, int aml_binding_pages(struct aml_binding *binding, void **pages,
void **pages, struct aml_tiling *tiling, void *ptr, ...) struct aml_tiling *tiling, void *ptr, int tileid)
{ {
assert(binding != NULL); assert(binding != NULL);
assert(pages != NULL); assert(pages != NULL);
assert(tiling != NULL); assert(tiling != NULL);
va_list ap; return binding->ops->pages(binding->data, pages, tiling, ptr, tileid);
int ret;
va_start(ap, ptr);
ret = binding->ops->pages(binding->data, pages, tiling, ptr, ap);
va_end(ap);
return ret;
} }
int aml_binding_nodes(struct aml_binding *binding, int aml_binding_nodes(struct aml_binding *binding, int *nodes,
int *nodes, struct aml_tiling *tiling, void *ptr, ...) struct aml_tiling *tiling, void *ptr, int tileid)
{ {
assert(binding != NULL); assert(binding != NULL);
assert(nodes != NULL); assert(nodes != NULL);
assert(tiling != NULL); assert(tiling != NULL);
va_list ap; return binding->ops->nodes(binding->data, nodes, tiling, ptr, tileid);
int ret;
va_start(ap, ptr);
ret = binding->ops->nodes(binding->data, nodes, tiling, ptr, ap);
va_end(ap);
return ret;
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
int aml_binding_interleave_getinfo(struct aml_binding_data *data, int aml_binding_interleave_getinfo(struct aml_binding_data *data,
intptr_t *start, intptr_t *end, intptr_t *start, intptr_t *end,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(tiling != NULL); assert(tiling != NULL);
size_t size = aml_tiling_tilesize(tiling, args); size_t size = aml_tiling_tilesize(tiling, tileid);
*start = (intptr_t) aml_tiling_vtilestart(tiling, ptr, args); *start = (intptr_t) aml_tiling_tilestart(tiling, ptr, tileid);
*end = *start + size; *end = *start + size;
/* include first and last pages */ /* include first and last pages */
...@@ -27,24 +27,24 @@ int aml_binding_interleave_getinfo(struct aml_binding_data *data, ...@@ -27,24 +27,24 @@ int aml_binding_interleave_getinfo(struct aml_binding_data *data,
int aml_binding_interleave_nbpages(struct aml_binding_data *data, int aml_binding_interleave_nbpages(struct aml_binding_data *data,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(tiling != NULL); assert(tiling != NULL);
intptr_t start, end; intptr_t start, end;
return aml_binding_interleave_getinfo(data, &start, &end, tiling, ptr, args); return aml_binding_interleave_getinfo(data, &start, &end, tiling, ptr, tileid);
} }
int aml_binding_interleave_pages(struct aml_binding_data *data, void **pages, int aml_binding_interleave_pages(struct aml_binding_data *data, void **pages,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(pages != NULL); assert(pages != NULL);
assert(tiling != NULL); assert(tiling != NULL);
intptr_t start, end; intptr_t start, end;
int i, count; int i, count;
count = aml_binding_interleave_getinfo(data, &start, &end, tiling, ptr, args); count = aml_binding_interleave_getinfo(data, &start, &end, tiling, ptr, tileid);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
pages[i] = (void *)(start + i * PAGE_SIZE); pages[i] = (void *)(start + i * PAGE_SIZE);
return 0; return 0;
...@@ -52,7 +52,7 @@ int aml_binding_interleave_pages(struct aml_binding_data *data, void **pages, ...@@ -52,7 +52,7 @@ int aml_binding_interleave_pages(struct aml_binding_data *data, void **pages,
int aml_binding_interleave_nodes(struct aml_binding_data *data, int *nodes, int aml_binding_interleave_nodes(struct aml_binding_data *data, int *nodes,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(nodes != NULL); assert(nodes != NULL);
...@@ -61,7 +61,7 @@ int aml_binding_interleave_nodes(struct aml_binding_data *data, int *nodes, ...@@ -61,7 +61,7 @@ int aml_binding_interleave_nodes(struct aml_binding_data *data, int *nodes,
(struct aml_binding_interleave_data *)data; (struct aml_binding_interleave_data *)data;
intptr_t start, end; intptr_t start, end;
int i, count; int i, count;
count = aml_binding_interleave_getinfo(data, &start, &end, tiling, ptr, args); count = aml_binding_interleave_getinfo(data, &start, &end, tiling, ptr, tileid);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
nodes[i] = binding->nodes[i%binding->count]; nodes[i] = binding->nodes[i%binding->count];
return 0; return 0;
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
int aml_binding_single_getinfo(struct aml_binding_data *data, int aml_binding_single_getinfo(struct aml_binding_data *data,
intptr_t *start, intptr_t *end, intptr_t *start, intptr_t *end,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(tiling != NULL); assert(tiling != NULL);
size_t size = aml_tiling_tilesize(tiling, args); size_t size = aml_tiling_tilesize(tiling, tileid);
*start = (intptr_t) aml_tiling_vtilestart(tiling, ptr, args); *start = (intptr_t) aml_tiling_tilestart(tiling, ptr, tileid);
*end = *start + size; *end = *start + size;
/* include first and last pages */ /* include first and last pages */
...@@ -27,24 +27,24 @@ int aml_binding_single_getinfo(struct aml_binding_data *data, ...@@ -27,24 +27,24 @@ int aml_binding_single_getinfo(struct aml_binding_data *data,
int aml_binding_single_nbpages(struct aml_binding_data *data, int aml_binding_single_nbpages(struct aml_binding_data *data,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(tiling != NULL); assert(tiling != NULL);
intptr_t start, end; intptr_t start, end;
return aml_binding_single_getinfo(data, &start, &end, tiling, ptr, args); return aml_binding_single_getinfo(data, &start, &end, tiling, ptr, tileid);
} }
int aml_binding_single_pages(struct aml_binding_data *data, void **pages, int aml_binding_single_pages(struct aml_binding_data *data, void **pages,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(pages != NULL); assert(pages != NULL);
assert(tiling != NULL); assert(tiling != NULL);
intptr_t start, end; intptr_t start, end;
int i, count; int i, count;
count = aml_binding_single_getinfo(data, &start, &end, tiling, ptr, args); count = aml_binding_single_getinfo(data, &start, &end, tiling, ptr, tileid);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
pages[i] = (void *)(start + i * PAGE_SIZE); pages[i] = (void *)(start + i * PAGE_SIZE);
return 0; return 0;
...@@ -52,7 +52,7 @@ int aml_binding_single_pages(struct aml_binding_data *data, void **pages, ...@@ -52,7 +52,7 @@ int aml_binding_single_pages(struct aml_binding_data *data, void **pages,
int aml_binding_single_nodes(struct aml_binding_data *data, int *nodes, int aml_binding_single_nodes(struct aml_binding_data *data, int *nodes,
struct aml_tiling *tiling, void *ptr, struct aml_tiling *tiling, void *ptr,
va_list args) int tileid)
{ {
assert(data != NULL); assert(data != NULL);
assert(nodes != NULL); assert(nodes != NULL);
...@@ -61,7 +61,8 @@ int aml_binding_single_nodes(struct aml_binding_data *data, int *nodes, ...@@ -61,7 +61,8 @@ int aml_binding_single_nodes(struct aml_binding_data *data, int *nodes,
(struct aml_binding_single_data *)data; (struct aml_binding_single_data *)data;
intptr_t start, end; intptr_t start, end;
int i, count; int i, count;
count = aml_binding_single_getinfo(data, &start, &end, tiling, ptr, args); count = aml_binding_single_getinfo(data, &start, &end, tiling, ptr,
tileid);
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
nodes[i] = binding->node; nodes[i] = binding->node;
return 0; return 0;
......
...@@ -4,38 +4,16 @@ ...@@ -4,38 +4,16 @@
/******************************************************************************* /*******************************************************************************
* Tiling functions * Tiling functions
******************************************************************************/ ******************************************************************************/
size_t aml_tiling_vtilesize(struct aml_tiling *t, va_list args) size_t aml_tiling_tilesize(struct aml_tiling *t, int tileid)
{ {
assert(t != NULL); assert(t != NULL);
return t->ops->tilesize(t->data, args); return t->ops->tilesize(t->data, tileid);
} }
size_t aml_tiling_tilesize(struct aml_tiling *t, ...) void* aml_tiling_tilestart(struct aml_tiling *t, void *ptr, int tileid)
{ {
assert(t != NULL); assert(t != NULL);
va_list ap; return t->ops->tilestart(t->data, ptr, tileid);
size_t ret;
va_start(ap, t);
ret = aml_tiling_vtilesize(t, ap);
va_end(ap);
return ret;
}
void* aml_tiling_vtilestart(struct aml_tiling *t, void *ptr, va_list args)
{
assert(t != NULL);
return t->ops->tilestart(t->data, ptr, args);
}
void* aml_tiling_tilestart(struct aml_tiling *t, void *ptr, ...)
{
assert(t != NULL);
va_list ap;
void* ret;
va_start(ap, ptr);
ret = aml_tiling_vtilestart(t, ptr, ap);
va_end(ap);
return ret;
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -49,20 +49,19 @@ struct aml_tiling_iterator_ops aml_tiling_iterator_1d_ops = { ...@@ -49,20 +49,19 @@ struct aml_tiling_iterator_ops aml_tiling_iterator_1d_ops = {
* 1D ops * 1D ops
******************************************************************************/ ******************************************************************************/
size_t aml_tiling_1d_tilesize(struct aml_tiling_data *t, va_list args) size_t aml_tiling_1d_tilesize(struct aml_tiling_data *t, int tileid)
{ {
struct aml_tiling_1d_data *data = struct aml_tiling_1d_data *data =
(struct aml_tiling_1d_data *)t; (struct aml_tiling_1d_data *)t;
return data->blocksize; return data->blocksize;
} }
void* aml_tiling_1d_tilestart(struct aml_tiling_data *t, void *ptr, va_list args) void* aml_tiling_1d_tilestart(struct aml_tiling_data *t, void *ptr, int tileid)
{ {
struct aml_tiling_1d_data *data = struct aml_tiling_1d_data *data =
(struct aml_tiling_1d_data *)t; (struct aml_tiling_1d_data *)t;
intptr_t p = (intptr_t)ptr; intptr_t p = (intptr_t)ptr;
unsigned long x = va_arg(args, unsigned long); return (void *)(p + tileid*data->blocksize);
return (void *)(p + x*data->blocksize);
} }
int aml_tiling_1d_init_iterator(struct aml_tiling_data *t, int aml_tiling_1d_init_iterator(struct aml_tiling_data *t,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment