Skip to content

Commit fa0268f

Browse files
authored
Merge pull request #169 from JuliaGPU/sd-1.0
Sd 1.0
2 parents c535f37 + 6f26d02 commit fa0268f

36 files changed

+411
-402
lines changed

.travis.yml

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
language: julia
22
sudo: false
3-
43
os:
54
#- linux
65
- osx
7-
86
julia:
9-
- 0.6
7+
- 1.0
108
- nightly
119
matrix:
1210
allow_failures:
1311
- julia: nightly
14-
1512
notifications:
1613
email: false
17-
1814
# before_install:
1915
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
2016
# - if [ $TRAVIS_OS_NAME = "linux" ]; then
@@ -29,19 +25,19 @@ notifications:
2925
# chmod +x ${AMDAPPSDK}/bin/x86_64/clinfo;
3026
# ${AMDAPPSDK}/bin/x86_64/clinfo;
3127
# fi;
32-
script:
33-
- julia -e 'Pkg.init(); Pkg.clone(pwd())'
34-
- julia -e 'using OpenCL'
28+
#script:
29+
#- julia -e 'Pkg.init(); Pkg.clone(pwd())'
30+
#- julia -e 'using OpenCL'
3531

36-
- julia --color=yes --depwarn=error -e "Pkg.test(\"OpenCL\")"
32+
#- julia --color=yes --depwarn=error -e "Pkg.test(\"OpenCL\")"
3733

38-
- julia examples/demo.jl
39-
- julia examples/performance.jl
40-
- julia examples/hands_on_opencl/ex04/vadd_chain.jl
41-
- julia examples/hands_on_opencl/ex05/vadd_abc.jl
42-
- julia examples/hands_on_opencl/ex06/matmul.jl
43-
- julia examples/hands_on_opencl/ex07/matmul.jl
44-
- julia examples/hands_on_opencl/ex08/matmul.jl
34+
#- julia examples/demo.jl
35+
#- julia examples/performance.jl
36+
#- julia examples/hands_on_opencl/ex04/vadd_chain.jl
37+
#- julia examples/hands_on_opencl/ex05/vadd_abc.jl
38+
#- julia examples/hands_on_opencl/ex06/matmul.jl
39+
#- julia examples/hands_on_opencl/ex07/matmul.jl
40+
#- julia examples/hands_on_opencl/ex08/matmul.jl
4541

4642
# - if [ $TRAVIS_OS_NAME = "linux" ]; then
4743
# julia examples/hands_on_opencl/ex09/pi_ocl.jl;
@@ -55,6 +51,6 @@ script:
5551
# - if [ $TRAVIS_OS_NAME = "linux" ]; then
5652
# julia examples/hands_on_opencl/exA/pi_vocl.jl 8;
5753
# fi;
58-
5954
after_success:
60-
- julia -e 'Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; fi
55+
- julia -e 'using Pkg; Pkg.add("Coverage")'
56+
- julia -e 'using Coverage; Coveralls.submit(process_folder())'

Project.toml

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name = "OpenCL"
22
uuid = "08131aa3-fb12-5dee-8b74-c09406e224a2"
33

4+
[deps]
5+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
6+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
8+
49
[extras]
510
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
611

REQUIRE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
julia 0.6
1+
julia 1.0

examples/hands_on_opencl/ex07/matmul.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ prg = cl.Program(ctx, source=kernel_source) |> cl.build!
148148
mmul = cl.Kernel(prg, "mmul")
149149
wk_size = cl.info(first(cl.devices(ctx)), :max_work_group_size)
150150
if Ndim * (ORDER ÷ 16) >= wk_size
151-
warn("Specified work_size is bigger than $wk_size")
151+
@warn("Specified work_size is bigger than $wk_size")
152152
else
153153

154154
info("=== OpenCL, matrix mult, C row, A row in priv mem, order $Ndim ====")

examples/hands_on_opencl/ex08/matmul.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ prg = cl.Program(ctx, source=kernel_source) |> cl.build!
147147
mmul = cl.Kernel(prg, "mmul")
148148
wk_size = cl.info(first(cl.devices(ctx)), :max_work_group_size)
149149
if Ndim * (ORDER ÷ 16) >= wk_size
150-
warn("Specified work_size is bigger than $wk_size")
150+
@warn("Specified work_size is bigger than $wk_size")
151151
else
152152

153153
info("=== OpenCL, matrix mult, C row, priv A, B, cols loc, order $Ndim ====")
@@ -176,7 +176,7 @@ prg = cl.Program(ctx, source=kernel_source) |> cl.build!
176176
mmul = cl.Kernel(prg, "mmul")
177177
wk_size = cl.info(first(cl.devices(ctx)), :max_work_group_size)
178178
if Ndim * (ORDER ÷ 16) >= wk_size
179-
warn("Specified work_size is bigger than $wk_size")
179+
@warn("Specified work_size is bigger than $wk_size")
180180
else
181181

182182
info("=== OpenCL, matrix mult, A and B in block form in local memory, order $Ndim ====")

examples/hands_on_opencl/exA/pi_vocl.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ elseif vector_size == 8
3838
ITERS = 32768 # (262144/8)
3939
WGS = 64
4040
else
41-
warn("Invalid vector size")
41+
@warn("Invalid vector size")
4242
exit(1)
4343
end
4444

examples/performance.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function cl_performance(ndatapts::Integer, nworkers::Integer)
4444
for platform in cl.platforms()
4545

4646
if platform[:name] == "Portable Computing Language"
47-
warn("Portable Computing Language platform not yet supported")
47+
@warn("Portable Computing Language platform not yet supported")
4848
continue
4949
end
5050

@@ -65,14 +65,14 @@ function cl_performance(ndatapts::Integer, nworkers::Integer)
6565
@printf("Device max work item size: %s\n", device[:max_work_item_size])
6666

6767
if device[:max_mem_alloc_size] < sizeof(Float32) * ndatapts
68-
warn("Requested buffer size exceeds device max alloc size!")
69-
warn("Skipping device $(device[:name])...")
68+
@warn("Requested buffer size exceeds device max alloc size!")
69+
@warn("Skipping device $(device[:name])...")
7070
continue
7171
end
7272

7373
if device[:max_work_group_size] < nworkers
74-
warn("Number of workers exceeds the device's max work group size!")
75-
warn("Skipping device $(device[:name])...")
74+
@warn("Number of workers exceeds the device's max work group size!")
75+
@warn("Skipping device $(device[:name])...")
7676
continue
7777
end
7878

src/OpenCL.jl

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
__precompile__(true)
21
module OpenCL
32

43
export cl

src/api.jl

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ module api
22

33
include("types.jl")
44

5-
const paths = is_apple() ? String["/System/Library/Frameworks/OpenCL.framework"] : String[]
5+
const paths = Sys.isapple() ? String["/System/Library/Frameworks/OpenCL.framework"] : String[]
6+
7+
import Libdl
68

79
const libopencl = Libdl.find_library(["libOpenCL", "OpenCL"], paths)
810
@assert libopencl != ""
911

1012
function _ocl_func(func, ret_type, arg_types)
11-
local args_in = Symbol[Symbol("arg$i::$T")
13+
local args_in = Symbol[Symbol("arg$i")
1214
for (i, T) in enumerate(arg_types.args)]
15+
1316
esc(quote
1417
function $func($(args_in...))
1518
ccall(($(string(func)), libopencl),
@@ -24,17 +27,15 @@ macro ocl_func(func, ret_type, arg_types)
2427
_ocl_func(func, ret_type, arg_types)
2528
end
2629

27-
const CL_callback = Ptr{Void}
30+
const CL_callback = Ptr{Nothing}
2831

2932
abstract type CL_user_data_tag end
3033
const CL_user_data = Ptr{CL_user_data_tag}
3134

3235
Base.cconvert(::Type{Ptr{CL_user_data_tag}}, obj::T) where {T} = Ref{T}(obj)
33-
Base.unsafe_convert(::Type{Ptr{CL_user_data_tag}}, ref::Ref{T}) where {T} =
34-
Ptr{CL_user_data_tag}(isbits(T) ? pointer_from_objref(ref) : pointer_from_objref(ref[]))
3536

36-
Base.cconvert(::Type{Ptr{CL_user_data_tag}}, ptr::Ptr) = ptr
37-
Base.unsafe_convert(::Type{Ptr{CL_user_data_tag}}, ptr::Ptr) = Ptr{CL_user_data_tag}(ptr)
37+
Base.unsafe_convert(P::Type{Ptr{CL_user_data_tag}}, ptr::Ref) = P(Base.unsafe_convert(Ptr{Cvoid}, ptr))
38+
Base.unsafe_convert(P::Type{Ptr{CL_user_data_tag}}, ptr::Ptr) = P(Base.unsafe_convert(Ptr{Cvoid}, ptr))
3839

3940
include("api/opencl_1.0.0.jl")
4041
include("api/opencl_1.1.0.jl")

src/api/opencl_1.0.0.jl

+27-27
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
(CL_uint, Ptr{CL_platform_id}, Ptr{CL_uint}))
44

55
@ocl_func(clGetPlatformInfo,
6-
CL_int, (CL_platform_id, CL_platform_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
6+
CL_int, (CL_platform_id, CL_platform_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
77

88
#=== device apis ===#
99
@ocl_func(clGetDeviceIDs, CL_int,
1010
(CL_platform_id, CL_device_type, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint}))
1111

1212
@ocl_func(clGetDeviceInfo, CL_int,
13-
(CL_device_id, CL_device_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
13+
(CL_device_id, CL_device_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
1414

1515
#=== context apis ===#
1616
#TODO: pass user data as Any type
1717
@ocl_func(clCreateContext, CL_context,
18-
(Ptr{CL_context_properties}, CL_uint, Ptr{CL_device_id}, CL_callback, CL_user_data, Ptr{CL_int}))
18+
(Ptr{CL_context_properties}, CL_uint, Ptr{CL_device_id}, CL_callback, CL_callback, Ptr{CL_int}))
1919

2020
@ocl_func(clCreateContextFromType, CL_context,
21-
(Ptr{CL_context_properties}, CL_device_type, CL_callback, CL_user_data, Ptr{CL_int}))
21+
(Ptr{CL_context_properties}, CL_device_type, CL_callback, CL_callback, Ptr{CL_int}))
2222

2323
@ocl_func(clRetainContext, CL_int, (CL_context,))
2424

2525
@ocl_func(clReleaseContext, CL_int, (CL_context,))
2626

2727
@ocl_func(clGetContextInfo, CL_int,
28-
(CL_context, CL_context_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
28+
(CL_context, CL_context_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
2929

3030
#=== command queue apis ===#
3131
@ocl_func(clCreateCommandQueue, CL_command_queue,
@@ -36,11 +36,11 @@
3636
@ocl_func(clReleaseCommandQueue, CL_int, (CL_command_queue,))
3737

3838
@ocl_func(clGetCommandQueueInfo, CL_int,
39-
(CL_command_queue, CL_command_queue_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
39+
(CL_command_queue, CL_command_queue_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
4040

4141
#=== memory object apis ===#
4242
@ocl_func(clCreateBuffer, CL_mem,
43-
(CL_context, CL_mem_flags, Csize_t, Ptr{Void}, Ptr{CL_int}))
43+
(CL_context, CL_mem_flags, Csize_t, Ptr{Nothing}, Ptr{CL_int}))
4444

4545
@ocl_func(clRetainMemObject, CL_int, (CL_mem,))
4646

@@ -50,10 +50,10 @@
5050
(CL_context, CL_mem_flags, CL_mem_object_type, CL_uint, Ptr{CL_image_format}, Ptr{CL_uint}))
5151

5252
@ocl_func(clGetMemObjectInfo, CL_mem,
53-
(CL_mem, CL_mem_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
53+
(CL_mem, CL_mem_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
5454

5555
@ocl_func(clGetImageInfo, CL_mem,
56-
(CL_mem, CL_image_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
56+
(CL_mem, CL_image_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
5757

5858
#=== sampler apis ===#
5959
@ocl_func(clCreateSampler, CL_sampler,
@@ -64,7 +64,7 @@
6464
@ocl_func(clReleaseSampler, CL_int, (CL_sampler,))
6565

6666
@ocl_func(clGetSamplerInfo, CL_int,
67-
(CL_sampler, CL_sampler_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
67+
(CL_sampler, CL_sampler_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
6868

6969
#=== program object apis ===#
7070
@ocl_func(clCreateProgramWithSource, CL_program,
@@ -79,10 +79,10 @@
7979
@ocl_func(clReleaseProgram, CL_int, (CL_program,))
8080

8181
@ocl_func(clBuildProgram, CL_int,
82-
(CL_program, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_callback, Ptr{Void}))
82+
(CL_program, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_callback, Ptr{Nothing}))
8383

8484
@ocl_func(clGetProgramBuildInfo, CL_int,
85-
(CL_program, CL_device_id, CL_program_build_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
85+
(CL_program, CL_device_id, CL_program_build_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
8686

8787
#=== kernel object apis ===#
8888
@ocl_func(clCreateKernel, CL_kernel,
@@ -96,28 +96,28 @@
9696
@ocl_func(clReleaseKernel, CL_int, (CL_kernel,))
9797

9898
@ocl_func(clSetKernelArg, CL_int,
99-
(CL_kernel, CL_uint, Csize_t, Ptr{Void}))
99+
(CL_kernel, CL_uint, Csize_t, Ptr{Nothing}))
100100

101101
@ocl_func(clGetKernelInfo, CL_int,
102-
(CL_kernel, CL_kernel_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
102+
(CL_kernel, CL_kernel_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
103103

104104
@ocl_func(clGetKernelWorkGroupInfo, CL_int,
105-
(CL_kernel, CL_device_id, CL_kernel_work_group_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
105+
(CL_kernel, CL_device_id, CL_kernel_work_group_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
106106

107107
#=== event object apis ===#
108108
@ocl_func(clWaitForEvents, CL_int,
109109
(CL_uint, Ptr{CL_event_info}))
110110

111111
@ocl_func(clGetEventInfo, CL_int,
112-
(CL_event, CL_event_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
112+
(CL_event, CL_event_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
113113

114114
@ocl_func(clRetainEvent, CL_int, (CL_event,))
115115

116116
@ocl_func(clReleaseEvent, CL_int, (CL_event,))
117117

118118
#=== profiling apis ===#
119119
@ocl_func(clGetEventProfilingInfo, CL_int,
120-
(CL_event, CL_profiling_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
120+
(CL_event, CL_profiling_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))
121121

122122
#=== flush and finish apis ===#
123123
@ocl_func(clFlush, CL_int, (CL_command_queue,))
@@ -126,12 +126,12 @@
126126

127127
#=== enqueued commands apis ===#
128128
@ocl_func(clEnqueueReadBuffer, CL_int,
129-
(CL_command_queue, CL_mem, CL_bool, Csize_t, Csize_t, Ptr{Void},
129+
(CL_command_queue, CL_mem, CL_bool, Csize_t, Csize_t, Ptr{Nothing},
130130
CL_uint, Ptr{CL_event}, Ptr{CL_event}))
131131

132132
@ocl_func(clEnqueueWriteBuffer, CL_int,
133133
(CL_command_queue, CL_mem, CL_bool,
134-
Csize_t, Csize_t, Ptr{Void}, CL_uint,
134+
Csize_t, Csize_t, Ptr{Nothing}, CL_uint,
135135
Ptr{CL_event}, Ptr{CL_event}))
136136

137137
@ocl_func(clEnqueueCopyBuffer, CL_int,
@@ -141,11 +141,11 @@
141141
@ocl_func(clEnqueueReadImage, CL_int,
142142
(CL_command_queue, CL_mem, CL_bool,
143143
Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t,
144-
Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
144+
Ptr{Nothing}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
145145

146146
@ocl_func(clEnqueueWriteImage, CL_int,
147147
(CL_command_queue, CL_mem, CL_bool, Ptr{Csize_t}, Ptr{Csize_t},
148-
Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
148+
Csize_t, Csize_t, Ptr{Nothing}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
149149

150150
@ocl_func(clEnqueueCopyImage, CL_int,
151151
(CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t},
@@ -159,17 +159,17 @@
159159
(CL_command_queue, CL_mem, CL_mem, Csize_t, Ptr{Csize_t}, Ptr{Csize_t},
160160
CL_uint, Ptr{CL_event}, Ptr{CL_event}))
161161

162-
@ocl_func(clEnqueueMapBuffer, Ptr{Void},
162+
@ocl_func(clEnqueueMapBuffer, Ptr{Nothing},
163163
(CL_command_queue, CL_mem, CL_bool, CL_map_flags, Csize_t, Csize_t,
164164
CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int}))
165165

166-
@ocl_func(clEnqueueMapImage, Ptr{Void},
166+
@ocl_func(clEnqueueMapImage, Ptr{Nothing},
167167
(CL_command_queue, CL_mem, CL_bool, CL_map_flags,
168168
Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t},
169169
CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int}))
170170

171171
@ocl_func(clEnqueueUnmapMemObject, CL_int,
172-
(CL_command_queue, CL_mem, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
172+
(CL_command_queue, CL_mem, Ptr{Nothing}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
173173

174174
@ocl_func(clEnqueueNDRangeKernel, CL_int,
175175
(CL_command_queue, CL_kernel, CL_uint,
@@ -180,8 +180,8 @@
180180
(CL_command_queue, CL_kernel, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
181181

182182
@ocl_func(clEnqueueNativeKernel, CL_int,
183-
(CL_command_queue, Ptr{Void}, Csize_t, CL_uint,
184-
Ptr{CL_mem}, Ptr{Ptr{Void}}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
183+
(CL_command_queue, Ptr{Nothing}, Csize_t, CL_uint,
184+
Ptr{CL_mem}, Ptr{Ptr{Nothing}}, CL_uint, Ptr{CL_event}, Ptr{CL_event}))
185185

186186
#== opengl interop functions ==#
187187

@@ -207,4 +207,4 @@
207207
(CL_mem, Ptr{CL_GL_object_type}, Ptr{GL_uint}))
208208

209209
@ocl_func(clGetGLTextureInfo, CL_int,
210-
(CL_mem, CL_GL_texture_info, Csize_t, Ptr{Void}, Ptr{Csize_t}))
210+
(CL_mem, CL_GL_texture_info, Csize_t, Ptr{Nothing}, Ptr{Csize_t}))

0 commit comments

Comments
 (0)