Use SVM memory pool - #706
Conversation
|
cc @inducer Edit: inducer/arraycontext#186 seems to have fixed this. |
|
What do you think of the get_reasonable_memory_pool interface @inducer? |
|
From my perspective, this is ready for review. This should work whether the other PRs (e.g. inducer/pyopencl#452) are merged or not. |
| def get_reasonable_memory_pool(ctx, queue): | ||
| """Return an SVM or buffer memory pool based on what the device supports.""" | ||
| from pyopencl.characterize import has_coarse_grain_buffer_svm | ||
| import pyopencl.tools as cl_tools | ||
|
|
||
| if has_coarse_grain_buffer_svm(queue.device) and hasattr(cl_tools, "SVMPool"): | ||
| logger.info("Using SVM-based memory pool") | ||
| return cl_tools.SVMPool(cl_tools.SVMAllocator( # pylint: disable=no-member | ||
| ctx, alignment=0, queue=queue)) | ||
| else: | ||
| from warnings import warn | ||
| warn("No SVM support, returning a CL buffer-based memory pool") | ||
| return cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) |
There was a problem hiding this comment.
My thought was that this function is very specific to our use case - other applications using pyopencl probably won't care much for this function since it is unlikely they would prefer an SVM pool over a buffer pool. I thought about putting this in grudge, but it also doesn't feel relevant there.
There was a problem hiding this comment.
I defer to your judgement on this, i was mostly curious
MTCam
left a comment
There was a problem hiding this comment.
lgtm! we just gotta get the downstream examples updated.
| ctx, alignment=0, queue=queue)) | ||
| else: | ||
| from warnings import warn | ||
| warn("No SVM support, returning a CL buffer-based memory pool") |
There was a problem hiding this comment.
Tell the user what aspect is missing (SVM for the device, vs missing newfangled SVM in pyopencl).
inducer
left a comment
There was a problem hiding this comment.
LGTM with more detailed diagnostics.
related PRs:
clEnqueueSVMMemFree: copy pointers pocl/pocl#1069pocl conda files: