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
28
Issues
28
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
10a2b644
Commit
10a2b644
authored
Apr 10, 2019
by
Swann Perarnau
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'api-create-errors' into 'master'
Improve code base for create API and style Closes
#31
See merge request
!46
parents
38a571f7
024652bd
Pipeline
#6910
passed with stages
in 6 minutes and 8 seconds
Changes
42
Pipelines
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
1380 additions
and
950 deletions
+1380
-950
.checkpatch.conf
.checkpatch.conf
+27
-0
.gitlab-ci.yml
.gitlab-ci.yml
+1
-1
benchmarks/dgemm_mkl.c
benchmarks/dgemm_mkl.c
+4
-4
benchmarks/dgemm_noprefetch.c
benchmarks/dgemm_noprefetch.c
+8
-8
benchmarks/dgemm_prefetch.c
benchmarks/dgemm_prefetch.c
+13
-13
benchmarks/stream_add_omp_mt.c
benchmarks/stream_add_omp_mt.c
+9
-9
benchmarks/stream_add_omp_st.c
benchmarks/stream_add_omp_st.c
+9
-9
benchmarks/stream_add_pth_st.c
benchmarks/stream_add_pth_st.c
+9
-9
include/aml.h
include/aml.h
+19
-53
include/aml/area/linux.h
include/aml/area/linux.h
+67
-37
include/aml/dma/linux-par.h
include/aml/dma/linux-par.h
+37
-34
include/aml/dma/linux-seq.h
include/aml/dma/linux-seq.h
+29
-29
include/aml/scratch/par.h
include/aml/scratch/par.h
+48
-44
include/aml/scratch/seq.h
include/aml/scratch/seq.h
+47
-41
include/aml/tiling/1d.h
include/aml/tiling/1d.h
+33
-0
include/aml/tiling/2d.h
include/aml/tiling/2d.h
+38
-0
include/aml/utils/bitmap.h
include/aml/utils/bitmap.h
+59
-30
include/aml/utils/error.h
include/aml/utils/error.h
+19
-30
include/aml/utils/vector.h
include/aml/utils/vector.h
+36
-18
include/aml/utils/version.h.in
include/aml/utils/version.h.in
+1
-1
src/area/area.c
src/area/area.c
+18
-24
src/area/linux.c
src/area/linux.c
+190
-157
src/dma/dma.c
src/dma/dma.c
+2
-0
src/dma/dma_linux_par.c
src/dma/dma_linux_par.c
+59
-42
src/dma/dma_linux_seq.c
src/dma/dma_linux_seq.c
+40
-25
src/scratch/scratch.c
src/scratch/scratch.c
+10
-3
src/scratch/scratch_par.c
src/scratch/scratch_par.c
+81
-55
src/scratch/scratch_seq.c
src/scratch/scratch_seq.c
+80
-53
src/tiling/tiling.c
src/tiling/tiling.c
+13
-99
src/tiling/tiling_1d.c
src/tiling/tiling_1d.c
+90
-7
src/tiling/tiling_2d.c
src/tiling/tiling_2d.c
+102
-7
src/utils/bitmap.c
src/utils/bitmap.c
+67
-21
src/utils/error.c
src/utils/error.c
+12
-21
src/utils/vector.c
src/utils/vector.c
+57
-19
tests/area/test_linux.c
tests/area/test_linux.c
+7
-6
tests/dma/test_dma_linux_par.c
tests/dma/test_dma_linux_par.c
+4
-4
tests/dma/test_dma_linux_seq.c
tests/dma/test_dma_linux_seq.c
+4
-4
tests/scratch/test_scratch_par.c
tests/scratch/test_scratch_par.c
+5
-5
tests/scratch/test_scratch_seq.c
tests/scratch/test_scratch_seq.c
+5
-5
tests/tiling/test_tiling.c
tests/tiling/test_tiling.c
+6
-8
tests/tiling/test_tiling_2d.c
tests/tiling/test_tiling_2d.c
+14
-14
tests/utils/test_vector.c
tests/utils/test_vector.c
+1
-1
No files found.
.checkpatch.conf
View file @
10a2b644
...
...
@@ -10,3 +10,30 @@
# better output format for CI
--
terse
--
no
-
summary
# files
include
/
aml
.
h
include
/
aml
/
area
/
linux
.
h
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
include
/
aml
/
utils
/
vector
.
h
src
/
aml
.
c
src
/
area
/
area
.
c
src
/
area
/
linux
.
c
src
/
dma
/
dma
.
c
src
/
dma
/
dma_linux_seq
.
c
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
src
/
utils
/
vector
.
c
.gitlab-ci.yml
View file @
10a2b644
...
...
@@ -52,4 +52,4 @@ repoquality:
checkpatch
:
stage
:
style
script
:
-
nix run -f "$ARGOPKGS" checkpatch --command checkpatch.pl
src/aml.c include/aml.h
-
nix run -f "$ARGOPKGS" checkpatch --command checkpatch.pl
benchmarks/dgemm_mkl.c
View file @
10a2b644
...
...
@@ -34,10 +34,10 @@ int main(int argc, char *argv[])
long
int
N
=
atol
(
argv
[
3
]);
unsigned
long
memsize
=
sizeof
(
double
)
*
N
*
N
;
slow
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
slow
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
slow
!=
NULL
);
fast
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
fast
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
fastb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
fast
!=
NULL
);
...
...
@@ -65,8 +65,8 @@ int main(int argc, char *argv[])
aml_area_munmap
(
slow
,
a
,
memsize
);
aml_area_munmap
(
slow
,
b
,
memsize
);
aml_area_munmap
(
fast
,
c
,
memsize
);
aml_area_linux_destroy
(
slow
);
aml_area_linux_destroy
(
fast
);
aml_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_finalize
();
return
0
;
}
benchmarks/dgemm_noprefetch.c
View file @
10a2b644
...
...
@@ -72,15 +72,15 @@ 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
));
slow
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
slow
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
slow
!=
NULL
);
fast
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
fast
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
fastb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
fast
!=
NULL
);
...
...
@@ -154,10 +154,10 @@ int main(int argc, char* argv[])
aml_area_munmap
(
slow
,
a
,
memsize
);
aml_area_munmap
(
slow
,
b
,
memsize
);
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_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
2d_fini
(
&
tiling_row
);
aml_tiling_
2d_fini
(
&
tiling_col
);
aml_finalize
();
return
0
;
}
benchmarks/dgemm_prefetch.c
View file @
10a2b644
...
...
@@ -97,18 +97,18 @@ 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
));
slow
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
slow
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
slow
!=
NULL
);
fast
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
fast
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
fastb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
fast
!=
NULL
);
...
...
@@ -182,17 +182,17 @@ int main(int argc, char* argv[])
/* print the flops in GFLOPS */
printf
(
"dgemm-prefetch: %llu %lld %lld %f
\n
"
,
N
,
memsize
,
time
,
flops
/
1e9
);
aml_scratch_par_
destroy
(
&
sa
);
aml_scratch_par_
destroy
(
&
sb
);
aml_dma_linux_seq_
destroy
(
&
dma
);
aml_scratch_par_
fini
(
&
sa
);
aml_scratch_par_
fini
(
&
sb
);
aml_dma_linux_seq_
fini
(
&
dma
);
aml_area_munmap
(
slow
,
a
,
memsize
);
aml_area_munmap
(
slow
,
b
,
memsize
);
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_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
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 @
10a2b644
...
...
@@ -63,11 +63,11 @@ int main(int argc, char *argv[])
}
/* initialize all the supporting struct */
assert
(
!
aml_tiling_
init
(
&
tiling
,
AML_TILING_TYPE_1D
,
tilesz
,
memsize
));
slow
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
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
);
fast
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
fast
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
fastb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
fast
!=
NULL
);
assert
(
!
aml_dma_linux_par_init
(
&
dma
,
numthreads
*
2
,
numthreads
));
...
...
@@ -118,15 +118,15 @@ int main(int argc, char *argv[])
assert
(
c
[
i
]
==
esize
);
}
aml_scratch_seq_
destroy
(
&
sa
);
aml_scratch_seq_
destroy
(
&
sb
);
aml_dma_linux_par_
destroy
(
&
dma
);
aml_scratch_seq_
fini
(
&
sa
);
aml_scratch_seq_
fini
(
&
sb
);
aml_dma_linux_par_
fini
(
&
dma
);
aml_area_munmap
(
slow
,
a
,
memsize
);
aml_area_munmap
(
slow
,
b
,
memsize
);
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_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
}
benchmarks/stream_add_omp_st.c
View file @
10a2b644
...
...
@@ -93,12 +93,12 @@ 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
));
slow
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
slow
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
slowb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
slow
!=
NULL
);
fast
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
fast
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
fastb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
fast
!=
NULL
);
assert
(
!
aml_dma_linux_seq_init
(
&
dma
,
numthreads
*
2
));
...
...
@@ -131,15 +131,15 @@ int main(int argc, char *argv[])
assert
(
c
[
i
]
==
esize
);
}
aml_scratch_par_
destroy
(
&
sa
);
aml_scratch_par_
destroy
(
&
sb
);
aml_dma_linux_seq_
destroy
(
&
dma
);
aml_scratch_par_
fini
(
&
sa
);
aml_scratch_par_
fini
(
&
sb
);
aml_dma_linux_seq_
fini
(
&
dma
);
aml_area_munmap
(
slow
,
a
,
memsize
);
aml_area_munmap
(
slow
,
b
,
memsize
);
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_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
}
benchmarks/stream_add_pth_st.c
View file @
10a2b644
...
...
@@ -100,11 +100,11 @@ int main(int argc, char *argv[])
}
/* initialize all the supporting struct */
assert
(
!
aml_tiling_
init
(
&
tiling
,
AML_TILING_TYPE_1D
,
tilesz
,
memsize
));
slow
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
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
);
fast
=
aml_area_linux_create
(
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
aml_area_linux_create
(
&
fast
,
AML_AREA_LINUX_MMAP_FLAG_PRIVATE
,
&
fastb
,
AML_AREA_LINUX_BINDING_FLAG_BIND
);
assert
(
fast
!=
NULL
);
assert
(
!
aml_dma_linux_seq_init
(
&
dma
,
(
size_t
)
numthreads
*
4
));
...
...
@@ -142,15 +142,15 @@ int main(int argc, char *argv[])
assert
(
c
[
i
]
==
esize
);
}
aml_scratch_par_
destroy
(
&
sa
);
aml_scratch_par_
destroy
(
&
sb
);
aml_dma_linux_seq_
destroy
(
&
dma
);
aml_scratch_par_
fini
(
&
sa
);
aml_scratch_par_
fini
(
&
sb
);
aml_dma_linux_seq_
fini
(
&
dma
);
aml_area_munmap
(
slow
,
a
,
memsize
);
aml_area_munmap
(
slow
,
b
,
memsize
);
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_area_linux_destroy
(
&
slow
);
aml_area_linux_destroy
(
&
fast
);
aml_tiling_
1d_fini
(
&
tiling
);
aml_finalize
();
return
0
;
}
include/aml.h
View file @
10a2b644
...
...
@@ -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
;
...
...
@@ -154,8 +160,10 @@ struct aml_tiling_ops {
int
flags
);
int
(
*
init_iterator
)(
struct
aml_tiling_data
*
tiling
,
struct
aml_tiling_iterator
*
iterator
,
int
flags
);
int
(
*
destroy
_iterator
)(
struct
aml_tiling_data
*
tiling
,
int
(
*
fini
_iterator
)(
struct
aml_tiling_data
*
tiling
,
struct
aml_tiling_iterator
*
iterator
);
int
(
*
destroy_iterator
)(
struct
aml_tiling_data
*
tiling
,
struct
aml_tiling_iterator
**
iterator
);
int
(
*
tileid
)(
const
struct
aml_tiling_data
*
tiling
,
va_list
coords
);
size_t
(
*
tilesize
)(
const
struct
aml_tiling_data
*
tiling
,
int
tileid
);
void
*
(
*
tilestart
)(
const
struct
aml_tiling_data
*
tiling
,
...
...
@@ -231,14 +239,22 @@ int aml_tiling_create_iterator(struct aml_tiling *tiling,
*/
int
aml_tiling_init_iterator
(
struct
aml_tiling
*
tiling
,
struct
aml_tiling_iterator
*
iterator
,
int
flags
);
/*
* Finalize an initialized tiling iterator.
* "tiling": an initialized tiling structure.
* "iterator": an initialized tiling iterator structure.
*/
void
aml_tiling_fini_iterator
(
struct
aml_tiling
*
tiling
,
struct
aml_tiling_iterator
*
iterator
);
/*
* Tears down an initialized tiling iterator.
* "tiling": an initialized tiling structure.
* "iterator": an initialized tiling iterator structure.
* Returns 0 if successful; an error code otherwise.
*/
int
aml_tiling_destroy_iterator
(
struct
aml_tiling
*
tiling
,
struct
aml_tiling_iterator
*
iterator
);
void
aml_tiling_destroy_iterator
(
struct
aml_tiling
*
tiling
,
struct
aml_tiling_iterator
*
*
iterator
);
struct
aml_tiling_iterator_ops
{
int
(
*
reset
)(
struct
aml_tiling_iterator_data
*
iterator
);
...
...
@@ -282,56 +298,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/area/linux.h
View file @
10a2b644
...
...
@@ -37,38 +37,12 @@ struct aml_area_linux_data {
};
/* Default linux area with private mapping and no binding. */
extern
const
struct
aml_area
aml_area_linux
;
extern
struct
aml_area
aml_area_linux
;
#define AML_AREA_LINUX_DECL(name) \
struct aml_area_linux_data __ ##name## _inner_data; \
struct aml_area name = { \
&aml_area_linux_ops, \
(struct aml_area_data *)&__ ## name ## _inner_data, \
}
#define AML_AREA_LINUX_ALLOCSIZE \
(sizeof(struct aml_area_linux_data) + \
sizeof(struct aml_area))
/**
* Initialize area data with struct aml_area_linux_binding. Subsequent calls to
* aml_area_mmap() with this returned area will apply binding settings.
* Returns NULL on failure with aml_errno set to:
* - AML_AREA_ENOMEM if there is not enough memory available for the operation
* - AML_AREA_EINVAL flags were not one of linux area flags.
* - AML_AREA_EDOM if binding nodeset is out of allowed nodeset.
**/
struct
aml_area
*
aml_area_linux_create
(
const
int
mmap_flags
,
const
struct
aml_bitmap
*
nodemask
,
const
int
binding_flags
);
/**
* Destroy area data containing struct aml_area_linux_binding
**/
void
aml_area_linux_destroy
(
struct
aml_area
*
area
);
/*******************************************************************************
* Linux operators
*******************************************************************************/
/**
* Bind memory of size "size" pointed by "ptr" to binding set in "bind".
...
...
@@ -80,10 +54,10 @@ aml_area_linux_mbind(struct aml_area_linux_data *bind,
void
*
ptr
,
size_t
size
);
/**
* Function to check whether binding of a ptr obtained with
* aml_area_linux_mmap() then aml_area_linux_mbind() match area settings.
* Returns 1 if mapped memory binding in ptr match area_data binding settings,
/**
* Function to check whether binding of a ptr obtained with
* aml_area_linux_mmap() then aml_area_linux_mbind() match area settings.
* Returns 1 if mapped memory binding in ptr match area_data binding settings,
* else 0.
**/
int
...
...
@@ -91,7 +65,7 @@ aml_area_linux_check_binding(struct aml_area_linux_data *area_data,
void
*
ptr
,
size_t
size
);
/**
/**
* mmap hook for aml area.
* Fails with AML_FAILURE. On failure errno should be checked for further
* error investigations.
...
...
@@ -101,14 +75,70 @@ aml_area_linux_mmap(const struct aml_area_data *area_data,
void
*
ptr
,
size_t
size
);
/**
/**
* munmap hook for aml area, to unmap memory mapped with aml_area_linux_mmap().
* Fails with AML_FAILURE. On failure errno should be checked for further
* error investigations.
**/
int
aml_area_linux_munmap
(
const
struct
aml_area_data
*
area_data
,
aml_area_linux_munmap
(
const
struct
aml_area_data
*
area_data
,
void
*
ptr
,
const
size_t
size
);
/*******************************************************************************
* create/destroy and others
*******************************************************************************/
#define AML_AREA_LINUX_DECL(name) \
struct aml_area_linux_data __ ##name## _inner_data; \
struct aml_area name = { \
&aml_area_linux_ops, \
(struct aml_area_data *)&__ ## name ## _inner_data, \
}
#define AML_AREA_LINUX_ALLOCSIZE \
(sizeof(struct aml_area_linux_data) + \
sizeof(struct aml_area))
/**
* Allocate and initialize a struct aml_area implemented by aml_area_linux
* operations.
* @param[out] area pointer to an uninitialized struct aml_area pointer to
* receive the new area.
* @param[in] mmap_flags flags to use when retrieving virtual memory with mmap
* @param[in] binding_flags, flags to use when binding memory.
* @param[in] nodemask list of memory nodes to use. Default to allowed memory
* nodes if NULL.
* @return On success, returns 0 and area points to the new aml_area.
* @return On failure, sets area to NULL and returns one of AML error codes:
* - AML_ENOMEM if there wasn't enough memory available.
* - AML_EINVAL if inputs flags were invalid.
* - AML_EDOM the nodemask provided is out of bounds (allowed nodeset).
**/
int
aml_area_linux_create
(
struct
aml_area
**
area
,
const
int
mmap_flags
,
const
struct
aml_bitmap
*
nodemask
,
const
int
binding_flags
);
/**
* Initialize a struct aml_area declared using the AML_AREA_LINUX_DECL macro.
* See aml_area_linux_create for details on arguments.
*/
int
aml_area_linux_init
(
struct
aml_area
*
area
,
const
int
mmap_flags
,
const
struct
aml_bitmap
*
nodemask
,
const
int
binding_flags
);
/**
* Finalize a struct aml_area initialized with aml_area_linux_init.
*/
void
aml_area_linux_fini
(
struct
aml_area
*
area
);
/**
* Destroy (finalize and free resources) a struct aml_area created by
* aml_area_linux_create.
*
* @param area is NULL after this call.
**/
void
aml_area_linux_destroy
(
struct
aml_area
**
area
);
#endif //AML_AREA_LINUX_NUMA_H
include/aml/dma/linux-par.h
View file @
10a2b644
...
...
@@ -41,9 +41,9 @@ struct aml_dma_linux_par_data {
};
struct
aml_dma_linux_par_ops
{
void
*
(
*
do_thread
)(
void
*
);
int
(
*
do_copy
)(
struct
aml_dma_linux_par_data
*
,
struct
aml_dma_request_linux_par
*
,
int
tid
);
void
*
(
*
do_thread
)(
void
*
thread_data
);
int
(
*
do_copy
)(
struct
aml_dma_linux_par_data
*
data
,
struct
aml_dma_request_linux_par
*
request
,
int
tid
);
};
struct
aml_dma_linux_par
{
...
...
@@ -62,39 +62,42 @@ struct aml_dma_linux_par {
(sizeof(struct aml_dma_linux_par) + \
sizeof(struct aml_dma))
/*
/*
*
* Allocates and initializes a new parallel DMA.
* "dma": an address where the pointer to the newly allocated DMA structure
* will be stored.
* Variadic arguments:
* - "nbreqs": an argument of type size_t; the initial number of slots for
* asynchronous request that are in-flight (will be increased
* automatically if necessary).
* - "nbthreads": an argument of type size_t; the number of threads to launch
* for each request.
* Returns 0 if successful; an error code otherwise.
*/
int
aml_dma_linux_par_create
(
struct
aml_dma
**
,
...);
/*
* Initializes a new parallel DMA. This is a varargs-variant of the
* aml_dma_linux_par_vinit() routine.
* "dma": an allocated DMA structure.
* Variadic arguments: see aml_dma_linux_par_create().
* Returns 0 if successful; an error code otherwise.
*/
int
aml_dma_linux_par_init
(
struct
aml_dma
*
,
...);
/*
*
* @param dma an address where the pointer to the newly allocated DMA structure
* will be stored.
* @param nbreqs the initial number of slots for asynchronous requests that are
* in-flight (will be increased automatically if necessary).
* @param nbthreads the number of threads to launch for each request.
*
* @return 0 if successful; an error code otherwise.
**/
int
aml_dma_linux_par_create
(
struct
aml_dma
**
dma
,
size_t
nbreqs
,
size_t
nbthreads
);
/**
* Initializes a new parallel DMA.
* "dma": an allocated DMA structure.
* "args": see the variadic arguments of aml_dma_linux_par_create().
* Returns 0 if successful; an error code otherwise.
*/
int
aml_dma_linux_par_vinit
(
struct
aml_dma
*
,
va_list
);
/*
* Tears down an initialized parallel DMA.
* "dma": an initialized DMA structure.
* Returns 0 if successful; an error code otherwise.
*
* @param dma a pointer to a dma declared with the AML_DMA_LINUX_PAR_DECL macro
* @param nbreqs the initial number of slots for asynchronous requests that are
* in-flight (will be increased automatically if necessary).
* @param nbthreads the number of threads to launch for each request.
*
* @return 0 if successful; an error code otherwise.
**/
int
aml_dma_linux_par_init
(
struct
aml_dma
*
dma
,
size_t
nbreqs
,
size_t
nbthreads
);
/**
* Finalize a parallel DMA
**/
void
aml_dma_linux_par_fini
(
struct
aml_dma
*
dma
);
/**
* Tears down a parallel DMA created with aml_dma_linux_par_create.
* @param dma the address of a pointer to a parallel dma. Will be NULL after.
*/
int
aml_dma_linux_par_destroy
(
struct
aml_dma
*
);
void
aml_dma_linux_par_destroy
(
struct
aml_dma
**
dma
);
#endif // AML_LINUX_DMA_LINUX_PAR_H
include/aml/dma/linux-seq.h
View file @
10a2b644
...
...
@@ -52,38 +52,38 @@ struct aml_dma_linux_seq {
(sizeof(struct aml_dma_linux_seq) + \
sizeof(struct aml_dma))
/*
/*
*
* Allocates and initializes a new sequential DMA.
* "dma": an address where the pointer to the newly allocated DMA structure
* will be stored.
* Variadic arguments:
* - "nbreqs": an argument of type size_t; the initial number of slots for
* asynchronous request that are in-flight (will be increased
* automatically if necessary).
* Returns 0 if successful; an error code otherwise.
*/
int
aml_dma_linux_seq_create
(
struct
aml_dma
**
dma
,
...);
/*
* Initializes a new sequential DMA. This is a varargs-variant of the
* aml_dma_linux_seq_vinit() routine.
* "dma": an allocated DMA structure.
* Variadic arguments: see aml_dma_linux_seq_create().
* Returns 0 if successful; an error code otherwise.
*/
int
aml_dma_linux_seq_init
(
struct
aml_dma
*
dma
,
...);
/*
*
* @param dma an address where the pointer to the newly allocated DMA structure
* will be stored.
* @param nbreqs the initial number of slots for asynchronous requests that are
* in-flight (will be increased automatically if necessary).
*
* @return 0 if successful; an error code otherwise.
**/
int
aml_dma_linux_seq_create
(
struct
aml_dma
**
dma
,
size_t
nbreqs
);
/**
* Initializes a new sequential DMA.
* "dma": an allocated DMA structure.
* "args": see the variadic arguments of aml_dma_linux_seq_create().
* Returns 0 if successful; an error code otherwise.
*/
int
aml_dma_linux_seq_vinit
(
struct
aml_dma
*
dma
,
va_list
args
);
/*
* Tears down an initialized sequential DMA.
* "dma": an initialized DMA structure.
* Returns 0 if successful; an error code otherwise.
*
* @param dma a pointer to a dma declared with the AML_DMA_LINUX_SEQ_DECL macro
* @param nbreqs same as the create version.
*
* @return 0 if successful; an error code otherwise.
**/
int
aml_dma_linux_seq_init
(
struct
aml_dma
*
dma
,
size_t
nbreqs
);
/**
* Finalize a sequential DMA
**/
void
aml_dma_linux_seq_fini
(
struct
aml_dma
*
dma
);
/**
* Tears down a sequential DMA created with aml_dma_linux_seq_create.
* @param dma the address of a pointer to a sequential dma. Will be NULL after.
*/
int
aml_dma_linux_seq_destroy
(
struct
aml_dma
*
dma
);
void
aml_dma_linux_seq_destroy
(
struct
aml_dma
*
*
dma
);
/* Performs a copy request.
* "dma" the dma_linux_seq_data associated with a linux_seq dma.
...
...
include/aml/scratch/par.h
View file @
10a2b644
...
...
@@ -31,16 +31,16 @@ struct aml_scratch_request_par {
struct
aml_scratch_par_data
{
struct
aml_area
*
src_area
,
*
sch_area
;
struct
aml_tiling
*
tiling
;
size_t
scratch_size
;
size_t
scratch_size
;
struct
aml_dma
*
dma
;
void
*
sch_ptr
;
void
*
sch_ptr
;
struct
aml_vector
tilemap
;
struct
aml_vector
requests
;
pthread_mutex_t
lock
;
};
struct
aml_scratch_par_ops
{
void
*
(
*
do_thread
)(
void
*
);
void
*
(
*
do_thread
)(
void
*
par_request
);
};
struct
aml_scratch_par
{
...
...
@@ -59,49 +59,53 @@ struct aml_scratch_par {
(sizeof(struct aml_scratch_par) + \
sizeof(struct aml_scratch))
/*
/*
*
* Allocates and initializes a new parallel scratchpad.
* "scratch": an address where the pointer to the newly allocated scratchpad
* structure will be stored.
* Variadic arguments:
* - "scratch_area": an argument of type struct aml_area*; the memory area
* where the scratchpad will be allocated from.
* - "source_area": an argument of type struct aml_area*; the memory area
* containing the user data structure.
* - "dma": an argument of type struct aml_dma*; the DMA that will be used for
* migrating data to and from the scratchpad.
* - "tiling": an argument of type struct aml_tiling*; the tiling to use on the
* user data structure and the scratchpad.
* - "nbtiles": an argument of type size_t; number of tiles to divide the
* scratchpad into.
* - "nbreqs": an argument of type size_t; the initial number of slots for
* asynchronous request that are in-flight (will be increased
* automatically if necessary).
* Returns 0 if successful; an error code otherwise.
*/
int
aml_scratch_par_create
(
struct
aml_scratch
**
scratch
,
...);
/*
* Initializes a new parallel scratchpad. This is a varargs-variant of the
* aml_scratch_par_vinit() routine.