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

map_mem / unmap! fails sporadically: array not mapped to buffer #158

Closed
skleinbo opened this issue Jun 26, 2018 · 0 comments
Closed

map_mem / unmap! fails sporadically: array not mapped to buffer #158

skleinbo opened this issue Jun 26, 2018 · 0 comments

Comments

@skleinbo
Copy link

skleinbo commented Jun 26, 2018

This minimal example demonstrates the issue:

using OpenCL

mutable struct MyBufferedType
    A::Array{Float32,1}
    A_buf::OpenCL.cl.Buffer
end
function MyBufferedType(cl_ctx::OpenCL.cl.Context)
    A = zeros(Float32,8)
    A_buf = OpenCL.cl.Buffer(Float32, cl_ctx, (:rw,:use), hostbuf=A)
    MyBufferedType(A,A_buf)
end

function main()
    cl_device = cl.devices(:gpu)[2]
    cl_ctx = cl.Context(cl_device)
    cl_queue = cl.CmdQueue(cl_ctx)
    D = MyBufferedType(cl_ctx)
    for j in 1:10^6
        try
            D.A, evt = cl.enqueue_map_mem(cl_queue, D.A_buf, :rw, 0, size(D.A), nothing, true)
            cl.wait(evt)
            cl.unmap!(cl_queue, D.A_buf,D.A)
        catch err
            println(j)
            warn(err)
            break
        end
    end
    return (cl_device,cl_ctx,cl_queue),D
end

dcq,D = main();

fails with e.g

103271
ERROR: ArgumentError: array @Ptr{Float32} @0x0000000019f5e190 is not mapped to buffer Buffer{Float32
}(@0x0000000021e61200)

The struct holds an array and a buffer. They are mapped onto each other repeatedly. The program fails reliably but randomly across different platforms and OSs (AMD GPU + Intel iGPU on Windows, NVIDIA on MacOS).

@skleinbo skleinbo changed the title MemMap / unmap! fails sporadically: array not mapped to buffer map_mem / unmap! fails sporadically: array not mapped to buffer Jun 26, 2018
@juliohm juliohm closed this as completed Oct 6, 2022
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

2 participants