Commit 8797fca6 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[refactor] convert tiling to new errors, create

Implement #31 for tiling.
Improve error management.
Checkpatch tiling.
parent cb98d0b9
Pipeline #6832 passed with stages
in 4 minutes and 31 seconds
...@@ -18,6 +18,8 @@ include/aml/dma/linux-seq.h ...@@ -18,6 +18,8 @@ include/aml/dma/linux-seq.h
include/aml/dma/linux-par.h include/aml/dma/linux-par.h
include/aml/scratch/seq.h include/aml/scratch/seq.h
include/aml/scratch/par.h include/aml/scratch/par.h
include/aml/tiling/1d.h
include/aml/tiling/2d.h
include/aml/utils/bitmap.h include/aml/utils/bitmap.h
include/aml/utils/error.h include/aml/utils/error.h
src/aml.c src/aml.c
...@@ -29,4 +31,7 @@ src/dma/dma_linux_par.c ...@@ -29,4 +31,7 @@ src/dma/dma_linux_par.c
src/scratch/scratch.c src/scratch/scratch.c
src/scratch/scratch_seq.c src/scratch/scratch_seq.c
src/scratch/scratch_par.c src/scratch/scratch_par.c
src/tiling/tiling.c
src/tiling/tiling_1d.c
src/tiling/tiling_2d.c
src/utils/error.c src/utils/error.c
...@@ -72,9 +72,9 @@ int main(int argc, char* argv[]) ...@@ -72,9 +72,9 @@ int main(int argc, char* argv[])
tilesize = sizeof(double)*T*T; tilesize = sizeof(double)*T*T;
/* the initial tiling, of 2D square tiles */ /* the initial tiling, of 2D square tiles */
assert(!aml_tiling_init(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR, assert(!aml_tiling_2d_init(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
assert(!aml_tiling_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR, assert(!aml_tiling_2d_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
...@@ -156,8 +156,8 @@ int main(int argc, char* argv[]) ...@@ -156,8 +156,8 @@ int main(int argc, char* argv[])
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(&slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(&fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_2d_fini(&tiling_row);
aml_tiling_destroy(&tiling_col, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_2d_fini(&tiling_col);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -97,12 +97,12 @@ int main(int argc, char* argv[]) ...@@ -97,12 +97,12 @@ int main(int argc, char* argv[])
tilesize = sizeof(double)*T*T; tilesize = sizeof(double)*T*T;
/* the initial tiling, 2d grid of tiles */ /* the initial tiling, 2d grid of tiles */
assert(!aml_tiling_init(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR, assert(!aml_tiling_2d_init(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
assert(!aml_tiling_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR, assert(!aml_tiling_2d_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
/* the prefetch tiling, 1D sequence of columns of tiles */ /* the prefetch tiling, 1D sequence of columns of tiles */
assert(!aml_tiling_init(&tiling_prefetch, AML_TILING_TYPE_1D, assert(!aml_tiling_1d_init(&tiling_prefetch,
tilesize*(N/T), memsize)); tilesize*(N/T), memsize));
aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
...@@ -190,9 +190,9 @@ int main(int argc, char* argv[]) ...@@ -190,9 +190,9 @@ int main(int argc, char* argv[])
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(&slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(&fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_2d_fini(&tiling_row);
aml_tiling_destroy(&tiling_col, AML_TILING_TYPE_2D_ROWMAJOR); aml_tiling_2d_fini(&tiling_col);
aml_tiling_destroy(&tiling_prefetch, AML_TILING_TYPE_1D); aml_tiling_1d_fini(&tiling_prefetch);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -63,7 +63,7 @@ int main(int argc, char *argv[]) ...@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
} }
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize)); assert(!aml_tiling_1d_init(&tiling, tilesz, memsize));
aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
...@@ -126,7 +126,7 @@ int main(int argc, char *argv[]) ...@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(&slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(&fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D); aml_tiling_1d_fini(&tiling);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) ...@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
} }
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize)); assert(!aml_tiling_1d_init(&tiling, tilesz, memsize));
aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
...@@ -139,7 +139,7 @@ int main(int argc, char *argv[]) ...@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(&slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(&fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D); aml_tiling_1d_fini(&tiling);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -100,7 +100,7 @@ int main(int argc, char *argv[]) ...@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
} }
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_init(&tiling, AML_TILING_TYPE_1D, tilesz, memsize)); assert(!aml_tiling_1d_init(&tiling, tilesz, memsize));
aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&slow, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(slow != NULL); assert(slow != NULL);
...@@ -150,7 +150,7 @@ int main(int argc, char *argv[]) ...@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
aml_area_munmap(fast, c, memsize); aml_area_munmap(fast, c, memsize);
aml_area_linux_destroy(&slow); aml_area_linux_destroy(&slow);
aml_area_linux_destroy(&fast); aml_area_linux_destroy(&fast);
aml_tiling_destroy(&tiling, AML_TILING_TYPE_1D); aml_tiling_1d_fini(&tiling);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -139,6 +139,12 @@ aml_area_munmap(const struct aml_area *area, ...@@ -139,6 +139,12 @@ aml_area_munmap(const struct aml_area *area,
* Representation of a data structure organization in memory. * Representation of a data structure organization in memory.
******************************************************************************/ ******************************************************************************/
/* Tiling types passed to the tiling create()/init()/vinit() routines. */
/* Regular, linear tiling with uniform tile sizes. */
#define AML_TILING_TYPE_1D 0
#define AML_TILING_TYPE_2D_ROWMAJOR 1
#define AML_TILING_TYPE_2D_COLMAJOR 2
/* opaque handle to all tilings */ /* opaque handle to all tilings */
struct aml_tiling_data; struct aml_tiling_data;
struct aml_tiling_iterator_data; struct aml_tiling_iterator_data;
...@@ -282,56 +288,6 @@ int aml_tiling_iterator_end(const struct aml_tiling_iterator *iterator); ...@@ -282,56 +288,6 @@ int aml_tiling_iterator_end(const struct aml_tiling_iterator *iterator);
*/ */
int aml_tiling_iterator_get(const struct aml_tiling_iterator *iterator, ...); int aml_tiling_iterator_get(const struct aml_tiling_iterator *iterator, ...);
/* Tiling types passed to the tiling create()/init()/vinit() routines. */
/* Regular, linear tiling with uniform tile sizes. */
#define AML_TILING_TYPE_1D 0
#define AML_TILING_TYPE_2D_ROWMAJOR 1
#define AML_TILING_TYPE_2D_COLMAJOR 2
/*
* Allocates and initializes a new tiling.
* "tiling": an address where the pointer to the newly allocated tiling
* structure will be stored.
* "type": see AML_TILING_TYPE_*.
* Variadic arguments:
* - if "type" equals AML_TILING_TYPE_1D, two additional arguments are needed:
* - "tilesize": an argument of type size_t; provides the size of each tile.
* - "totalsize": an argument of type size_t; provides the size of the
* complete user data structure to be tiled.
* - if "type" equals AML_TILING_TYPE_2D, four additional arguments are needed:
* - "tilesize": an argument of type size_t; provides the size of a tile.
* - "totalsize": an argument of type size_t; provides the size of the
* complete user data structure to be tiled.
* - "rowsize": an argument of type size_t; the number of tiles in a row
* - "colsize": an argument of type size_t; the number of tiles in a column
* Returns 0 if successful; an error code otherwise.
*/
int aml_tiling_create(struct aml_tiling **tiling, int type, ...);
/*
* Initializes a tiling. This is a varargs-variant of the aml_tiling_vinit()
* routine.
* "tiling": an allocated tiling structure.
* "type": see aml_tiling_create().
* Variadic arguments: see aml_tiling_create().
* Returns 0 if successful; an error code otherwise.
*/
int aml_tiling_init(struct aml_tiling *tiling, int type, ...);
/*
* Initializes a tiling.
* "tiling": an allocated tiling structure.
* "type": see aml_tiling_create().
* "args": see the variadic arguments of aml_tiling_create().
* Returns 0 if successful; an error code otherwise.
*/
int aml_tiling_vinit(struct aml_tiling *tiling, int type, va_list args);
/*
* Tears down an initialized tiling.
* "tiling": an initialized tiling structure.
* "type": see aml_tiling_create().
* Returns 0 if successful; an error code otherwise.
*/
int aml_tiling_destroy(struct aml_tiling *tiling, int type);
/******************************************************************************* /*******************************************************************************
* DMA: * DMA:
* Management of low-level movement of memory. * Management of low-level movement of memory.
......
...@@ -48,4 +48,37 @@ struct aml_tiling_iterator_1d_data { ...@@ -48,4 +48,37 @@ struct aml_tiling_iterator_1d_data {
(sizeof(struct aml_tiling_iterator_1d_data) + \ (sizeof(struct aml_tiling_iterator_1d_data) + \
sizeof(struct aml_tiling_iterator)) sizeof(struct aml_tiling_iterator))
/**
* Allocates and initializes a new 1D tiling.
*
* @param tiling an address where the pointer to the newly allocated tiling
* structure will be stored.
* @param tilesize provides the size of each tile.
* @param totalsize provides the size of the complete user data structure to be
* tiled.
* @return 0 if successful; an error code otherwise.
**/
int aml_tiling_1d_create(struct aml_tiling **tiling,
size_t tilesize, size_t totalsize);
/**
* Initializes a tiling. Similar to create.
*
* @param tiling a tiling declared with AML_TILING_1D_DECL.
* @param 0 if successful; an error code otherwise.
**/
int aml_tiling_1d_init(struct aml_tiling *tiling, size_t tilesize,
size_t totalsize);
/**
* Finalize a tiling.
**/
void aml_tiling_1d_fini(struct aml_tiling *tiling);
/**
* Tears down an initialized tiling.
*
* @param tiling a tiling created with aml_tiling_1d_create. NULL after return.
**/
void aml_tiling_1d_destroy(struct aml_tiling **tiling);
#endif /* AML_TILING_1D_H */ #endif /* AML_TILING_1D_H */
...@@ -59,5 +59,43 @@ struct aml_tiling_iterator_2d_data { ...@@ -59,5 +59,43 @@ struct aml_tiling_iterator_2d_data {
(sizeof(struct aml_tiling_iterator_2d_data) + \ (sizeof(struct aml_tiling_iterator_2d_data) + \
sizeof(struct aml_tiling_iterator)) sizeof(struct aml_tiling_iterator))
/**
* Allocates and initializes a new 2D tiling.
*
* @param tiling an address where the pointer to the newly allocated tiling
* structure will be stored.
* @param type a type of 2D tiling
* @param tilesize provides the size of each tile.
* @param totalsize provides the size of the complete user data structure to be
* tiled.
* @param rowsize the number of tiles in a row
* @param colsize the number of tiles in a column
* @return 0 if successful; an error code otherwise.
**/
int aml_tiling_2d_create(struct aml_tiling **tiling, int type,
size_t tilesize, size_t totalsize,
size_t rowsize, size_t colsize);
/**
* Initializes a tiling. Similar to create.
*
* @param tiling a tiling declared with AML_TILING_2D_DECL.
* @param 0 if successful; an error code otherwise.
**/
int aml_tiling_2d_init(struct aml_tiling *tiling, int type,
size_t tilesize, size_t totalsize,
size_t rowsize, size_t colsize);
/**
* Finalize a tiling.
**/
void aml_tiling_2d_fini(struct aml_tiling *tiling);
/**
* Tears down an initialized tiling.
*
* @param tiling a tiling created with aml_tiling_1d_create. NULL after return.
**/
void aml_tiling_2d_destroy(struct aml_tiling **tiling);
#endif /* AML_TILING_2D_H */ #endif /* AML_TILING_2D_H */
...@@ -21,6 +21,7 @@ int aml_tiling_tileid(const struct aml_tiling *t, ...) ...@@ -21,6 +21,7 @@ int aml_tiling_tileid(const struct aml_tiling *t, ...)
assert(t != NULL); assert(t != NULL);
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, t); va_start(ap, t);
ret = t->ops->tileid(t->data, ap); ret = t->ops->tileid(t->data, ap);
va_end(ap); va_end(ap);
...@@ -33,7 +34,8 @@ size_t aml_tiling_tilesize(const struct aml_tiling *t, int tileid) ...@@ -33,7 +34,8 @@ size_t aml_tiling_tilesize(const struct aml_tiling *t, int tileid)
return t->ops->tilesize(t->data, tileid); return t->ops->tilesize(t->data, tileid);
} }
void* aml_tiling_tilestart(const struct aml_tiling *t, const void *ptr, int tileid) void *aml_tiling_tilestart(const struct aml_tiling *t, const void *ptr,
int tileid)
{ {
assert(t != NULL); assert(t != NULL);
return t->ops->tilestart(t->data, ptr, tileid); return t->ops->tilestart(t->data, ptr, tileid);
...@@ -44,6 +46,7 @@ int aml_tiling_ndims(const struct aml_tiling *t, ...) ...@@ -44,6 +46,7 @@ int aml_tiling_ndims(const struct aml_tiling *t, ...)
assert(t != NULL); assert(t != NULL);
va_list ap; va_list ap;
int err; int err;
va_start(ap, t); va_start(ap, t);
err = t->ops->ndims(t->data, ap); err = t->ops->ndims(t->data, ap);
va_end(ap); va_end(ap);
...@@ -76,6 +79,7 @@ int aml_tiling_iterator_get(const struct aml_tiling_iterator *it, ...) ...@@ -76,6 +79,7 @@ int aml_tiling_iterator_get(const struct aml_tiling_iterator *it, ...)
{ {
assert(it != NULL); assert(it != NULL);
va_list ap; va_list ap;
va_start(ap, it); va_start(ap, it);
it->ops->get(it->data, ap); it->ops->get(it->data, ap);
va_end(ap); va_end(ap);
...@@ -111,101 +115,3 @@ int aml_tiling_destroy_iterator(struct aml_tiling *t, ...@@ -111,101 +115,3 @@ int aml_tiling_destroy_iterator(struct aml_tiling *t,
assert(it != NULL); assert(it != NULL);
return t->ops->destroy_iterator(t->data, it); return t->ops->destroy_iterator(t->data, it);
} }
/*******************************************************************************
* Init functions
******************************************************************************/
/* allocate and init the tiling according to type */
//In the future, a n-dimensional arrya could be created with an arguments of:
//type: n # of dimensions
//va_list: size of each dimension followed by total size
//The return is now changed to ensure that a tile size is not larger than the given total size
int aml_tiling_create(struct aml_tiling **t, int type, ...)
{
va_list ap;
int err;
va_start(ap, type);
struct aml_tiling *ret = NULL;
intptr_t baseptr, dataptr;
if(type == AML_TILING_TYPE_1D)
{
/* alloc */
baseptr = (intptr_t) calloc(1, AML_TILING_1D_ALLOCSIZE);
dataptr = baseptr + sizeof(struct aml_tiling);
ret = (struct aml_tiling *)baseptr;
ret->data = (struct aml_tiling_data *)dataptr;
err = aml_tiling_vinit(ret, type, ap);
}
else if(type == AML_TILING_TYPE_2D_ROWMAJOR ||
type == AML_TILING_TYPE_2D_COLMAJOR)
{
baseptr = (intptr_t) calloc(1, AML_TILING_2D_ALLOCSIZE);
dataptr = baseptr + sizeof(struct aml_tiling);
ret = (struct aml_tiling *)baseptr;
ret->data = (struct aml_tiling_data *)dataptr;
err = aml_tiling_vinit(ret, type, ap);
}
va_end(ap);
*t = ret;
return err;
}
int aml_tiling_vinit(struct aml_tiling *t, int type, va_list ap)
{
int err;
if(type == AML_TILING_TYPE_1D)
{
t->ops = &aml_tiling_1d_ops;
struct aml_tiling_1d_data *data =
(struct aml_tiling_1d_data *)t->data;
data->blocksize = va_arg(ap, size_t);
data->totalsize = va_arg(ap, size_t);
err = data->blocksize > data->totalsize;
}
else if(type == AML_TILING_TYPE_2D_ROWMAJOR)
{
t->ops = &aml_tiling_2d_rowmajor_ops;
struct aml_tiling_2d_data *data =
(struct aml_tiling_2d_data *)t->data;
data->blocksize = va_arg(ap, size_t);
data->totalsize = va_arg(ap, size_t);
data->ndims[0] = va_arg(ap, size_t);
data->ndims[1] = va_arg(ap, size_t);
err = data->blocksize > data->totalsize;
}
else if(type == AML_TILING_TYPE_2D_COLMAJOR)
{
t->ops = &aml_tiling_2d_colmajor_ops;
struct aml_tiling_2d_data *data =
(struct aml_tiling_2d_data *)t->data;
data->blocksize = va_arg(ap, size_t);
data->totalsize = va_arg(ap, size_t);
data->ndims[0] = va_arg(ap, size_t);
data->ndims[1] = va_arg(ap, size_t);
err = data->blocksize > data->totalsize;
}
return err;
}
int aml_tiling_init(struct aml_tiling *t, int type, ...)
{
int err;
va_list ap;
va_start(ap, type);
err = aml_tiling_vinit(t, type, ap);
va_end(ap);
return err;
}
int aml_tiling_destroy(struct aml_tiling *b, int type)
{
return 0;
}
...@@ -72,18 +72,21 @@ size_t aml_tiling_1d_tilesize(const struct aml_tiling_data *t, int tileid) ...@@ -72,18 +72,21 @@ size_t aml_tiling_1d_tilesize(const struct aml_tiling_data *t, int tileid)
{ {
const struct aml_tiling_1d_data *data = const struct aml_tiling_1d_data *data =
(const struct aml_tiling_1d_data *)t; (const struct aml_tiling_1d_data *)t;
if(tileid < 0)
if (tileid < 0)
return 0; return 0;
else else
return data->blocksize; return data->blocksize;
} }
void* aml_tiling_1d_tilestart(const struct aml_tiling_data *t, const void *ptr, int tileid) void *aml_tiling_1d_tilestart(const struct aml_tiling_data *t,
const void *ptr, int tileid)
{ {
const struct aml_tiling_1d_data *data = const struct aml_tiling_1d_data *data =
(const struct aml_tiling_1d_data *)t; (const struct aml_tiling_1d_data *)t;
intptr_t p = (intptr_t)ptr; intptr_t p = (intptr_t)ptr;
if(tileid < 0)
if (tileid < 0)
return NULL; return NULL;
else else
return (void *)(p + tileid*data->blocksize); return (void *)(p + tileid*data->blocksize);
...@@ -95,7 +98,7 @@ int aml_tiling_1d_ndims(const struct aml_tiling_data *t, va_list ap) ...@@ -95,7 +98,7 @@ int aml_tiling_1d_ndims(const struct aml_tiling_data *t, va_list ap)
(const struct aml_tiling_1d_data *)t; (const struct aml_tiling_1d_data *)t;
size_t *x = va_arg(ap, size_t *); size_t *x = va_arg(ap, size_t *);
*x = data->totalsize/data->blocksize; *x = data->totalsize/data->blocksize;
if(data->totalsize % data->blocksize != 0) if (data->totalsize % data->blocksize != 0)
*x++; *x++;
return 0; return 0;
} }
...@@ -104,8 +107,9 @@ int aml_tiling_1d_init_iterator(struct aml_tiling_data *t, ...@@ -104,8 +107,9 @@ int aml_tiling_1d_init_iterator(struct aml_tiling_data *t,
struct aml_tiling_iterator *it, int flags) struct aml_tiling_iterator *it, int flags)
{ {
assert(it->data != NULL); assert(it->data != NULL);
struct aml_tiling_iterator_1d_data *data = struct aml_tiling_iterator_1d_data *data =
(struct aml_tiling_iterator_1d_data *)it->data; (struct aml_tiling_iterator_1d_data *)it->data;
it->ops = &aml_tiling_iterator_1d_ops; it->ops = &aml_tiling_iterator_1d_ops;
data->i = 0; data->i = 0;
data->tiling = (struct aml_tiling_1d_data *)t; data->tiling = (struct aml_tiling_1d_data *)t;
...@@ -117,9 +121,10 @@ int aml_tiling_1d_create_iterator(struct aml_tiling_data *t, ...@@ -117,9 +121,10 @@ int aml_tiling_1d_create_iterator(struct aml_tiling_data *t,
{ {
intptr_t baseptr, dataptr; intptr_t baseptr, dataptr;
struct aml_tiling_iterator *ret; struct aml_tiling_iterator *ret;
baseptr = (intptr_t) calloc(1, AML_TILING_ITERATOR_1D_ALLOCSIZE); baseptr = (intptr_t) calloc(1, AML_TILING_ITERATOR_1D_ALLOCSIZE);
dataptr = baseptr + sizeof(struct aml_tiling_iterator); dataptr = baseptr + sizeof(struct aml_tiling_iterator);
ret = (struct aml_tiling_iterator *)baseptr; ret = (struct aml_tiling_iterator *)baseptr;
ret->data = (struct aml_tiling_iterator_data *)dataptr; ret->data = (struct aml_tiling_iterator_data *)dataptr;
...@@ -143,3 +148,73 @@ struct aml_tiling_ops aml_tiling_1d_ops = { ...@@ -143,3 +148,73 @@ struct aml_tiling_ops aml_tiling_1d_ops = {
aml_tiling_1d_tilestart, aml_tiling_1d_tilestart,
aml_tiling_1d_ndims, aml_tiling_1d_ndims,
}; };
/*******************************************************************************
* 1D create/destroy
******************************************************************************/
int aml_tiling_1d_create(struct aml_tiling **t,
size_t tilesize, size_t totalsize)
{
struct aml_tiling *ret = NULL;
intptr_t baseptr, dataptr;
int err;
if (t == NULL)
return -AML_EINVAL;
/* alloc */
baseptr = (intptr_t) calloc(1, AML_TILING_1D_ALLOCSIZE);
if (baseptr == 0) {
*t = NULL;