Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVMAllocator is hardcoded using default CommandQueue #106

Closed
sorayuki opened this issue May 18, 2024 · 1 comment
Closed

SVMAllocator is hardcoded using default CommandQueue #106

sorayuki opened this issue May 18, 2024 · 1 comment

Comments

@sorayuki
Copy link

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.

@sorayuki
Copy link
Author

move to KhronosGroup/OpenCL-CLHPP#294

@sorayuki sorayuki closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2024
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

No branches or pull requests

1 participant