Skip to content

Refactor memory manager. Remove buffer_info. Simplify allocs. Disable Events - #2689

Merged
umar456 merged 2 commits into
arrayfire:masterfrom
umar456:refactor_memman
Dec 11, 2019
Merged

umar456 merged 2 commits into
arrayfire:masterfrom
umar456:refactor_memman

Conversation

@umar456

@umar456 umar456 commented Dec 10, 2019

Copy link
Copy Markdown
Member
  • Removed buffer_info from the allocation calls

The buffer_info object was created so that the event synchonization was
performed in the memAlloc call instead of in the memory manager. It did not have
significant benefit over performing the synchronization within the memory
manager and increased complexity of the API. Now that the events API is
exposed, it shouldn't be necessary to include this.

  • Moved memory manager classes into separate files in the common directory
  • Use memAlloc instead of bufferAlloc in OpenCL Array initializtion to
    provide type context to the memory manager. Avoid inconsistencies between
    backends.
  • Use objects instead of handles within the codebase

* Removed buffer_info from the allocation calls

The buffer_info object was created so that the event synchonization was
performed in the memAlloc call instead of in the memory manager. It did not have
significant benefit over performing the synchronization within the memory
manager and increased complexity of the API. Now that the events API is
exposed, it shouldn't be necessary to include this.

* Moved memory manager classes into separate files in the common directory
* Use memAlloc instead of bufferAlloc in OpenCL Array<T> initializtion to
  provide type context to the memory manager. Avoid inconsistencies between
  backends.
* Use objects instead of handles within the codebase

@9prady9 9prady9 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are refactoring bufferAlloc calls under OpenCL backend to memAlloc, can you do it other places also - they are mostly done in vision backend implementations.

Comment thread src/backend/opencl/Array.cpp Resolved
@WilliamTambellini

Copy link
Copy Markdown
Contributor

For one of my NN, the speed seems a little better than the master branch (as today):
master: 34s
this change: 32s
but still far from 3.6.4: 23s

@WilliamTambellini WilliamTambellini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking : is that change disabling events ?

@umar456

umar456 commented Dec 10, 2019

Copy link
Copy Markdown
Member Author

Yes. This PR also disables events.

@jacobkahn jacobkahn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Is the intention here to completely remove events from memory management components for now rather than gating them? Removing af_buffer_info seems like it'll make adding events back later a breaking API change, unless we want to make Arrays aware of events rather than the memory manager

Comment thread test/memory.cpp
ASSERT_EQ(payload->lastElementSize, 1);
}
ASSERT_EQ(payload->lastDims, af::dim4(bDim * b.numdims()));
ASSERT_EQ(payload->lastElementSize, sizeof(float));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// DefaultMemoryManager(const DefaultMemoryManager &&other) = default;
DefaultMemoryManager &operator=(const DefaultMemoryManager &other) = delete;
// DefaultMemoryManager &operator=(const DefaultMemoryManager &&other) =
// default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove or uncomment the move ctor/assignment op? Although this should be movable.

@umar456

umar456 commented Dec 11, 2019

Copy link
Copy Markdown
Member Author

I think the events could be handled in the memory manager without exposing it to ArrayFire. Earlier, I was thinking we could add the returned events and make it part of the Array object. I don't think this is necessary because the memory manager can enqueue those waits before it returns the pointer. The end result would be the same.

With the events API exposed the memory manager can handle this sort of thing externally.

@umar456

umar456 commented Dec 11, 2019

Copy link
Copy Markdown
Member Author

@9prady9 converting from bufferAlloc to memAlloc would be a pretty large change. I think we should do that on another PR.

@umar456 umar456 changed the title Refactor memory manager. Remove buffer_info. Simplify allocs Refactor memory manager. Remove buffer_info. Simplify allocs. Disable Events Dec 11, 2019
@umar456
umar456 dismissed 9prady9’s stale review December 11, 2019 22:13

Addressed Changes.

@umar456
umar456 merged commit af665bc into arrayfire:master Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants