KhronosGroup / KhronosGroup/OpenCL-CLHPP

SVMAllocator is hardcoded using default CommandQueue

Open
#294 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
425
Forks
133
Avg merge
3h 30m
Merged PRs (30d)
1

Description

When working with the C++ binding header, the class SVMAllocator comes with a constructor accepting a cl::Context parameter.

But when cl::vector with SVMAllocator constructing with default value, it will call a enqueueMapSVM and use cl::CommandQueue::getDefault to do the mapping. It may not associate with the cl::Context which the SVMAllocator belongs.

For example, take a look at this piece of code

```
template
using RWAlloc = cl::SVMAllocator>>;

void DoTest(cl::Platform plat) {
cl::vector devices;
ctx.plat.getDevices(CL_DEVICE_TYPE_ALL, &devices);
cl::Context clctx(devices);
cl::CommandQueue queue{ clctx };

RWAlloc rwalloc(clctx);
std::vector> input(numElements, 1, rwalloc);
...
```

The code crashes when constructing input.
It would be better if SVMAllocator comes with a CommandQueue parameter.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing SVMAllocator construction and its enqueueMapSVM path, especially where CommandQueue::getDefault is used during cl::vector allocation. Reproduce the provided example and verify that mapping uses the allocator's associated context or queue without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.