forked from JuliaGPU/CLBlast.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
3 deletions.
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ include("sbmv.jl") | |
include("trmv.jl") | ||
include("trsv.jl") | ||
include("ger.jl") | ||
include("her.jl") |
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
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,62 @@ | ||
|
||
for (func, elty, relty) in [(:CLBlastCher, Complex64, Float32), (:CLBlastZher, Complex128, Float64)] | ||
|
||
@eval function $func(layout::CLBlastLayout, triangle::CLBlastTriangle, | ||
n::Integer, | ||
alpha::$relty, | ||
x_buffer::cl.CL_mem, x_offset::Integer, x_inc::Integer, | ||
a_buffer::cl.CL_mem, a_offset::Integer, a_ld::Integer, | ||
queue::cl.CmdQueue, event::cl.Event) | ||
err = ccall( | ||
($(string(func)), libCLBlast), | ||
cl.CL_int, | ||
(Cint, Cint, Csize_t, $relty, Ptr{Void}, Csize_t, Csize_t, Ptr{Void}, Csize_t, Csize_t, | ||
Ptr{Void}, Ptr{Void}), | ||
Cint(layout), Cint(triangle), n, alpha, x_buffer, x_offset, x_inc, | ||
a_buffer, a_offset, a_ld, Ref(queue), Ref(event) | ||
) | ||
if err != cl.CL_SUCCESS | ||
println(STDERR, "Calling function $(string($func)) failed!") | ||
throw(CLBlastError(err)) | ||
end | ||
return err | ||
end | ||
|
||
@eval function her!(uplo::Char, α::Number, x::cl.CLArray{$elty}, | ||
A::cl.CLArray{$elty,2}; | ||
queue::cl.CmdQueue=cl.queue(A)) | ||
# check and convert arguments | ||
m, n = size(A) | ||
if m != n | ||
throw(DimensionMismatch("`A` has dimensions $(size(A)) but must be square.")) | ||
end | ||
if length(x) != n | ||
throw(DimensionMismatch("`A` has dimensions $(size(A)) and `x` has length $(length(x)).")) | ||
end | ||
if uplo == 'U' | ||
triangle = CLBlastTriangleUpper | ||
elseif uplo == 'L' | ||
triangle = CLBlastTriangleLower | ||
else | ||
throw(ArgumentError("Upper/lower marker `uplo` is $(uplo) but only 'U' and 'L' are allowed.")) | ||
end | ||
alpha = convert($relty, α) | ||
layout = CLBlastLayoutColMajor | ||
|
||
# output event | ||
event = cl.Event(C_NULL) | ||
|
||
$func(layout, triangle, | ||
n, | ||
alpha, | ||
pointer(x), 0, 1, | ||
pointer(A), 0, size(A,1), | ||
queue, event) | ||
|
||
# wait for kernel | ||
cl.wait(event) | ||
|
||
nothing | ||
end | ||
|
||
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