Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
93e87596
Commit
93e87596
authored
Apr 16, 2019
by
pruthvi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- replace aligned_alloc with malloc for portable implementation
parent
5c87a287
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
aligned_buffer.cpp
src/ngraph/runtime/aligned_buffer.cpp
+1
-1
allocator.cpp
src/ngraph/runtime/allocator.cpp
+6
-2
No files found.
src/ngraph/runtime/aligned_buffer.cpp
View file @
93e87596
...
@@ -38,7 +38,7 @@ runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment, Alloca
...
@@ -38,7 +38,7 @@ runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment, Alloca
{
{
m_byte_size
=
std
::
max
<
size_t
>
(
1
,
byte_size
);
m_byte_size
=
std
::
max
<
size_t
>
(
1
,
byte_size
);
size_t
allocation_size
=
m_byte_size
+
alignment
;
size_t
allocation_size
=
m_byte_size
+
alignment
;
m_allocated_buffer
=
static_cast
<
char
*>
(
m_allocator
->
Malloc
(
m_byte
_size
,
alignment
));
m_allocated_buffer
=
static_cast
<
char
*>
(
m_allocator
->
Malloc
(
allocation
_size
,
alignment
));
m_aligned_buffer
=
m_allocated_buffer
;
m_aligned_buffer
=
m_allocated_buffer
;
size_t
mod
=
size_t
(
m_aligned_buffer
)
%
alignment
;
size_t
mod
=
size_t
(
m_aligned_buffer
)
%
alignment
;
...
...
src/ngraph/runtime/allocator.cpp
View file @
93e87596
...
@@ -25,7 +25,11 @@ class ngraph::runtime::DefaultAllocator : public ngraph::runtime::Allocator
...
@@ -25,7 +25,11 @@ class ngraph::runtime::DefaultAllocator : public ngraph::runtime::Allocator
public
:
public
:
void
*
Malloc
(
size_t
size
,
size_t
alignment
)
void
*
Malloc
(
size_t
size
,
size_t
alignment
)
{
{
void
*
ptr
=
ngraph
::
aligned_alloc
(
alignment
,
size
);
// If allocation succeeds, returns a pointer to the lowest (first) byte in the
// allocated memory block that is suitably aligned for any scalar type.
// TODO(pruthvi): replace std::malloc with custom aligned_alloc implementation
// which is portable and work on all alignment requirement.
void
*
ptr
=
std
::
malloc
(
size
);
// check for exception
// check for exception
if
(
!
ptr
)
if
(
!
ptr
)
...
@@ -40,7 +44,7 @@ public:
...
@@ -40,7 +44,7 @@ public:
{
{
if
(
ptr
)
if
(
ptr
)
{
{
ngraph
::
aligned_
free
(
ptr
);
std
::
free
(
ptr
);
}
}
}
}
};
};
...
...
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