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
27
Issues
27
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
6b5135bc
Commit
6b5135bc
authored
Sep 05, 2019
by
Swann Perarnau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[feature] dma transform on dense layouts
parent
b67af364
Pipeline
#8418
failed with stages
in 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
2 deletions
+101
-2
include/aml.h
include/aml.h
+2
-1
src/dma/dma.c
src/dma/dma.c
+99
-1
No files found.
include/aml.h
View file @
6b5135bc
...
...
@@ -882,7 +882,8 @@ int aml_dma_cancel(struct aml_dma *dma, struct aml_dma_request **req);
int
aml_copy_layout_generic
(
struct
aml_layout
*
dst
,
const
struct
aml_layout
*
src
,
void
*
arg
);
int
aml_copy_layout_transform_native
(
struct
aml_layout
*
dest
,
const
struct
aml_layout
*
src
,
void
*
arg
);
////////////////////////////////////////////////////////////////////////////////
/**
...
...
src/dma/dma.c
View file @
6b5135bc
...
...
@@ -10,7 +10,7 @@
#include "aml.h"
#include "aml/layout/native.h"
#include "aml/layout/dense.h"
#include <assert.h>
/*******************************************************************************
...
...
@@ -68,6 +68,104 @@ int aml_copy_layout_generic(struct aml_layout *dst,
return
0
;
}
static
inline
void
aml_copy_shndstr_helper
(
size_t
d
,
const
size_t
*
target_dims
,
void
*
dst
,
const
size_t
*
cumul_dst_pitch
,
const
size_t
*
dst_stride
,
const
void
*
src
,
const
size_t
*
cumul_src_pitch
,
const
size_t
*
src_stride
,
const
size_t
*
elem_number
,
size_t
elem_size
)
{
if
(
d
==
1
)
if
(
dst_stride
[
0
]
*
cumul_dst_pitch
[
0
]
==
elem_size
&&
src_stride
[
target_dims
[
0
]]
*
cumul_src_pitch
[
target_dims
[
0
]]
==
elem_size
)
memcpy
(
dst
,
src
,
elem_number
[
target_dims
[
0
]]
*
elem_size
);
else
for
(
size_t
i
=
0
;
i
<
elem_number
[
target_dims
[
0
]];
i
+=
1
)
memcpy
((
void
*
)((
intptr_t
)
dst
+
i
*
(
dst_stride
[
0
]
*
cumul_dst_pitch
[
0
])),
(
void
*
)((
intptr_t
)
src
+
i
*
(
src_stride
[
target_dims
[
0
]]
*
cumul_src_pitch
[
target_dims
[
0
]])),
elem_size
);
else
for
(
size_t
i
=
0
;
i
<
elem_number
[
target_dims
[
d
-
1
]];
i
+=
1
)
{
aml_copy_shndstr_helper
(
d
-
1
,
target_dims
,
dst
,
cumul_dst_pitch
,
dst_stride
,
src
,
cumul_src_pitch
,
src_stride
,
elem_number
,
elem_size
);
dst
=
(
void
*
)((
intptr_t
)
dst
+
dst_stride
[
d
-
1
]
*
cumul_dst_pitch
[
d
-
1
]);
src
=
(
void
*
)((
intptr_t
)
src
+
src_stride
[
target_dims
[
d
-
1
]]
*
cumul_src_pitch
[
target_dims
[
d
-
1
]]);
}
}
int
aml_copy_shndstr_c
(
size_t
d
,
const
size_t
*
target_dims
,
void
*
dst
,
const
size_t
*
cumul_dst_pitch
,
const
size_t
*
dst_stride
,
const
void
*
src
,
const
size_t
*
cumul_src_pitch
,
const
size_t
*
src_stride
,
const
size_t
*
elem_number
,
size_t
elem_size
)
{
assert
(
d
>
0
);
size_t
present_dims
;
present_dims
=
0
;
for
(
size_t
i
=
0
;
i
<
d
;
i
+=
1
)
{
assert
(
target_dims
[
i
]
<
d
);
present_dims
|=
1
<<
target_dims
[
i
];
}
for
(
size_t
i
=
0
;
i
<
d
;
i
+=
1
)
assert
(
present_dims
&
1
<<
i
);
for
(
size_t
i
=
0
;
i
<
d
-
1
;
i
+=
1
)
{
assert
(
cumul_dst_pitch
[
i
+
1
]
>=
dst_stride
[
i
]
*
cumul_dst_pitch
[
i
]
*
elem_number
[
target_dims
[
i
]]);
assert
(
cumul_src_pitch
[
i
+
1
]
>=
src_stride
[
i
]
*
cumul_src_pitch
[
i
]
*
elem_number
[
i
]);
}
aml_copy_shndstr_helper
(
d
,
target_dims
,
dst
,
cumul_dst_pitch
,
dst_stride
,
src
,
cumul_src_pitch
,
src_stride
,
elem_number
,
elem_size
);
return
0
;
}
int
aml_copy_layout_transform_native
(
struct
aml_layout
*
dst
,
const
struct
aml_layout
*
src
,
void
*
arg
)
{
size_t
d
;
size_t
elem_size
;
struct
aml_layout_dense
*
ddst
;
struct
aml_layout_dense
*
dsrc
;
const
size_t
*
target_dims
=
(
const
size_t
*
)
arg
;
ddst
=
(
struct
aml_layout_dense
*
)
dst
->
data
;
dsrc
=
(
struct
aml_layout_dense
*
)
src
->
data
;
d
=
dsrc
->
ndims
;
assert
(
d
>
0
);
elem_size
=
dsrc
->
cpitch
[
0
];
assert
(
d
==
ddst
->
ndims
);
assert
(
elem_size
==
ddst
->
cpitch
[
0
]);
for
(
size_t
i
=
0
;
i
<
d
;
i
+=
1
)
assert
(
dsrc
->
dims
[
target_dims
[
i
]]
==
ddst
->
dims
[
i
]);
return
aml_copy_shndstr_c
(
d
,
target_dims
,
ddst
->
ptr
,
ddst
->
cpitch
,
ddst
->
stride
,
dsrc
->
ptr
,
dsrc
->
cpitch
,
dsrc
->
stride
,
dsrc
->
dims
,
elem_size
);
}
/*******************************************************************************
* Generic DMA API:
* Most of the stuff is dispatched to a different layer, using type-specific
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment