Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aml
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
33
Issues
33
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
aml
Commits
8797fca6
Commit
8797fca6
authored
Apr 09, 2019
by
Swann Perarnau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[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
Changes
18
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
307 additions
and
208 deletions
+307
-208
.checkpatch.conf
.checkpatch.conf
+5
-0
benchmarks/dgemm_noprefetch.c
benchmarks/dgemm_noprefetch.c
+4
-4
benchmarks/dgemm_prefetch.c
benchmarks/dgemm_prefetch.c
+6
-6
benchmarks/stream_add_omp_mt.c
benchmarks/stream_add_omp_mt.c
+2
-2
benchmarks/stream_add_omp_st.c
benchmarks/stream_add_omp_st.c
+2
-2
benchmarks/stream_add_pth_st.c
benchmarks/stream_add_pth_st.c
+2
-2
include/aml.h
include/aml.h
+6
-50
include/aml/tiling/1d.h
include/aml/tiling/1d.h
+33
-0
include/aml/tiling/2d.h
include/aml/tiling/2d.h
+38
-0
src/tiling/tiling.c
src/tiling/tiling.c
+5
-99
src/tiling/tiling_1d.c
src/tiling/tiling_1d.c
+81
-6
src/tiling/tiling_2d.c
src/tiling/tiling_2d.c
+93
-6
tests/dma/test_dma_linux_par.c
tests/dma/test_dma_linux_par.c
+3
-3
tests/dma/test_dma_linux_seq.c
tests/dma/test_dma_linux_seq.c
+3
-3
tests/scratch/test_scratch_par.c
tests/scratch/test_scratch_par.c
+3
-3
tests/scratch/test_scratch_seq.c
tests/scratch/test_scratch_seq.c
+3
-3
tests/tiling/test_tiling.c
tests/tiling/test_tiling.c
+4
-5
tests/tiling/test_tiling_2d.c
tests/tiling/test_tiling_2d.c
+14
-14
No files found.
.checkpatch.conf
View file @
8797fca6
...
...
@@ -18,6 +18,8 @@ include/aml/dma/linux-seq.h
include
/
aml
/
dma
/
linux
-
par
.
h
include
/
aml
/
scratch
/
seq
.
h
include
/
aml
/
scratch
/
par
.
h
include
/
aml
/
tiling
/
1
d
.
h
include
/
aml
/
tiling
/
2
d
.
h
include
/
aml
/
utils
/
bitmap
.
h
include
/
aml
/
utils
/
error
.
h
src
/
aml
.
c
...
...
@@ -29,4 +31,7 @@ src/dma/dma_linux_par.c
src
/
scratch
/
scratch
.
c
src
/
scratch
/
scratch_seq
.
c
src
/
scratch
/
scratch_par
.
c
src
/
tiling
/
tiling
.
c
src
/
tiling
/
tiling_1d
.
c
src
/
tiling
/
tiling_2d
.
c
src
/
utils
/
error
.
c
benchmarks/dgemm_noprefetch.c
View file @
8797fca6
...
...
@@ -72,9 +72,9 @@ int main(int argc, char* argv[])
tilesize
=
sizeof
(
double
)
*
T
*
T
;
/* 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
));
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
));
aml_area_linux_create
(
&
slow
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
...
...
@@ -156,8 +156,8 @@ int main(int argc, char* argv[])
aml_area_munmap
(
fast
,
c
,
memsize
);
aml_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
destroy
(
&
tiling_row
,
AML_TILING_TYPE_2D_ROWMAJOR
);
aml_tiling_
destroy
(
&
tiling_col
,
AML_TILING_TYPE_2D_ROWMAJOR
);
aml_tiling_
2d_fini
(
&
tiling_row
);
aml_tiling_
2d_fini
(
&
tiling_col
);
aml_finalize
();
return
0
;
}
benchmarks/dgemm_prefetch.c
View file @
8797fca6
...
...
@@ -97,12 +97,12 @@ int main(int argc, char* argv[])
tilesize
=
sizeof
(
double
)
*
T
*
T
;
/* 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
));
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
));
/* 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
));
aml_area_linux_create
(
&
slow
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
...
...
@@ -190,9 +190,9 @@ int main(int argc, char* argv[])
aml_area_munmap
(
fast
,
c
,
memsize
);
aml_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
destroy
(
&
tiling_row
,
AML_TILING_TYPE_2D_ROWMAJOR
);
aml_tiling_
destroy
(
&
tiling_col
,
AML_TILING_TYPE_2D_ROWMAJOR
);
aml_tiling_
destroy
(
&
tiling_prefetch
,
AML_TILING_TYPE_1D
);
aml_tiling_
2d_fini
(
&
tiling_row
);
aml_tiling_
2d_fini
(
&
tiling_col
);
aml_tiling_
1d_fini
(
&
tiling_prefetch
);
aml_finalize
();
return
0
;
}
benchmarks/stream_add_omp_mt.c
View file @
8797fca6
...
...
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
}
/* 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
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
slow
!=
NULL
);
...
...
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
aml_area_munmap
(
fast
,
c
,
memsize
);
aml_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
destroy
(
&
tiling
,
AML_TILING_TYPE_1D
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
}
benchmarks/stream_add_omp_st.c
View file @
8797fca6
...
...
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
}
/* 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
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
...
...
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
aml_area_munmap
(
fast
,
c
,
memsize
);
aml_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
destroy
(
&
tiling
,
AML_TILING_TYPE_1D
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
}
benchmarks/stream_add_pth_st.c
View file @
8797fca6
...
...
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
}
/* 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
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
slow
!=
NULL
);
...
...
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
aml_area_munmap
(
fast
,
c
,
memsize
);
aml_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
destroy
(
&
tiling
,
AML_TILING_TYPE_1D
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
}
include/aml.h
View file @
8797fca6
...
...
@@ -139,6 +139,12 @@ aml_area_munmap(const struct aml_area *area,
* 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 */
struct
aml_tiling_data
;
struct
aml_tiling_iterator_data
;
...
...
@@ -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
,
...);
/* 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:
* Management of low-level movement of memory.
...
...
include/aml/tiling/1d.h
View file @
8797fca6
...
...
@@ -48,4 +48,37 @@ struct aml_tiling_iterator_1d_data {
(sizeof(struct aml_tiling_iterator_1d_data) + \
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 */
include/aml/tiling/2d.h
View file @
8797fca6
...
...
@@ -59,5 +59,43 @@ struct aml_tiling_iterator_2d_data {
(sizeof(struct aml_tiling_iterator_2d_data) + \
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 */
src/tiling/tiling.c
View file @
8797fca6
...
...
@@ -21,6 +21,7 @@ int aml_tiling_tileid(const struct aml_tiling *t, ...)
assert
(
t
!=
NULL
);
va_list
ap
;
int
ret
;
va_start
(
ap
,
t
);
ret
=
t
->
ops
->
tileid
(
t
->
data
,
ap
);
va_end
(
ap
);
...
...
@@ -33,7 +34,8 @@ size_t aml_tiling_tilesize(const struct aml_tiling *t, int 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
);
return
t
->
ops
->
tilestart
(
t
->
data
,
ptr
,
tileid
);
...
...
@@ -44,6 +46,7 @@ int aml_tiling_ndims(const struct aml_tiling *t, ...)
assert
(
t
!=
NULL
);
va_list
ap
;
int
err
;
va_start
(
ap
,
t
);
err
=
t
->
ops
->
ndims
(
t
->
data
,
ap
);
va_end
(
ap
);
...
...
@@ -76,6 +79,7 @@ int aml_tiling_iterator_get(const struct aml_tiling_iterator *it, ...)
{
assert
(
it
!=
NULL
);
va_list
ap
;
va_start
(
ap
,
it
);
it
->
ops
->
get
(
it
->
data
,
ap
);
va_end
(
ap
);
...
...
@@ -111,101 +115,3 @@ int aml_tiling_destroy_iterator(struct aml_tiling *t,
assert
(
it
!=
NULL
);
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
;
}
src/tiling/tiling_1d.c
View file @
8797fca6
...
...
@@ -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
*
)
t
;
if
(
tileid
<
0
)
if
(
tileid
<
0
)
return
0
;
else
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
*
)
t
;
intptr_t
p
=
(
intptr_t
)
ptr
;
if
(
tileid
<
0
)
if
(
tileid
<
0
)
return
NULL
;
else
return
(
void
*
)(
p
+
tileid
*
data
->
blocksize
);
...
...
@@ -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
;
size_t
*
x
=
va_arg
(
ap
,
size_t
*
);
*
x
=
data
->
totalsize
/
data
->
blocksize
;
if
(
data
->
totalsize
%
data
->
blocksize
!=
0
)
if
(
data
->
totalsize
%
data
->
blocksize
!=
0
)
*
x
++
;
return
0
;
}
...
...
@@ -104,8 +107,9 @@ int aml_tiling_1d_init_iterator(struct aml_tiling_data *t,
struct
aml_tiling_iterator
*
it
,
int
flags
)
{
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
;
it
->
ops
=
&
aml_tiling_iterator_1d_ops
;
data
->
i
=
0
;
data
->
tiling
=
(
struct
aml_tiling_1d_data
*
)
t
;
...
...
@@ -117,9 +121,10 @@ int aml_tiling_1d_create_iterator(struct aml_tiling_data *t,
{
intptr_t
baseptr
,
dataptr
;
struct
aml_tiling_iterator
*
ret
;
baseptr
=
(
intptr_t
)
calloc
(
1
,
AML_TILING_ITERATOR_1D_ALLOCSIZE
);
dataptr
=
baseptr
+
sizeof
(
struct
aml_tiling_iterator
);
ret
=
(
struct
aml_tiling_iterator
*
)
baseptr
;
ret
->
data
=
(
struct
aml_tiling_iterator_data
*
)
dataptr
;
...
...
@@ -143,3 +148,73 @@ struct aml_tiling_ops aml_tiling_1d_ops = {
aml_tiling_1d_tilestart
,
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
;
return
-
AML_ENOMEM
;
}
dataptr
=
baseptr
+
sizeof
(
struct
aml_tiling
);
ret
=
(
struct
aml_tiling
*
)
baseptr
;
ret
->
data
=
(
struct
aml_tiling_data
*
)
dataptr
;
ret
->
ops
=
&
aml_tiling_1d_ops
;
err
=
aml_tiling_1d_init
(
ret
,
tilesize
,
totalsize
);
if
(
err
)
{
free
(
ret
);
ret
=
NULL
;
}
*
t
=
ret
;
return
err
;
}
int
aml_tiling_1d_init
(
struct
aml_tiling
*
t
,
size_t
tilesize
,
size_t
totalsize
)
{
int
err
;
struct
aml_tiling_1d_data
*
data
;
if
(
t
==
NULL
||
t
->
data
==
NULL
)
return
-
AML_EINVAL
;
data
=
(
struct
aml_tiling_1d_data
*
)
t
->
data
;
if
(
tilesize
>
totalsize
)
return
-
AML_EINVAL
;
data
->
blocksize
=
tilesize
;
data
->
totalsize
=
totalsize
;
return
0
;
}
void
aml_tiling_1d_fini
(
struct
aml_tiling
*
t
)
{
/* nothing to do */
}
void
aml_tiling_1d_destroy
(
struct
aml_tiling
**
t
)
{
if
(
t
==
NULL
)
return
;
free
(
*
t
);
*
t
=
NULL
;
}
src/tiling/tiling_2d.c
View file @
8797fca6
...
...
@@ -67,7 +67,8 @@ int aml_tiling_2d_rowmajor_tileid(const struct aml_tiling_data *t, va_list ap)
(
const
struct
aml_tiling_2d_data
*
)
t
;
size_t
row
=
va_arg
(
ap
,
size_t
);
size_t
col
=
va_arg
(
ap
,
size_t
);
if
(
row
>=
data
->
ndims
[
0
]
||
col
>=
data
->
ndims
[
1
])
if
(
row
>=
data
->
ndims
[
0
]
||
col
>=
data
->
ndims
[
1
])
return
-
1
;
else
return
(
row
*
data
->
ndims
[
1
])
+
col
;
...
...
@@ -79,7 +80,8 @@ int aml_tiling_2d_colmajor_tileid(const struct aml_tiling_data *t, va_list ap)
(
const
struct
aml_tiling_2d_data
*
)
t
;
size_t
row
=
va_arg
(
ap
,
size_t
);
size_t
col
=
va_arg
(
ap
,
size_t
);
if
(
row
>=
data
->
ndims
[
0
]
||
col
>=
data
->
ndims
[
1
])
if
(
row
>=
data
->
ndims
[
0
]
||
col
>=
data
->
ndims
[
1
])
return
-
1
;
else
return
(
col
*
data
->
ndims
[
0
])
+
row
;
...
...
@@ -89,19 +91,21 @@ size_t aml_tiling_2d_tilesize(const struct aml_tiling_data *t, int tileid)
{
const
struct
aml_tiling_2d_data
*
data
=
(
const
struct
aml_tiling_2d_data
*
)
t
;
if
(
tileid
<
0
||
tileid
>=
data
->
ndims
[
0
]
*
data
->
ndims
[
1
])
if
(
tileid
<
0
||
tileid
>=
data
->
ndims
[
0
]
*
data
->
ndims
[
1
])
return
0
;
else
return
data
->
blocksize
;
}
void
*
aml_tiling_2d_tilestart
(
const
struct
aml_tiling_data
*
t
,
void
*
aml_tiling_2d_tilestart
(
const
struct
aml_tiling_data
*
t
,
const
void
*
ptr
,
int
tileid
)
{
const
struct
aml_tiling_2d_data
*
data
=
(
const
struct
aml_tiling_2d_data
*
)
t
;
intptr_t
p
=
(
intptr_t
)
ptr
;
if
(
tileid
<
0
||
tileid
>=
data
->
ndims
[
0
]
*
data
->
ndims
[
1
])
if
(
tileid
<
0
||
tileid
>=
data
->
ndims
[
0
]
*
data
->
ndims
[
1
])
return
NULL
;
else
return
(
void
*
)(
p
+
tileid
*
data
->
blocksize
);
...
...
@@ -113,6 +117,7 @@ int aml_tiling_2d_ndims(const struct aml_tiling_data *t, va_list ap)
(
const
struct
aml_tiling_2d_data
*
)
t
;
size_t
*
nrows
=
va_arg
(
ap
,
size_t
*
);
size_t
*
ncols
=
va_arg
(
ap
,
size_t
*
);
/* looks totally wrong */
*
nrows
=
data
->
ndims
[
0
];
*
ncols
=
data
->
ndims
[
1
];
...
...
@@ -136,6 +141,7 @@ int aml_tiling_2d_create_iterator(struct aml_tiling_data *t,
{
intptr_t
baseptr
,
dataptr
;
struct
aml_tiling_iterator
*
ret
;
baseptr
=
(
intptr_t
)
calloc
(
1
,
AML_TILING_ITERATOR_2D_ALLOCSIZE
);
dataptr
=
baseptr
+
sizeof
(
struct
aml_tiling_iterator
);
...
...
@@ -147,7 +153,6 @@ int aml_tiling_2d_create_iterator(struct aml_tiling_data *t,
return
0
;
}
int
aml_tiling_2d_destroy_iterator
(
struct
aml_tiling_data
*
t
,
struct
aml_tiling_iterator
*
it
)
{
...
...
@@ -174,3 +179,85 @@ struct aml_tiling_ops aml_tiling_2d_colmajor_ops = {
aml_tiling_2d_tilestart
,
aml_tiling_2d_ndims
,
};
/*******************************************************************************
* 2d create/destroy
******************************************************************************/
int
aml_tiling_2d_create
(
struct
aml_tiling
**
t
,
int
type
,
size_t
tilesize
,
size_t
totalsize
,
size_t
rowsize
,
size_t
colsize
)
{
struct
aml_tiling
*
ret
=
NULL
;
intptr_t
baseptr
,
dataptr
;
int
err
;
if
(
t
==
NULL
)
return
-
AML_EINVAL
;
if
(
type
!=
AML_TILING_TYPE_2D_ROWMAJOR
&&
type
!=
AML_TILING_TYPE_2D_COLMAJOR
)
return
-
AML_EINVAL
;
/* alloc */
baseptr
=
(
intptr_t
)
calloc
(
1
,
AML_TILING_2D_ALLOCSIZE
);
if
(
baseptr
==
0
)
{
*
t
=
NULL
;
return
-
AML_ENOMEM
;
}
dataptr
=
baseptr
+
sizeof
(
struct
aml_tiling
);
ret
=
(
struct
aml_tiling
*
)
baseptr
;
ret
->
data
=
(
struct
aml_tiling_data
*
)
dataptr
;
if
(
type
==
AML_TILING_TYPE_2D_ROWMAJOR
)
ret
->
ops
=
&
aml_tiling_2d_rowmajor_ops
;
else
ret
->
ops
=
&
aml_tiling_2d_colmajor_ops
;
err
=
aml_tiling_2d_init
(
ret
,
type
,
tilesize
,
totalsize
,
rowsize
,
colsize
);
if
(
err
)
{
free
(
ret
);
ret
=
NULL
;
}
*
t
=
ret
;
return
err
;
}
int
aml_tiling_2d_init
(
struct
aml_tiling
*
t
,
int
type
,
size_t
tilesize
,
size_t
totalsize
,
size_t
rowsize
,
size_t
colsize
)
{
int
err
;
struct
aml_tiling_2d_data
*
data
;
if
(
t
==
NULL
||
t
->
data
==
NULL
)
return
-
AML_EINVAL
;
data
=
(
struct
aml_tiling_2d_data
*
)
t
->
data
;
if
(
tilesize
>
totalsize
)
return
-
AML_EINVAL
;
data
->
blocksize
=
tilesize
;
data
->
totalsize
=
totalsize
;
data
->
ndims
[
0
]
=
rowsize
;
data
->
ndims
[
1
]
=
colsize
;
return
0
;
}
void
aml_tiling_2d_fini
(
struct
aml_tiling
*
t
)
{
/* nothing to do */
}
void
aml_tiling_2d_destroy
(
struct
aml_tiling
**
t
)
{
if
(
t
==
NULL
)
return
;
free
(
*
t
);
*
t
=
NULL
;
}
tests/dma/test_dma_linux_par.c
View file @
8797fca6
...
...
@@ -28,8 +28,8 @@ int main(int argc, char *argv[])
aml_init
(
&
argc
,
&
argv
);
/* initialize all the supporting struct */
assert
(
!
aml_tiling_
init
(
&
tiling
,
AML_TILING_TYPE_1D
,
TILESIZE
*
PAGE_SIZE
,
TILESIZE
*
PAGE_SIZE
*
NBTILES
));
assert
(
!
aml_tiling_
1d_init
(
&
tiling
,
TILESIZE
*
PAGE_SIZE
,
TILESIZE
*
PAGE_SIZE
*
NBTILES
));
aml_bitmap_zero
(
&
nodemask
);
aml_bitmap_set
(
&
nodemask
,
0
);
...
...
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
aml_dma_linux_par_fini
(
&
dma
);
aml_area_munmap
(
&
aml_area_linux
,
dst
,
TILESIZE
*
PAGE_SIZE
*
NBTILES
);
aml_area_munmap
(
&
aml_area_linux
,
src
,
TILESIZE
*
PAGE_SIZE
*
NBTILES
);
aml_tiling_
destroy
(
&
tiling
,
AML_TILING_TYPE_1D
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
...
...
tests/dma/test_dma_linux_seq.c
View file @
8797fca6
...
...
@@ -28,8 +28,8 @@ int main(int argc, char *argv[])
aml_init
(
&
argc
,
&
argv
);
/* initialize all the supporting struct */
assert
(
!
aml_tiling_
init
(
&
tiling
,
AML_TILING_TYPE_1D
,
TILESIZE
*
PAGE_SIZE
,