-
Notifications
You must be signed in to change notification settings - Fork 2
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
WIP: continuing higher-level wrappers #32
Open
JerryChen97
wants to merge
133
commits into
master
Choose a base branch
from
jerry/polish_before_more_wrappers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
133 commits
Select commit
Hold shift + click to select a range
def834a
Fix two problems: wrong path to Dense.jl and lack of 'export magmaInit'
4f6750e
Change the "src/dense/Dense.jl" to "src/dense/dense.jl"
29a72ca
Fix the bug hidden in the svd.jl. Add the test for Cgesvd & Zgesvd
864363a
ADD the codes in JuliaGPU/MAGMA.jl to our current files
9a504f0
Try adding gpu interface but errored
9f09e5f
Correct the setmatrix, setvector and getvector
ba1c33e
Delete the trial of adding GPU interfaces for gesvd. There is no gpu …
dc208ae
Add gesdd, not finished yet
7fac92f
Continue
181c9b4
Edit gesdd
ecff1fd
Fix some bugs
3fbae75
Add 'export gesdd!' to MAGMA.jl
ad03663
Add test for gesdd!
6d52fb5
Add magma_malloc_pinned
7d8a230
Add a trial function for GPU gesdd
d07758f
Merge the judgment of A's type into the original wrapper
f2cea2d
The communication between CPU and GPU can be easily carried through s…
23f5277
Correct the naming convention for types
2e441b5
Delete some unnecessary things
b22ae4e
Polish some trivia
587a7ed
Fix some bugs
db829be
Add trial codes for GPU interface
7d27ce6
Tried some other ways but still bugs
5c15d63
Fixed
1f722a2
Simplify the process of converting in src
3314199
Add the same process of converting for gesvd along with the comments
31faa65
Delete useless codes
d765d30
Delete useless codes
3ced1db
Add GPU interface testing for gesvd
5a190d1
Furtherly polished the codes for testing and added some comments
86c3dda
Add some comments
f235236
Add some comments for gesdd!
00d4528
Merge branch 'master' into jerry/add_magma_malloc
194c43a
Simplify the testing procedure
648eadf
Add gebrd wrapper. Delete unnecessary parts.
d4a01a3
Fix gebrd wrapper and its testing
c758419
Delete something only for testing which actually do nothing
412c0c0
Fix a bug hidden in the testing codes. Trim some unnecessary parts.
8e616f3
Add linearsystemsolver.jl file
8f48cd7
Draft for linear solvers
c4d0cb6
Add a possibly useful build file for OpenBLAS
4ed5fbe
Test the workflow of deps/build.jl
fa1737c
WIP: debugging some problems
b9b54b1
Cleaned some bugs and now the CPU version works. Later comes the GPU …
4c12bb6
Add LinearAlgebra into the dependencies since we are gonna use some f…
eb9a601
Merge branch 'master' into jerry/add_magma_sgels
Roger-luo e2c9d10
WIP: Still have the problem "ReadOnlyMemoryError()" when ccall the gp…
3b7674e
Merge branch 'jerry/add_magma_sgels' of https://github.com/Roger-luo/…
ed2be06
WIP: debugging gels_gpu
02729ed
WIP: IDKY but that bug suddenly disappears when I write the ccall exp…
3d75045
Debugged. Now everything seems fine. Need to clean.
db49d05
Newly create a magmafunc_gpu function to create a gpu subroutine name…
db621ab
Simplify something
0f27099
Cleaned some redundant codes
a52f06b
WIP: testing gesv
cd28b7b
Finished the wrappers for gesv
7f3a1ad
Merge branch 'master' into jerry/add_magma_gesv
2b85e5a
Multidispatch gesvd! .Delete the cmplx-testing.
49aa810
Multidispatch gesdd. Add prefix 'magma_' to gesvd and gesdd
0f980f3
Fix bugs
6a5f677
Multidispatch gels
a78db12
Multipatch gesv
d5df7c1
Merge branch 'master' into jerry/polish_wrappers
3b3f61c
Testing codes for clang
499e683
Cleaned some repeated wrappers
b0c53ee
Merge branch 'master' into jerry/clang_wrappers
280c1f9
Add a simple README for src/clang/
81a98e3
Removed unnecessary file: enums.jl
c04d6c1
Exported magma_init
1aa16ad
Replaced magmaInit with magma_init, in test/dense/svd.jl
74d3873
Replaced in linearsystemsolver.jl
a7be96e
Removed the definition of magmaInit in MAGMA.jl
c0b8fd0
export magma_finalize
c7a7545
Replaced magmaFinalize with magma_finalize
ecc9a8e
Deleted magmaFinalize
0771b5b
Deleted unnecessary comments
9a598b1
Moved some 'using ***' to runtests.jl
b9fa5cc
Moved some 'using' to runtests.jl
b16b257
Deleted unnecessary file: libmagma_common.jl
838d22f
Renamed 'libmagma_common_v2.jl' as 'libmagma_common.jl'
22ab054
Deleted unnecessary comments
08eb7c3
Test the output of @magmafunc(gesvd)
JerryChen97 f732d10
Test passsed
JerryChen97 c8220dc
Edited tests for both gesvd and gesdd
JerryChen97 dd61a57
Edited for gebrd
JerryChen97 eaa0b31
Replaced all the Ptr with PtrOrCuPtr
JerryChen97 3d5dfaa
Deleted some unnecessary codes
JerryChen97 3b7280a
Constructed a type list for magma common usage
JerryChen97 fb6da0f
Changed the meta-prog into a more compact form
JerryChen97 7d2c595
Added the higher-level wrappers for getri with testing
JerryChen97 fcf9015
Cleaned some unnecessary things
JerryChen97 f108f75
Changed into more compact form
JerryChen97 1c58562
Debugging getrs
JerryChen97 570d8fa
Remained some bugs, but they seemed to be of MAGMA
JerryChen97 60784d9
Added the higher-level wrappers for getrf
JerryChen97 d8d5493
Add testing code for getrf individually
JerryChen97 8ddaf8b
Export getrf!
JerryChen97 3c9c84c
Changed the getrs testings into 'broken'
JerryChen97 34bc9c1
Improved the comments
JerryChen97 928f89d
Moved the func name eval to the outer side of for loop
JerryChen97 4321ac9
Fixed the bug of getrs
JerryChen97 aa77819
Merge branch 'master' into jerry/polish_before_more_wrappers
JerryChen97 875c441
Deleted some unnecessary sentences in linearsystemsolver.jl
JerryChen97 a6ec3c2
Deleted some unnecessary code
JerryChen97 974d9bc
Trimed more in the testing codes
JerryChen97 38af544
Add wrappers for getrf_gpu
JerryChen97 307ea66
Deleted two left 'isGPU' and add gerbt wrappers
JerryChen97 27c1e80
Modified the gerbt
JerryChen97 d2affb6
Edited the testing for gesv_rbt
JerryChen97 242586b
Corrected the gesv_rbt wrappers
JerryChen97 65f806e
Add wrappers for geqrsv
JerryChen97 cd1876b
Adding the posv wrappers
JerryChen97 6ded754
Add using require_one_based_indexing
JerryChen97 67f5a72
Add definition for require...
JerryChen97 4195cf0
Added the testing code from LAPACK
JerryChen97 6d584e0
Trimed the complex testing for gesv_rbt for convenience
JerryChen97 18836eb
Finished posv wrappers
JerryChen97 4e6981f
Adding hesv wrappers
JerryChen97 8abf713
Adding tests for hesv
JerryChen97 e7a19a5
Adding the sysv wrappers
JerryChen97 26f16cb
Added the tests for sysv
JerryChen97 573325b
Created factorization.jl
JerryChen97 e747109
Edited
JerryChen97 054d964
Added geqrf wrappers
JerryChen97 cd180a5
Added tests for geqrf
JerryChen97 a918026
Added several other wrappers of factorization
JerryChen97 d267458
Add the file for wrappers of eigenvalues subroutines
JerryChen97 c87163e
Set up the functions' name to wrap
JerryChen97 1982953
Added geev wrapper's src code
JerryChen97 44fe5a8
Added the testing code
JerryChen97 371a919
Fixed
JerryChen97 7283370
Added gehrd and fixed
JerryChen97 0a0c7f9
Deleted some unnecessary parts
JerryChen97 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
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,141 @@ | ||
const function_list_eigenvalues = ("geev", "gehrd", | ||
"heevx", "heevd", "heevdx", "heevr", "hetrd", | ||
"hegvx", "hegvd", "hegvdx", "hegvr") | ||
macro char_to_vec(op) | ||
return op == 'V' ? MagmaVec : MagmaNoVec | ||
end | ||
macro type_to_rtype(type) | ||
return type == Float64 || type == ComplexF64 ? Float64 : Float32 | ||
end | ||
|
||
for type in magmaTypeList_real | ||
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. you don't need to create the symbols, just use type. |
||
# create the symbols for element types | ||
elty = Symbol(type) | ||
relty= Symbol(@type_to_rtype(type)) | ||
# generate the symbol variables for our wrappers | ||
for func_name in function_list_eigenvalues | ||
@eval $(Symbol(func_name)) = (Symbol(magmaTypeDict[$type], $func_name)) | ||
end | ||
|
||
@eval begin | ||
|
||
function magma_geev!(jobvl::AbstractChar, jobvr::AbstractChar, A::AbstractMatrix{$elty}) | ||
magma_init() | ||
chkstride1(A) | ||
n = checksquare(A) | ||
chkfinite(A) # balancing routines don't support NaNs and Infs | ||
lvecs = jobvl == 'V' | ||
rvecs = jobvr == 'V' | ||
VL = similar(A, $elty, (n, lvecs ? n : 0)) | ||
VR = similar(A, $elty, (n, rvecs ? n : 0)) | ||
WR = similar(A, $elty, n) | ||
WI = similar(A, $elty, n) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
lda = max(1, stride(A, 2)) | ||
|
||
jobvl = @char_to_vec(jobvl) | ||
jobvr = @char_to_vec(jobvr) | ||
func = eval(@magmafunc($geev)) | ||
for i = 1:2 # first call returns lwork as work[1] | ||
func(jobvl, jobvr, n, A, lda, WR, WI, VL, n, | ||
VR, n, work, lwork, info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
(WR, WI, VL, VR) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
for type in magmaTypeList_complex | ||
# create the symbols for element types | ||
elty = Symbol(type) | ||
relty= Symbol(@type_to_rtype(type)) | ||
# generate the symbol variables for our wrappers | ||
for func_name in function_list_eigenvalues | ||
@eval $(Symbol(func_name)) = (Symbol(magmaTypeDict[$type], $func_name)) | ||
end | ||
|
||
@eval begin | ||
|
||
function magma_geev!(jobvl::AbstractChar, jobvr::AbstractChar, A::AbstractMatrix{$elty}) | ||
magma_init() | ||
chkstride1(A) | ||
n = checksquare(A) | ||
chkfinite(A) # balancing routines don't support NaNs and Infs | ||
lvecs = jobvl == 'V' | ||
rvecs = jobvr == 'V' | ||
VL = similar(A, $elty, (n, lvecs ? n : 0)) | ||
VR = similar(A, $elty, (n, rvecs ? n : 0)) | ||
W = similar(A, $elty, n) | ||
rwork = similar(A, $relty, 2n) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
lda = max(1, stride(A, 2)) | ||
|
||
jobvl = @char_to_vec(jobvl) | ||
jobvr = @char_to_vec(jobvr) | ||
func = eval(@magmafunc($geev)) | ||
for i = 1:2 # first call returns lwork as work[1] | ||
func(jobvl, jobvr, n, A, lda, W, VL, n, VR, n, | ||
work, lwork, rwork, info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
(W, VL, VR) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
for type in magmaTypeList | ||
# create the symbols for element types | ||
elty = Symbol(type) | ||
relty= Symbol(@type_to_rtype(type)) | ||
# generate the symbol variables for our wrappers | ||
for func_name in function_list_eigenvalues | ||
@eval $(Symbol(func_name)) = (Symbol(magmaTypeDict[$type], $func_name)) | ||
end | ||
|
||
@eval begin | ||
|
||
function magma_gehrd!(ilo::Integer, ihi::Integer, A::AbstractMatrix{$elty}) | ||
magma_init() | ||
chkstride1(A) | ||
n = checksquare(A) | ||
chkfinite(A) # balancing routines don't support NaNs and Infs | ||
tau = similar(A, $elty, max(0,n - 1)) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
func = eval(@magmafunc($gehrd)) | ||
nb = eval(@magmafunc_nb($gehrd))(n) | ||
T = CuArray{$elty}(undef, nb*n) | ||
for i = 1:2 # first call returns lwork as work[1] | ||
func(n, ilo, ihi, A, | ||
max(1, stride(A, 2)), tau, work, lwork, T, | ||
info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
A, tau | ||
end | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# wrappers for MAGMA factorization functions | ||
|
||
const function_list_factorization = ("geqrf", "gerqf", "geqlf", "gelqf") | ||
for type in magmaTypeList | ||
# create the symbols for element types | ||
elty = Symbol(type) | ||
# generate the symbol variables for our wrappers | ||
for func_name in function_list_factorization | ||
@eval $(Symbol(func_name)) = (Symbol(magmaTypeDict[$type], $func_name)) | ||
end | ||
|
||
@eval begin | ||
|
||
function magma_geqrf!(A::Matrix{$elty}) | ||
m, n = size(A) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
lda = max(1, m) | ||
tau = similar(A, min(m, n)) | ||
|
||
func = eval(@magmafunc($geqrf)) | ||
magma_init() | ||
for i = 1:2 # | ||
func(m, n, A, lda, tau, work, lwork, info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
A, tau | ||
end | ||
function magma_geqrf!(A::CuMatrix{$elty}) | ||
magma_init() | ||
m, n = size(A) | ||
nb = (eval(@magmafunc_nb($geqrf)))( m, n ) | ||
info = Ref{Cint}() | ||
lda = max(1, m) | ||
tau = similar(Matrix(A), min(m, n)) | ||
T = similar(A, (2*min( m, n ) + ceil(Int, n/32)*32 )*nb) | ||
|
||
func = eval(@magmafunc_gpu($geqrf)) | ||
func(m, n, A, lda, tau, T, info) | ||
magma_finalize() | ||
A, tau | ||
end | ||
|
||
# ! Strangely, it seems that MAGMA does not provide any API for gerqf | ||
# function magma_gerqf!(A::Matrix{$elty}) | ||
# m, n = size(A) | ||
# work = Vector{$elty}(undef, 1) | ||
# lwork = Cint(-1) | ||
# info = Ref{Cint}() | ||
# lda = max(1, m) | ||
# tau = similar(A, min(m, n)) | ||
# func = (eval(@magmafunc_generic($geqrf, "_error"))) | ||
# magma_init() | ||
# for i = 1:2 # | ||
# func(m, n, A, lda, tau, work, lwork, info) | ||
# if i == 1 | ||
# lwork = ceil(Int, real(work[1])) | ||
# resize!(work, lwork) | ||
# end | ||
# end | ||
# magma_finalize() | ||
# A, tau | ||
# end | ||
# function magma_gerqf!(A::CuMatrix{$elty}) | ||
# #! MAGMA does not provide direct GPU interface for gerqf | ||
# A = Matrix(A) | ||
# magma_gerqf!(A) | ||
# end | ||
|
||
function magma_geqlf!(A::Matrix{$elty}) | ||
m, n = size(A) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
lda = max(1, m) | ||
tau = similar(A, min(m, n)) | ||
|
||
func = eval(@magmafunc($geqlf)) | ||
magma_init() | ||
for i = 1:2 # | ||
func(m, n, A, lda, tau, work, lwork, info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
A, tau | ||
end | ||
function magma_geqlf!(A::CuMatrix{$elty}) | ||
A = Matrix(A) | ||
magma_geqlf!(A) | ||
end | ||
|
||
function magma_gelqf!(A::Matrix{$elty}) | ||
m, n = size(A) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
lda = max(1, m) | ||
tau = similar(A, min(m, n)) | ||
|
||
func = eval(@magmafunc($gelqf)) | ||
magma_init() | ||
for i = 1:2 # | ||
func(m, n, A, lda, tau, work, lwork, info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
A, tau | ||
end | ||
function magma_gelqf!(A::CuMatrix{$elty}) | ||
m, n = size(A) | ||
work = Vector{$elty}(undef, 1) | ||
lwork = Cint(-1) | ||
info = Ref{Cint}() | ||
lda = max(1, m) | ||
tau = similar(Matrix(A), min(m, n)) | ||
|
||
func = eval(@magmafunc_gpu($gelqf)) | ||
magma_init() | ||
for i = 1:2 # | ||
func(m, n, A, lda, tau, work, lwork, info) | ||
if i == 1 | ||
lwork = ceil(Int, real(work[1])) | ||
resize!(work, lwork) | ||
end | ||
end | ||
magma_finalize() | ||
A, tau | ||
end | ||
|
||
function magma_geqrs!(A::CuArray{$elty}, B::CuArray{$elty}) | ||
magma_init() | ||
|
||
m, n = size(A) | ||
nrhs = size(B, 2) | ||
lda = max(1, m) | ||
ldb = max(1, m) | ||
tau = Array{$elty}(undef, n) | ||
|
||
|
||
magma_finalize() | ||
B, info[] | ||
end | ||
|
||
end | ||
|
||
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.
this is sufficient. you don't need to parse strings manually.
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.
Ah cool. There is some improvisation made by me a long time ago for convenience. Thank you for your careful checking and improvement.