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

Issues with native execution on Intel #252

Open
maleadt opened this issue Oct 8, 2024 · 1 comment
Open

Issues with native execution on Intel #252

maleadt opened this issue Oct 8, 2024 · 1 comment

Comments

@maleadt
Copy link
Member

maleadt commented Oct 8, 2024

Intel is one of the few platforms that also supports IL execution, however something seems wrong:

using OpenCL

cl.platform!("intel")

function memset(a, val)
    @inbounds a[1] = val
    return
end

function main()
    a = CLArray{Int}(undef, 1)
    @opencl memset(a, 42)
    Array(a)
end
julia> main()
1-element Vector{Int64}:
 42

julia> main()
1-element Vector{Int64}:
 0

julia> main()
1-element Vector{Int64}:
 0

Not sure yet what the issue is here.

@maleadt
Copy link
Member Author

maleadt commented Oct 8, 2024

Looks like this works when not using uninitialized memory:

function main()
    # broken
    a = CLArray{Int}(undef, 1)
    # working
    a = CLArray{Int}([1])
    
    @opencl memset(a, 42)
    println("Result: ", Array(a)[])
end
julia> uninitialized()
libopencl.clSVMAlloc(OpenCL.cl.Context(id=0x0000000032fd8f20), 1, 8, 0) = Ptr{Nothing} @0x0000791e9b200000
libopencl.clSetKernelArg(OpenCL.cl.Kernel(id=0x00000000349537e0), 0x00000000, 32, Ref{OpenCL.CLDeviceArray{Int64, 1, 1}}) = 0
 4: 1-element device array at Core.LLVMPtr{Int64, 1}(0x0000791e9b200000)
libopencl.clSetKernelArg(OpenCL.cl.Kernel(id=0x00000000349537e0), 0x00000001, 8, Ref{Int64}) = 0
 4: 42
libopencl.clGetDeviceInfo(OpenCL.cl.Device(id=0x0000000032cf3020), 0x1003, 4, Ref{UInt32}, 0x0000000000000000) = 0
 4: 3
libopencl.clEnqueueNDRangeKernel(OpenCL.cl.CmdQueue(id=0x0000000031b9d5d0), OpenCL.cl.Kernel(id=0x00000000349537e0), 0x00000001, 0x0000000000000000, 1-element Vector{UInt64}, 0x0000000000000000, 0x00000000, 0x0000000000000000, Ref{Ptr{OpenCL.cl._cl_event}}) = 0
 9: Ptr{OpenCL.cl._cl_event} @0x0000000037d36c40
libopencl.clEnqueueSVMMemcpy(OpenCL.cl.CmdQueue(id=0x0000000031b9d5d0), true, 0x0000791f7799da00, 0x0000791e9b200000, 8, 0, 0x0000000000000000, Ref{Ptr{OpenCL.cl._cl_event}}) = 0
 8: Ptr{OpenCL.cl._cl_event} @0x0000000037c7bf60
Result: 0

julia> initialized()
libopencl.clSVMAlloc(OpenCL.cl.Context(id=0x0000000032fd8f20), 1, 8, 0) = Ptr{Nothing} @0x0000791e9ae00000
libopencl.clEnqueueSVMMemcpy(OpenCL.cl.CmdQueue(id=0x0000000031b9d5d0), true, 0x0000791e9ae00000, 0x0000791f77f0ee40, 8, 0, 0x0000000000000000, Ref{Ptr{OpenCL.cl._cl_event}}) = 0
 8: Ptr{OpenCL.cl._cl_event} @0x0000000033a15c00
libopencl.clSetKernelArg(OpenCL.cl.Kernel(id=0x00000000349537e0), 0x00000000, 32, Ref{OpenCL.CLDeviceArray{Int64, 1, 1}}) = 0
 4: 1-element device array at Core.LLVMPtr{Int64, 1}(0x0000791e9ae00000)
libopencl.clSetKernelArg(OpenCL.cl.Kernel(id=0x00000000349537e0), 0x00000001, 8, Ref{Int64}) = 0
 4: 42
libopencl.clGetDeviceInfo(OpenCL.cl.Device(id=0x0000000032cf3020), 0x1003, 4, Ref{UInt32}, 0x0000000000000000) = 0
 4: 3
libopencl.clEnqueueNDRangeKernel(OpenCL.cl.CmdQueue(id=0x0000000031b9d5d0), OpenCL.cl.Kernel(id=0x00000000349537e0), 0x00000001, 0x0000000000000000, 1-element Vector{UInt64}, 0x0000000000000000, 0x00000000, 0x0000000000000000, Ref{Ptr{OpenCL.cl._cl_event}}) = 0
 9: Ptr{OpenCL.cl._cl_event} @0x0000000037acbbd0
libopencl.clEnqueueSVMMemcpy(OpenCL.cl.CmdQueue(id=0x0000000031b9d5d0), true, 0x0000791f77f14f00, 0x0000791e9ae00000, 8, 0, 0x0000000000000000, Ref{Ptr{OpenCL.cl._cl_event}}) = 0
 8: Ptr{OpenCL.cl._cl_event} @0x0000000037c8df30
Result: 42

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