viennacl / viennacl-dev

Developer repository for ViennaCL. Visit http://viennacl.sourceforge.net/ for the latest releases.
Other
281 stars 89 forks source link

Memory Pool #270

Open kaushikcfd opened 5 years ago

kaushikcfd commented 5 years ago

This PR implements a memory pool for ViennaCL's OpenCL backend.

Brief overview of the implementation details:

These allocation calls for the temporaries were substantial when vector operations were called in PETSc. The following table shows the timings(in ms) before and after implementation of the pooled memory handle.

Before After
VecNorm 0.294 0.036
VecMDot 0.741 0.506

Details of the test:

I have attached the files for the tests, along with their makefiles.

Attachments: timings.tar.gz

kaushikcfd commented 5 years ago

cc @inducer

karlrupp commented 5 years ago

Thanks, @kaushikcfd !

While a memory pool is one way to solve the issue you have encountered with PETSc, I'm afraid this PR is way too intrusive (yet backend-specific) for achieving the actual goal of eliminating the impact of temporaries you've seen in PETSc.

Please let me spend some more thoughts on a more concise (yet equally powerful) fix that immediately carries over to the CUDA backend as well.

kaushikcfd commented 5 years ago

@karlrupp: Thanks for taking a look. This can be extended for CUDA backend as well. PyCUDA and PyOpenCL share the same memory pool implementation and hence we would also need to just add another memory pool allocator class, which would involve minimal changes.