Commit 0e89b24a authored by Swann Perarnau's avatar Swann Perarnau

Merge branch 'remove-static-allocs' into 'master'

Remove static allocs

Closes #37

See merge request !68
parents c9d8ed8c d3558a6d
Pipeline #8044 passed with stages
in 24 minutes and 49 seconds
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
AML_TILING_2D_ROWMAJOR_DECL(tiling_row); struct aml_tiling *tiling_row;
AML_TILING_2D_COLMAJOR_DECL(tiling_col); struct aml_tiling *tiling_col;
struct aml_area *slow, *fast; struct aml_area *slow, *fast;
size_t memsize, tilesize, N, T; size_t memsize, tilesize, N, T;
double *a, *b, *c; double *a, *b, *c;
...@@ -34,7 +34,7 @@ void do_work() ...@@ -34,7 +34,7 @@ void do_work()
ldb = lda; ldb = lda;
ldc = lda; ldc = lda;
size_t ndims[2]; size_t ndims[2];
aml_tiling_ndims(&tiling_row, &ndims[0], &ndims[1]); aml_tiling_ndims(tiling_row, &ndims[0], &ndims[1]);
for(int k = 0; k < ndims[1]; k++) for(int k = 0; k < ndims[1]; k++)
{ {
...@@ -45,12 +45,12 @@ void do_work() ...@@ -45,12 +45,12 @@ void do_work()
{ {
size_t aoff, boff, coff; size_t aoff, boff, coff;
double *ap, *bp, *cp; double *ap, *bp, *cp;
aoff = aml_tiling_tileid(&tiling_col, i, k); aoff = aml_tiling_tileid(tiling_col, i, k);
boff = aml_tiling_tileid(&tiling_row, k, j); boff = aml_tiling_tileid(tiling_row, k, j);
coff = aml_tiling_tileid(&tiling_row, i, j); coff = aml_tiling_tileid(tiling_row, i, j);
ap = aml_tiling_tilestart(&tiling_col, a, aoff); ap = aml_tiling_tilestart(tiling_col, a, aoff);
bp = aml_tiling_tilestart(&tiling_row, b, boff); bp = aml_tiling_tilestart(tiling_row, b, boff);
cp = aml_tiling_tilestart(&tiling_row, c, coff); cp = aml_tiling_tilestart(tiling_row, c, coff);
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, ldc, lda, ldb, 1.0, ap, lda, bp, ldb, 1.0, cp, ldc); cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, ldc, lda, ldb, 1.0, ap, lda, bp, ldb, 1.0, cp, ldc);
} }
} }
...@@ -72,10 +72,10 @@ int main(int argc, char* argv[]) ...@@ -72,10 +72,10 @@ 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_2d_init(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR, assert(!aml_tiling_2d_create(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
assert(!aml_tiling_2d_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR, assert(!aml_tiling_2d_create(&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,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
...@@ -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_2d_fini(&tiling_row); aml_tiling_2d_destroy(&tiling_row);
aml_tiling_2d_fini(&tiling_col); aml_tiling_2d_destroy(&tiling_col);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
AML_TILING_2D_ROWMAJOR_DECL(tiling_row); struct aml_tiling *tiling_row;
AML_TILING_2D_COLMAJOR_DECL(tiling_col); struct aml_tiling *tiling_col;
AML_TILING_1D_DECL(tiling_prefetch); struct aml_tiling *tiling_prefetch;
AML_SCRATCH_PAR_DECL(sa); struct aml_scratch *sa;
AML_SCRATCH_PAR_DECL(sb); struct aml_scratch *sb;
struct aml_area *slow, *fast; struct aml_area *slow, *fast;
size_t memsize, tilesize, N, T; size_t memsize, tilesize, N, T;
...@@ -45,19 +45,19 @@ void do_work() ...@@ -45,19 +45,19 @@ void do_work()
int ai, bi, oldai, oldbi; int ai, bi, oldai, oldbi;
void *abaseptr, *bbaseptr; void *abaseptr, *bbaseptr;
struct aml_scratch_request *ar, *br; struct aml_scratch_request *ar, *br;
aml_tiling_ndims(&tiling_row, &ndims[0], &ndims[1]); aml_tiling_ndims(tiling_row, &ndims[0], &ndims[1]);
abaseptr = aml_scratch_baseptr(&sa); abaseptr = aml_scratch_baseptr(sa);
bbaseptr = aml_scratch_baseptr(&sb); bbaseptr = aml_scratch_baseptr(sb);
prea = aml_tiling_tilestart(&tiling_prefetch, a, 0); prea = aml_tiling_tilestart(tiling_prefetch, a, 0);
preb = aml_tiling_tilestart(&tiling_prefetch, b, 0); preb = aml_tiling_tilestart(tiling_prefetch, b, 0);
ai = -1; bi = -1; ai = -1; bi = -1;
for(int k = 0; k < ndims[1]; k++) for(int k = 0; k < ndims[1]; k++)
{ {
oldbi = bi; oldbi = bi;
oldai = ai; oldai = ai;
aml_scratch_async_pull(&sa, &ar, abaseptr, &ai, a, k + 1); aml_scratch_async_pull(sa, &ar, abaseptr, &ai, a, k + 1);
aml_scratch_async_pull(&sb, &br, bbaseptr, &bi, b, k + 1); aml_scratch_async_pull(sb, &br, bbaseptr, &bi, b, k + 1);
#pragma omp parallel for #pragma omp parallel for
for(int i = 0; i < ndims[0]; i++) for(int i = 0; i < ndims[0]; i++)
{ {
...@@ -65,25 +65,25 @@ void do_work() ...@@ -65,25 +65,25 @@ void do_work()
{ {
size_t coff; size_t coff;
double *ap, *bp, *cp; double *ap, *bp, *cp;
ap = aml_tiling_tilestart(&tiling_row, prea, i); ap = aml_tiling_tilestart(tiling_row, prea, i);
bp = aml_tiling_tilestart(&tiling_row, preb, j); bp = aml_tiling_tilestart(tiling_row, preb, j);
coff = aml_tiling_tileid(&tiling_row, i, j); coff = aml_tiling_tileid(tiling_row, i, j);
cp = aml_tiling_tilestart(&tiling_row, c, coff); cp = aml_tiling_tilestart(tiling_row, c, coff);
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, ldc, lda, ldb, 1.0, ap, lda, bp, ldb, 1.0, cp, ldc); cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, ldc, lda, ldb, 1.0, ap, lda, bp, ldb, 1.0, cp, ldc);
} }
} }
aml_scratch_wait(&sa, ar); aml_scratch_wait(sa, ar);
aml_scratch_wait(&sb, br); aml_scratch_wait(sb, br);
prea = aml_tiling_tilestart(&tiling_prefetch, abaseptr, ai); prea = aml_tiling_tilestart(tiling_prefetch, abaseptr, ai);
preb = aml_tiling_tilestart(&tiling_prefetch, bbaseptr, bi); preb = aml_tiling_tilestart(tiling_prefetch, bbaseptr, bi);
aml_scratch_release(&sa, oldai); aml_scratch_release(sa, oldai);
aml_scratch_release(&sb, oldbi); aml_scratch_release(sb, oldbi);
} }
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
AML_DMA_LINUX_SEQ_DECL(dma); struct aml_dma *dma;
struct aml_bitmap slowb, fastb; struct aml_bitmap slowb, fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 5); assert(argc == 5);
...@@ -97,13 +97,13 @@ int main(int argc, char* argv[]) ...@@ -97,13 +97,13 @@ 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_2d_init(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR, assert(!aml_tiling_2d_create(&tiling_row, AML_TILING_TYPE_2D_ROWMAJOR,
tilesize, memsize, N/T , N/T)); tilesize, memsize, N/T , N/T));
assert(!aml_tiling_2d_init(&tiling_col, AML_TILING_TYPE_2D_COLMAJOR, assert(!aml_tiling_2d_create(&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_1d_init(&tiling_prefetch, assert(!aml_tiling_1d_create(&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,
&slowb, AML_AREA_LINUX_BINDING_FLAG_BIND); &slowb, AML_AREA_LINUX_BINDING_FLAG_BIND);
...@@ -112,9 +112,9 @@ int main(int argc, char* argv[]) ...@@ -112,9 +112,9 @@ int main(int argc, char* argv[])
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
assert(!aml_dma_linux_seq_init(&dma, 2)); assert(!aml_dma_linux_seq_create(&dma, 2));
assert(!aml_scratch_par_init(&sa, &fast, &slow, &dma, &tiling_prefetch, (size_t)2, (size_t)2)); assert(!aml_scratch_par_create(&sa, fast, slow, dma, tiling_prefetch, (size_t)2, (size_t)2));
assert(!aml_scratch_par_init(&sb, &fast, &slow, &dma, &tiling_prefetch, (size_t)2, (size_t)2)); assert(!aml_scratch_par_create(&sb, fast, slow, dma, tiling_prefetch, (size_t)2, (size_t)2));
/* allocation */ /* allocation */
a = aml_area_mmap(slow, NULL, memsize); a = aml_area_mmap(slow, NULL, memsize);
b = aml_area_mmap(slow, NULL, memsize); b = aml_area_mmap(slow, NULL, memsize);
...@@ -182,17 +182,17 @@ int main(int argc, char* argv[]) ...@@ -182,17 +182,17 @@ int main(int argc, char* argv[])
/* print the flops in GFLOPS */ /* print the flops in GFLOPS */
printf("dgemm-prefetch: %llu %lld %lld %f\n", N, memsize, time, printf("dgemm-prefetch: %llu %lld %lld %f\n", N, memsize, time,
flops/1e9); flops/1e9);
aml_scratch_par_fini(&sa); aml_scratch_par_destroy(&sa);
aml_scratch_par_fini(&sb); aml_scratch_par_destroy(&sb);
aml_dma_linux_seq_fini(&dma); aml_dma_linux_seq_destroy(&dma);
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
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_2d_fini(&tiling_row); aml_tiling_2d_destroy(&tiling_row);
aml_tiling_2d_fini(&tiling_col); aml_tiling_2d_destroy(&tiling_col);
aml_tiling_1d_fini(&tiling_prefetch); aml_tiling_1d_destroy(&tiling_prefetch);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -38,8 +38,8 @@ int main(int argc, char *argv[]) ...@@ -38,8 +38,8 @@ int main(int argc, char *argv[])
*/ */
struct aml_area *slow = &aml_area_linux, *fast = aml_area_linux; struct aml_area *slow = &aml_area_linux, *fast = aml_area_linux;
struct aml_dma dma; struct aml_dma *dma;
assert(!aml_dma_init(&dma, 0)); assert(!aml_dma_create(&dma, 0));
void *a, *b, *c; void *a, *b, *c;
...@@ -75,19 +75,19 @@ int main(int argc, char *argv[]) ...@@ -75,19 +75,19 @@ int main(int argc, char *argv[])
{ {
for(unsigned long i = 0; i < numthreads*CHUNKING; i++) { for(unsigned long i = 0; i < numthreads*CHUNKING; i++) {
#pragma omp task depend(inout: wa[i*esz:esz]) #pragma omp task depend(inout: wa[i*esz:esz])
assert(!aml_dma_move(&dma, &fast, &slow, &wa[i*esz], esz)); assert(!aml_dma_move(dma, &fast, &slow, &wa[i*esz], esz));
#pragma omp task depend(inout: wb[i*esz:esz]) #pragma omp task depend(inout: wb[i*esz:esz])
assert(!aml_dma_move(&dma, &fast, &slow, &wb[i*esz], esz)); assert(!aml_dma_move(dma, &fast, &slow, &wb[i*esz], esz));
#pragma omp task depend(inout: wc[i*esz:esz]) #pragma omp task depend(inout: wc[i*esz:esz])
assert(!aml_dma_move(&dma, &fast, &slow, &wc[i*esz], esz)); assert(!aml_dma_move(dma, &fast, &slow, &wc[i*esz], esz));
#pragma omp task depend(in: wa[i*esz:esz], wb[i*esz:esz]) depend(out: wc[i*esz:esz]) #pragma omp task depend(in: wa[i*esz:esz], wb[i*esz:esz]) depend(out: wc[i*esz:esz])
kernel(&wa[i*esz], &wb[i*esz], &wc[i*esz], esz); kernel(&wa[i*esz], &wb[i*esz], &wc[i*esz], esz);
#pragma omp task depend(inout: wa[i*esz:esz]) #pragma omp task depend(inout: wa[i*esz:esz])
assert(!aml_dma_move(&dma, &slow, &fast, &wa[i*esz], esz)); assert(!aml_dma_move(dma, &slow, &fast, &wa[i*esz], esz));
#pragma omp task depend(inout: wb[i*esz:esz]) #pragma omp task depend(inout: wb[i*esz:esz])
assert(!aml_dma_move(&dma, &slow, &fast, &wb[i*esz], esz)); assert(!aml_dma_move(dma, &slow, &fast, &wb[i*esz], esz));
#pragma omp task depend(inout: wc[i*esz:esz]) #pragma omp task depend(inout: wc[i*esz:esz])
assert(!aml_dma_move(&dma, &slow, &fast, &wc[i*esz], esz)); assert(!aml_dma_move(dma, &slow, &fast, &wc[i*esz], esz));
} }
} }
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
size_t numthreads, tilesz, esz; size_t numthreads, tilesz, esz;
unsigned long *a, *b, *c; unsigned long *a, *b, *c;
AML_TILING_1D_DECL(tiling); struct aml_tiling *tiling;
struct aml_area *slow, *fast; struct aml_area *slow, *fast;
AML_SCRATCH_SEQ_DECL(sa); struct aml_scratch *sa;
AML_SCRATCH_SEQ_DECL(sb); struct aml_scratch *sb;
int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n) int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n)
{ {
...@@ -42,7 +42,7 @@ int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n) ...@@ -42,7 +42,7 @@ int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
AML_DMA_LINUX_PAR_DECL(dma); struct aml_dma *dma;
struct aml_bitmap slowb, fastb; struct aml_bitmap slowb, fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 4); assert(argc == 4);
...@@ -63,17 +63,17 @@ int main(int argc, char *argv[]) ...@@ -63,17 +63,17 @@ int main(int argc, char *argv[])
} }
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_1d_init(&tiling, tilesz, memsize)); assert(!aml_tiling_1d_create(&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);
aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
assert(!aml_dma_linux_par_init(&dma, numthreads*2, numthreads)); assert(!aml_dma_linux_par_create(&dma, numthreads*2, numthreads));
assert(!aml_scratch_seq_init(&sa, &fast, &slow, &dma, &tiling, assert(!aml_scratch_seq_create(&sa, fast, slow, dma, tiling,
(size_t)2*numthreads, (size_t)1)); (size_t)2*numthreads, (size_t)1));
assert(!aml_scratch_seq_init(&sb, &fast, &slow, &dma, &tiling, assert(!aml_scratch_seq_create(&sb, fast, slow, dma, tiling,
(size_t)2*numthreads, (size_t)1)); (size_t)2*numthreads, (size_t)1));
/* allocation */ /* allocation */
...@@ -93,23 +93,23 @@ int main(int argc, char *argv[]) ...@@ -93,23 +93,23 @@ int main(int argc, char *argv[])
int i, ai, bi, oldai, oldbi; int i, ai, bi, oldai, oldbi;
unsigned long *ap, *bp; unsigned long *ap, *bp;
void *abaseptr, *bbaseptr; void *abaseptr, *bbaseptr;
ap = aml_tiling_tilestart(&tiling, a, 0); ap = aml_tiling_tilestart(tiling, a, 0);
bp = aml_tiling_tilestart(&tiling, b, 0); bp = aml_tiling_tilestart(tiling, b, 0);
abaseptr = aml_scratch_baseptr(&sa); abaseptr = aml_scratch_baseptr(sa);
bbaseptr = aml_scratch_baseptr(&sb); bbaseptr = aml_scratch_baseptr(sb);
ai = -1; bi = -1; ai = -1; bi = -1;
for(i = 0; i < (memsize/tilesz) -1; i++) { for(i = 0; i < (memsize/tilesz) -1; i++) {
struct aml_scratch_request *ar, *br; struct aml_scratch_request *ar, *br;
oldai = ai; oldbi = bi; oldai = ai; oldbi = bi;
aml_scratch_async_pull(&sa, &ar, abaseptr, &ai, a, i+1); aml_scratch_async_pull(sa, &ar, abaseptr, &ai, a, i+1);
aml_scratch_async_pull(&sb, &br, bbaseptr, &bi, b, i+1); aml_scratch_async_pull(sb, &br, bbaseptr, &bi, b, i+1);
kernel(ap, bp, &c[i*esz], esz); kernel(ap, bp, &c[i*esz], esz);
aml_scratch_wait(&sa, ar); aml_scratch_wait(sa, ar);
aml_scratch_wait(&sb, br); aml_scratch_wait(sb, br);
ap = aml_tiling_tilestart(&tiling, abaseptr, ai); ap = aml_tiling_tilestart(tiling, abaseptr, ai);
bp = aml_tiling_tilestart(&tiling, bbaseptr, bi); bp = aml_tiling_tilestart(tiling, bbaseptr, bi);
aml_scratch_release(&sa, oldai); aml_scratch_release(sa, oldai);
aml_scratch_release(&sb, oldbi); aml_scratch_release(sb, oldbi);
} }
kernel(ap, bp, &c[i*esz], esz); kernel(ap, bp, &c[i*esz], esz);
...@@ -118,15 +118,15 @@ int main(int argc, char *argv[]) ...@@ -118,15 +118,15 @@ int main(int argc, char *argv[])
assert(c[i] == esize); assert(c[i] == esize);
} }
aml_scratch_seq_fini(&sa); aml_scratch_seq_destroy(&sa);
aml_scratch_seq_fini(&sb); aml_scratch_seq_destroy(&sb);
aml_dma_linux_par_fini(&dma); aml_dma_linux_par_destroy(&dma);
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
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_1d_fini(&tiling); aml_tiling_1d_destroy(&tiling);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
size_t numthreads, tilesz, esz; size_t numthreads, tilesz, esz;
unsigned long *a, *b, *c; unsigned long *a, *b, *c;
AML_TILING_1D_DECL(tiling); struct aml_tiling *tiling;
struct aml_area *slow, *fast; struct aml_area *slow, *fast;
AML_SCRATCH_PAR_DECL(sa); struct aml_scratch *sa;
AML_SCRATCH_PAR_DECL(sb); struct aml_scratch *sb;
int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n) int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n)
{ {
...@@ -47,32 +47,32 @@ void do_work(unsigned long tid) ...@@ -47,32 +47,32 @@ void do_work(unsigned long tid)
unsigned long *ap, *bp, *cp; unsigned long *ap, *bp, *cp;
void *abaseptr, *bbaseptr; void *abaseptr, *bbaseptr;
offset = tid*CHUNKING; offset = tid*CHUNKING;
ap = aml_tiling_tilestart(&tiling, a, offset); ap = aml_tiling_tilestart(tiling, a, offset);
bp = aml_tiling_tilestart(&tiling, b, offset); bp = aml_tiling_tilestart(tiling, b, offset);
cp = aml_tiling_tilestart(&tiling, c, offset); cp = aml_tiling_tilestart(tiling, c, offset);
abaseptr = aml_scratch_baseptr(&sa); abaseptr = aml_scratch_baseptr(sa);
bbaseptr = aml_scratch_baseptr(&sb); bbaseptr = aml_scratch_baseptr(sb);
ai = -1; bi = -1; ai = -1; bi = -1;
for(i = 0; i < CHUNKING-1; i++) { for(i = 0; i < CHUNKING-1; i++) {
struct aml_scratch_request *ar, *br; struct aml_scratch_request *ar, *br;
oldai = ai; oldbi = bi; oldai = ai; oldbi = bi;
aml_scratch_async_pull(&sa, &ar, abaseptr, &ai, a, offset+i+1); aml_scratch_async_pull(sa, &ar, abaseptr, &ai, a, offset+i+1);
aml_scratch_async_pull(&sb, &br, bbaseptr, &bi, b, offset+i+1); aml_scratch_async_pull(sb, &br, bbaseptr, &bi, b, offset+i+1);
kernel(ap, bp, cp, esz); kernel(ap, bp, cp, esz);
aml_scratch_wait(&sa, ar); aml_scratch_wait(sa, ar);
aml_scratch_wait(&sb, br); aml_scratch_wait(sb, br);
ap = aml_tiling_tilestart(&tiling, abaseptr, ai); ap = aml_tiling_tilestart(tiling, abaseptr, ai);
bp = aml_tiling_tilestart(&tiling, bbaseptr, bi); bp = aml_tiling_tilestart(tiling, bbaseptr, bi);
cp = aml_tiling_tilestart(&tiling, c, offset+i+1); cp = aml_tiling_tilestart(tiling, c, offset+i+1);
aml_scratch_release(&sa, oldai); aml_scratch_release(sa, oldai);
aml_scratch_release(&sb, oldbi); aml_scratch_release(sb, oldbi);
} }
kernel(ap, bp, cp, esz); kernel(ap, bp, cp, esz);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
AML_DMA_LINUX_SEQ_DECL(dma); struct aml_dma *dma;
struct aml_bitmap slowb, fastb; struct aml_bitmap slowb, fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 4); assert(argc == 4);
...@@ -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_1d_init(&tiling, tilesz, memsize)); assert(!aml_tiling_1d_create(&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);
...@@ -101,10 +101,10 @@ int main(int argc, char *argv[]) ...@@ -101,10 +101,10 @@ int main(int argc, char *argv[])
aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE, aml_area_linux_create(&fast, AML_AREA_LINUX_MMAP_FLAG_PRIVATE,
&fastb, AML_AREA_LINUX_BINDING_FLAG_BIND); &fastb, AML_AREA_LINUX_BINDING_FLAG_BIND);
assert(fast != NULL); assert(fast != NULL);
assert(!aml_dma_linux_seq_init(&dma, numthreads*2)); assert(!aml_dma_linux_seq_create(&dma, numthreads*2));
assert(!aml_scratch_par_init(&sa, &fast, &slow, &dma, &tiling, assert(!aml_scratch_par_create(&sa, fast, slow, dma, tiling,
2*numthreads, numthreads)); 2*numthreads, numthreads));
assert(!aml_scratch_par_init(&sb, &fast, &slow, &dma, &tiling, assert(!aml_scratch_par_create(&sb, fast, slow, dma, tiling,
2*numthreads, numthreads)); 2*numthreads, numthreads));
/* allocation */ /* allocation */
...@@ -131,15 +131,15 @@ int main(int argc, char *argv[]) ...@@ -131,15 +131,15 @@ int main(int argc, char *argv[])
assert(c[i] == esize); assert(c[i] == esize);
} }
aml_scratch_par_fini(&sa); aml_scratch_par_destroy(&sa);
aml_scratch_par_fini(&sb); aml_scratch_par_destroy(&sb);
aml_dma_linux_seq_fini(&dma); aml_dma_linux_seq_destroy(&dma);
aml_area_munmap(slow, a, memsize); aml_area_munmap(slow, a, memsize);
aml_area_munmap(slow, b, memsize); aml_area_munmap(slow, b, memsize);
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_1d_fini(&tiling); aml_tiling_1d_destroy(&tiling);
aml_finalize(); aml_finalize();
return 0; return 0;
} }
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
size_t numthreads, tilesz, esz; size_t numthreads, tilesz, esz;
unsigned long *a, *b, *c; unsigned long *a, *b, *c;
struct aml_area *slow, *fast; struct aml_area *slow, *fast;
AML_TILING_1D_DECL(tiling); struct aml_tiling *tiling;
AML_SCRATCH_PAR_DECL(sa); struct aml_scratch *sa;
AML_SCRATCH_PAR_DECL(sb); struct aml_scratch *sb;
int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n) int kernel(unsigned long *a, unsigned long *b, unsigned long *c, size_t n)
{ {
...@@ -53,25 +53,25 @@ void *th_work(void *arg) ...@@ -53,25 +53,25 @@ void *th_work(void *arg)
void *abaseptr, *bbaseptr; void *abaseptr, *bbaseptr;
struct winfo *wi = arg; struct winfo *wi = arg;
offset = wi->tid*CHUNKING; offset = wi->tid*CHUNKING;
ap = aml_tiling_tilestart(&tiling, a, offset); ap = aml_tiling_tilestart(tiling, a, offset);
bp = aml_tiling_tilestart(&tiling, b, offset); bp = aml_tiling_tilestart(tiling, b, offset);
cp = aml_tiling_tilestart(&tiling, c, offset); cp = aml_tiling_tilestart(tiling, c, offset);
abaseptr = aml_scratch_baseptr(&sa); abaseptr = aml_scratch_baseptr(sa);
bbaseptr = aml_scratch_baseptr(&sb); bbaseptr = aml_scratch_baseptr(sb);
ai = -1; bi = -1; ai = -1; bi = -1;
for(i = 0; i < CHUNKING-1; i++) { for(i = 0; i < CHUNKING-1; i++) {
struct aml_scratch_request *ar, *br; struct aml_scratch_request *ar, *br;
oldai = ai; oldbi = bi; oldai = ai; oldbi = bi;
aml_scratch_async_pull(&sa, &ar, abaseptr, &ai, a, offset+i+1); aml_scratch_async_pull(sa, &ar, abaseptr, &ai, a, offset+i+1);
aml_scratch_async_pull(&sb, &br, bbaseptr, &bi, b, offset+i+1); aml_scratch_async_pull(sb, &br, bbaseptr, &bi, b, offset+i+1);
kernel(ap, bp, cp, esz); kernel(ap, bp, cp, esz);
aml_scratch_wait(&sa, ar); aml_scratch_wait(sa, ar);
aml_scratch_wait(&sb, br); aml_scratch_wait(sb, br);
ap = aml_tiling_tilestart(&tiling, abaseptr, ai); ap = aml_tiling_tilestart(tiling, abaseptr, ai);
bp = aml_tiling_tilestart(&tiling, bbaseptr, bi); bp = aml_tiling_tilestart(tiling, bbaseptr, bi);
cp = aml_tiling_tilestart(&tiling, c, offset+i+1); cp = aml_tiling_tilestart(tiling, c, offset+i+1);
aml_scratch_release(&sa, oldai); aml_scratch_release(sa, oldai);
aml_scratch_release(&sb, oldbi); aml_scratch_release(sb, oldbi);
} }
kernel(ap, bp, cp, esz); kernel(ap, bp, cp, esz);
...@@ -79,7 +79,7 @@ void *th_work(void *arg) ...@@ -79,7 +79,7 @@ void *th_work(void *arg)
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
AML_DMA_LINUX_SEQ_DECL(dma); struct aml_dma *dma;
struct aml_bitmap slowb, fastb; struct aml_bitmap slowb, fastb;
aml_init(&argc, &argv); aml_init(&argc, &argv);
assert(argc == 4); assert(argc == 4);
...@@ -100,17 +100,17 @@ int main(int argc, char *argv[]) ...@@ -100,17 +100,17 @@ int main(int argc, char *argv[])
} }
/* initialize all the supporting struct */ /* initialize all the supporting struct */
assert(!aml_tiling_1d_init(&tiling, tilesz, memsize)); assert(!aml_tiling_1d_create(&tiling, tilesz, memsize));