-
Notifications
You must be signed in to change notification settings - Fork 14
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
Sd/v05 #25
Merged
Sd/v05 #25
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
35d94fa
update to 0.5
SimonDanisch f26c007
add build
SimonDanisch 03981d8
switch to Base.Test
SimonDanisch db24fea
clean ups
SimonDanisch 1864dc0
correct build script for linux
SimonDanisch 53a52b8
remove deps from git tracking
SimonDanisch cb7621d
fix tests
SimonDanisch 8fd9ca0
remove @static
SimonDanisch 711de6c
better init and teardown
SimonDanisch 29b83a9
add back queue and add gemv
SimonDanisch 7407ceb
better supertype in args and better error
SimonDanisch e165fb8
factcheck isn't used anymore
SimonDanisch e948e27
make tests pass
SimonDanisch c39ed6f
build CLBLAS
SimonDanisch db900e3
default script should just work
SimonDanisch 714d0eb
add gemv tests
SimonDanisch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
*~ | ||
.juliahistory | ||
.juliahistory | ||
deps/deps.jl | ||
deps/downloads | ||
deps/package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
julia 0.5- | ||
julia 0.5 | ||
OpenCL | ||
BinDeps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using BinDeps | ||
@BinDeps.setup | ||
libnames = ["libCLBLAS", "clBLAS", "libclBLAS"] | ||
libCLBLAS = library_dependency("libCLBLAS", aliases = libnames) | ||
archive = "package" | ||
libpath = "package/bin" | ||
baseurl = "https://github.com/clMathLibraries/clBLAS/releases/download/v2.12/clBLAS-2.12.0-" | ||
|
||
# download a pre-compiled binary (built by GLFW) | ||
if is_windows() | ||
if Sys.ARCH == :x86_64 | ||
uri = URI(baseurl * "Windows-x64.zip") | ||
provides( | ||
Binaries, uri, | ||
libCLBLAS, unpacked_dir = archive, | ||
installed_libpath = libpath, os = :Windows | ||
) | ||
else | ||
error("Only 64 bits windows supported with automatic build") | ||
end | ||
end | ||
|
||
if is_linux() | ||
provides(AptGet, "libclblas-dev", libCLBLAS) | ||
if Sys.ARCH == :x86_64 | ||
uri = URI(baseurl * "Linux-x64.tar.gz") | ||
provides( | ||
Binaries, uri, | ||
libCLBLAS, unpacked_dir = archive, | ||
installed_libpath = libpath, os = :Linux | ||
) | ||
end | ||
end | ||
if is_apple() | ||
error(""" | ||
OSX not oficially supported. | ||
Find manual build instructions on: https://github.com/clMathLibraries/clBLAS/wiki/Build | ||
""") | ||
end | ||
|
||
@BinDeps.install Dict("libCLBLAS" => "libCLBLAS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import OpenCL | ||
const cl = OpenCL | ||
using OpenCL: cl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const ARRAY_SIZE = 64 | ||
sum = Array(Float32, 2) | ||
data = Array(Float32, ARRAY_SIZE) | ||
sum = Vector{Float32}(2) | ||
data = Vector{Float32}(ARRAY_SIZE) | ||
for i in 1:ARRAY_SIZE | ||
data[i] = i*1.0 | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,49 @@ | ||
import CLBLAS | ||
import OpenCL | ||
|
||
const clblas = CLBLAS | ||
clblas.setup() | ||
|
||
const cl = OpenCL | ||
|
||
device, ctx, queue = clblas.get_next_compute_context() | ||
|
||
N = unsigned(5) | ||
data = Array(Float32, 5) | ||
data[1] = 1.1 | ||
data[2] = 2.22 | ||
data[3] = 3.333 | ||
data[4] = 4.4444 | ||
data[5] = 5.55555 | ||
|
||
bufX = cl.Buffer(Float32, ctx, (:r, :copy),hostbuf=data) | ||
bufAsum = cl.Buffer(Float32, ctx, :w, length(bufX)) | ||
scratchBuff = cl.Buffer(Float32, ctx, :rw, length(bufX)) | ||
|
||
offx = unsigned(0) | ||
incx = cl.cl_int(1) | ||
ncq = cl.cl_uint(1) | ||
clq = queue.id | ||
newl = cl.cl_uint(0) | ||
|
||
event = cl.UserEvent(ctx, retain=true) | ||
ptrEvent = [event.id] | ||
|
||
clblas.clblasSasum( N, bufAsum.id, 0, bufX.id, 0, incx, scratchBuff.id, | ||
ncq, [clq], newl, C_NULL, ptrEvent); | ||
|
||
cl.api.clWaitForEvents(cl.cl_uint(1), ptrEvent) | ||
|
||
result = Array(Float32, length(1)) | ||
cl.enqueue_read_buffer(queue, bufAsum, result, unsigned(0), nothing, true) | ||
|
||
expected = data[1:end] |> sum | ||
println(result) | ||
println("------------") | ||
println(expected) | ||
|
||
try | ||
@assert(isapprox(norm(expected - result[1]), zero(Float32))) | ||
info("success!") | ||
finally | ||
clblas.teardown() | ||
end | ||
|
||
const clblas = CLBLAS | ||
clblas.setup() | ||
|
||
using OpenCL: cl | ||
|
||
device, ctx, queue = clblas.get_next_compute_context() | ||
|
||
N = Unsigned(5) | ||
data = Vector{Float32}(5) | ||
data[1] = 1.1 | ||
data[2] = 2.22 | ||
data[3] = 3.333 | ||
data[4] = 4.4444 | ||
data[5] = 5.55555 | ||
|
||
bufX = cl.Buffer(Float32, ctx, (:r, :copy),hostbuf=data) | ||
bufAsum = cl.Buffer(Float32, ctx, :w, length(bufX)) | ||
scratchBuff = cl.Buffer(Float32, ctx, :rw, length(bufX)) | ||
|
||
offx = Unsigned(0) | ||
incx = cl.cl_int(1) | ||
ncq = cl.cl_uint(1) | ||
clq = queue.id | ||
newl = cl.cl_uint(0) | ||
|
||
event = cl.UserEvent(ctx, retain=true) | ||
ptrEvent = [event.id] | ||
|
||
clblas.clblasSasum( N, bufAsum.id, 0, bufX.id, 0, incx, scratchBuff.id, | ||
ncq, [clq], newl, C_NULL, ptrEvent); | ||
|
||
cl.api.clWaitForEvents(cl.cl_uint(1), ptrEvent) | ||
|
||
result = Vector{Float32}(length(1)) | ||
cl.enqueue_read_buffer(queue, bufAsum, result, Unsigned(0), nothing, true) | ||
|
||
expected = data[1:end] |> sum | ||
println(result) | ||
println("------------") | ||
println(expected) | ||
|
||
try | ||
@assert(isapprox(norm(expected - result[1]), zero(Float32))) | ||
info("success!") | ||
finally | ||
clblas.teardown() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,60 @@ | ||
import CLBLAS | ||
import OpenCL | ||
|
||
const clblas = CLBLAS | ||
clblas.setup() | ||
|
||
const cl = OpenCL | ||
|
||
device, ctx, queue = clblas.get_next_compute_context() | ||
|
||
N = unsigned(5) | ||
alpha = cl.cl_float(12) | ||
data = Array(Float32, 5) | ||
data[1] = 1.1 | ||
data[2] = 2.22 | ||
data[3] = 3.333 | ||
data[4] = 4.4444 | ||
data[5] = 5.55555 | ||
|
||
dat = Array(Float32, 5) | ||
dat[1] = 6.1 | ||
dat[2] = 7.22 | ||
dat[3] = 8.333 | ||
dat[4] = 9.4444 | ||
dat[5] = 10.55555 | ||
|
||
bufX = cl.Buffer(Float32, ctx, (:rw, :copy),hostbuf=data) | ||
bufY = cl.Buffer(Float32, ctx, (:rw, :copy),hostbuf=dat) | ||
|
||
offx = unsigned(0) | ||
incx = cl.cl_int(1) | ||
incy = cl.cl_int(1) | ||
ncq = cl.cl_uint(1) | ||
clq = queue.id | ||
newl = cl.cl_uint(0) | ||
|
||
event = cl.UserEvent(ctx, retain=true) | ||
ptrEvent = [event.id] | ||
|
||
clblas.clblasSaxpy( N, alpha, bufX.id, 0, incx, bufY.id, 0, incy, | ||
ncq, [clq], newl, C_NULL, ptrEvent); | ||
|
||
cl.api.clWaitForEvents(cl.cl_uint(1), ptrEvent) | ||
|
||
result = Array(Float32, length(bufY)) | ||
cl.enqueue_read_buffer(queue, bufY, result, unsigned(0), nothing, true) | ||
|
||
#Y←αX+Y | ||
expected = alpha * data + dat | ||
println(result) | ||
println("------------") | ||
println(expected) | ||
|
||
try | ||
for i in 1:length(result) | ||
@assert(isapprox(norm(expected[i] - result[i]), zero(Float32), atol=0.00001)) | ||
end | ||
info("success!") | ||
finally | ||
clblas.teardown() | ||
|
||
const clblas = CLBLAS | ||
clblas.setup() | ||
|
||
using OpenCL: cl | ||
|
||
device, ctx, queue = clblas.get_next_compute_context() | ||
|
||
N = unsigned(5) | ||
alpha = cl.cl_float(12) | ||
data = Array(Float32, 5) | ||
data[1] = 1.1 | ||
data[2] = 2.22 | ||
data[3] = 3.333 | ||
data[4] = 4.4444 | ||
data[5] = 5.55555 | ||
|
||
dat = Array(Float32, 5) | ||
dat[1] = 6.1 | ||
dat[2] = 7.22 | ||
dat[3] = 8.333 | ||
dat[4] = 9.4444 | ||
dat[5] = 10.55555 | ||
|
||
bufX = cl.Buffer(Float32, ctx, (:rw, :copy),hostbuf=data) | ||
bufY = cl.Buffer(Float32, ctx, (:rw, :copy),hostbuf=dat) | ||
|
||
offx = unsigned(0) | ||
incx = cl.cl_int(1) | ||
incy = cl.cl_int(1) | ||
ncq = cl.cl_uint(1) | ||
clq = queue.id | ||
newl = cl.cl_uint(0) | ||
|
||
event = cl.UserEvent(ctx, retain=true) | ||
ptrEvent = [event.id] | ||
|
||
clblas.clblasSaxpy( N, alpha, bufX.id, 0, incx, bufY.id, 0, incy, | ||
ncq, [clq], newl, C_NULL, ptrEvent); | ||
|
||
cl.api.clWaitForEvents(cl.cl_uint(1), ptrEvent) | ||
|
||
result = Array(Float32, length(bufY)) | ||
cl.enqueue_read_buffer(queue, bufY, result, unsigned(0), nothing, true) | ||
|
||
#Y←αX+Y | ||
expected = alpha * data + dat | ||
println(result) | ||
println("------------") | ||
println(expected) | ||
|
||
try | ||
for i in 1:length(result) | ||
@assert(isapprox(norm(expected[i] - result[i]), zero(Float32), atol=0.00001)) | ||
end | ||
info("success!") | ||
finally | ||
clblas.teardown() | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean
@static if is_linux()
as it's used above? Although I'm not sure if@static
makes any difference in this case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it shouldn't ;)