Skip to content
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

Use Ref{T} type for BLAS calls #11402

Merged
merged 1 commit into from
May 29, 2015
Merged

Use Ref{T} type for BLAS calls #11402

merged 1 commit into from
May 29, 2015

Conversation

simonbyrne
Copy link
Contributor

I was trying to figure out how the new Ref object works, so I translated the ccalls in blas.jl to the new style.

Is this the correct usage? In particular, for getting return values by reference:

julia/base/linalg/blas.jl

Lines 124 to 128 in 940c790

result = Ref{$elty}()
ccall(($(blasfunc(fname)), libblas), Void,
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ref{$elty}),
n, DX, incx, DY, incy, result)
result[]

cc: @vtjnash, @jiahao, @andreasnoack

@andreasnoack
Copy link
Member

I'm also interested in the answer to your question.

@StefanKarpinski
Copy link
Member

@vtjnash

ccall(($(blasfunc(fname)), libblas), Void,
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ref{$elty}),
n, DX, incx, DY, incy, result)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised that not all of the existing arguments were Ptr. @viralshah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, @ViralBShah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific symbol is from the CBLAS API to avoid returning a complex value. In the C API, the scalar inputs are not pointers.

@vtjnash
Copy link
Member

vtjnash commented May 22, 2015

Lgtm

@andreasnoack
Copy link
Member

@simonbyrne Could you rebase and merge this?

@simonbyrne simonbyrne force-pushed the sb/blas-ref branch 2 times, most recently from 0aef12a to 79adca4 Compare May 28, 2015 16:33
jakebolewski added a commit that referenced this pull request May 29, 2015
Use Ref{T} type for BLAS calls
@jakebolewski jakebolewski merged commit 0cde1c0 into master May 29, 2015
@jakebolewski jakebolewski deleted the sb/blas-ref branch May 29, 2015 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants