Commit 93e87596 authored by pruthvi's avatar pruthvi

- replace aligned_alloc with malloc for portable implementation

parent 5c87a287
...@@ -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;
......
...@@ -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);
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment