Skip to content

Commit 6d9a236

Browse files
authored
Merge pull request #172 from sambitdash/master
Additional fixes for Julia 1.0 support as well as failures on OpenCL 1.1
2 parents fa0268f + 3e6494e commit 6d9a236

File tree

4 files changed

+12
-37
lines changed

4 files changed

+12
-37
lines changed

src/context.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ end
9191
const io_lock = ReentrantLock()
9292
function log_error(message...)
9393
@async begin
94-
lock(STDERR)
94+
lock(stderr)
9595
lock(io_lock)
96-
print(STDERR, string(message..., "\n"))
96+
print(stderr, string(message..., "\n"))
9797
unlock(io_lock)
98-
unlock(STDERR)
98+
unlock(stderr)
9999
end
100100
end
101101

src/kernel.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,13 @@ function info(k::Kernel, kinfo::Symbol)
406406
return Program(ret[], retain=true)
407407
end
408408

409+
# Only supported for version 1.2 and above
409410
attributes(k::Kernel) = begin
410411
size = Ref{Csize_t}()
411-
api.clGetKernelInfo(k.id, CL_KERNEL_ATTRIBUTES,
412-
0, C_NULL, size)
413-
if size[] <= 1
412+
rcode = api.clGetKernelInfo(k.id, CL_KERNEL_ATTRIBUTES,
413+
0, C_NULL, size)
414+
# Version 1.1 mostly MESA drivers will pass through the below condition
415+
if rcode == CL_INVALID_VALUE || size[] <= 1
414416
return ""
415417
end
416418
result = Vector{CL_char}(undef, size[])

src/platform.jl

-27
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,6 @@ function info(p::Platform, pinfo::CL_platform_info)
6060
return CLString(result)
6161
end
6262

63-
64-
let info_map = Dict{Symbol, CL_platform_info}(
65-
:profile => CL_PLATFORM_PROFILE,
66-
:version => CL_PLATFORM_VERSION,
67-
:name => CL_PLATFORM_NAME,
68-
:vendor => CL_PLATFORM_VENDOR,
69-
:extensions => CL_PLATFORM_EXTENSIONS
70-
)
71-
global info
72-
function info(p::Platform, pinfo::Symbol)
73-
try
74-
cl_info = info_map[pinfo]
75-
if pinfo == :extensions
76-
split(info(p, cl_info))
77-
else
78-
info(p, cl_info)
79-
end
80-
catch err
81-
if isa(err, KeyError)
82-
throw(ArgumentError("OpenCL.Platform has no info for: $pinfo"))
83-
else
84-
throw(err)
85-
end
86-
end
87-
end
88-
end
89-
9063
function devices(p::Platform, dtype::CL_device_type)
9164
try
9265
ndevices = Ref{CL_uint}()

src/program.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ function build!(p::Program; options = "", raise = true)
9595
end
9696
for (dev, status) in cl.info(p, :build_status)
9797
if status == cl.CL_BUILD_ERROR
98-
println(STDERR, "Couldn't compile kernel: ")
98+
println(stderr, "Couldn't compile kernel: ")
9999
source = info(p, :source)
100-
print_with_linenumbers(source, " ", STDERR)
101-
println(STDERR, "With following build error:")
102-
println(STDERR, cl.info(p, :build_log)[dev])
100+
print_with_linenumbers(source, " ", stderr)
101+
println(stderr, "With following build error:")
102+
println(stderr, cl.info(p, :build_log)[dev])
103103
raise && @check err # throw the build error when raise!
104104
end
105105
end

0 commit comments

Comments
 (0)