Skip to content

SVMAllocator is hardcoded using default CommandQueue #294

@sorayuki

Description

@sorayuki

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<class T>
using RWAlloc = cl::SVMAllocator<T, cl::SVMTraitCoarse<cl::SVMTraitReadWrite<>>>;

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions