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
a68f0715
Commit
a68f0715
authored
Nov 15, 2017
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new memory handler
parent
48b6502b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
0 deletions
+91
-0
CMakeLists.txt
src/ngraph/CMakeLists.txt
+1
-0
memory_handler.cpp
src/ngraph/runtime/cpu/memory_handler.cpp
+48
-0
memory_handler.hpp
src/ngraph/runtime/cpu/memory_handler.hpp
+42
-0
No files found.
src/ngraph/CMakeLists.txt
View file @
a68f0715
...
...
@@ -112,6 +112,7 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND
runtime/cpu/cpu_kernels.cpp
runtime/cpu/emitter.cpp
runtime/cpu/external_function.cpp
runtime/cpu/memory_handler.cpp
runtime/cpu/tensor_view.cpp
)
# LLVM binary builds are typically built without RTTI
...
...
src/ngraph/runtime/cpu/memory_handler.cpp
0 → 100644
View file @
a68f0715
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include "ngraph/runtime/cpu/memory_handler.hpp"
using
namespace
ngraph
;
runtime
::
cpu
::
MemoryHandler
::
MemoryHandler
(
size_t
byte_size
,
size_t
alignment
)
:
m_allocated_buffer_pool
(
nullptr
)
,
m_aligned_buffer_pool
(
nullptr
)
{
if
(
byte_size
>
0
)
{
size_t
allocation_size
=
byte_size
+
alignment
;
m_allocated_buffer_pool
=
static_cast
<
char
*>
(
malloc
(
allocation_size
));
m_aligned_buffer_pool
=
m_allocated_buffer_pool
;
size_t
mod
=
size_t
(
m_aligned_buffer_pool
)
%
alignment
;
if
(
mod
!=
0
)
{
m_aligned_buffer_pool
+=
(
alignment
-
mod
);
}
}
}
runtime
::
cpu
::
MemoryHandler
::~
MemoryHandler
()
{
if
(
m_allocated_buffer_pool
!=
nullptr
)
{
free
(
m_allocated_buffer_pool
);
}
}
void
*
runtime
::
cpu
::
MemoryHandler
::
get_ptr
(
size_t
offset
)
const
{
return
m_aligned_buffer_pool
+
offset
;
}
src/ngraph/runtime/cpu/memory_handler.hpp
0 → 100644
View file @
a68f0715
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#pragma once
#include <cstddef>
#include <memory>
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
class
MemoryHandler
;
}
}
}
class
ngraph
::
runtime
::
cpu
::
MemoryHandler
{
public
:
MemoryHandler
(
size_t
pool_size
,
size_t
alignment
);
~
MemoryHandler
();
void
*
get_ptr
(
size_t
offset
)
const
;
private
:
char
*
m_allocated_buffer_pool
;
char
*
m_aligned_buffer_pool
;
};
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