Skip to content

Commit

Permalink
Merge pull request #172 from sambitdash/master
Browse files Browse the repository at this point in the history
Additional fixes for Julia 1.0 support as well as failures on OpenCL 1.1
  • Loading branch information
SimonDanisch authored Nov 15, 2018
2 parents fa0268f + 3e6494e commit 6d9a236
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ end
const io_lock = ReentrantLock()
function log_error(message...)
@async begin
lock(STDERR)
lock(stderr)
lock(io_lock)
print(STDERR, string(message..., "\n"))
print(stderr, string(message..., "\n"))
unlock(io_lock)
unlock(STDERR)
unlock(stderr)
end
end

Expand Down
8 changes: 5 additions & 3 deletions src/kernel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,13 @@ function info(k::Kernel, kinfo::Symbol)
return Program(ret[], retain=true)
end

# Only supported for version 1.2 and above
attributes(k::Kernel) = begin
size = Ref{Csize_t}()
api.clGetKernelInfo(k.id, CL_KERNEL_ATTRIBUTES,
0, C_NULL, size)
if size[] <= 1
rcode = api.clGetKernelInfo(k.id, CL_KERNEL_ATTRIBUTES,
0, C_NULL, size)
# Version 1.1 mostly MESA drivers will pass through the below condition
if rcode == CL_INVALID_VALUE || size[] <= 1
return ""
end
result = Vector{CL_char}(undef, size[])
Expand Down
27 changes: 0 additions & 27 deletions src/platform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,6 @@ function info(p::Platform, pinfo::CL_platform_info)
return CLString(result)
end


let info_map = Dict{Symbol, CL_platform_info}(
:profile => CL_PLATFORM_PROFILE,
:version => CL_PLATFORM_VERSION,
:name => CL_PLATFORM_NAME,
:vendor => CL_PLATFORM_VENDOR,
:extensions => CL_PLATFORM_EXTENSIONS
)
global info
function info(p::Platform, pinfo::Symbol)
try
cl_info = info_map[pinfo]
if pinfo == :extensions
split(info(p, cl_info))
else
info(p, cl_info)
end
catch err
if isa(err, KeyError)
throw(ArgumentError("OpenCL.Platform has no info for: $pinfo"))
else
throw(err)
end
end
end
end

function devices(p::Platform, dtype::CL_device_type)
try
ndevices = Ref{CL_uint}()
Expand Down
8 changes: 4 additions & 4 deletions src/program.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ function build!(p::Program; options = "", raise = true)
end
for (dev, status) in cl.info(p, :build_status)
if status == cl.CL_BUILD_ERROR
println(STDERR, "Couldn't compile kernel: ")
println(stderr, "Couldn't compile kernel: ")
source = info(p, :source)
print_with_linenumbers(source, " ", STDERR)
println(STDERR, "With following build error:")
println(STDERR, cl.info(p, :build_log)[dev])
print_with_linenumbers(source, " ", stderr)
println(stderr, "With following build error:")
println(stderr, cl.info(p, :build_log)[dev])
raise && @check err # throw the build error when raise!
end
end
Expand Down

0 comments on commit 6d9a236

Please sign in to comment.