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

add Grid function #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uuid = "902c3f28-d1ec-5e7e-8399-a24c3845ee38"
version = "0.6.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
DistributedArrays = "aaf54ef3-cdf8-58ed-94cc-d582ad619b94"
Elemental_jll = "c2e960f2-a21d-557e-aa36-859d46eed7e8"
Expand Down
1 change: 0 additions & 1 deletion src/Elemental.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ end
function __init__()
# ccall(:jl_, Cvoid, (Any,), "starting up!")
Init()
DefaultGrid[] = Grid()
atexit() do
# ccall(:jl_, Cvoid, (Any,), "closing down!")
Initialized() && Finalize()
Expand Down
2 changes: 1 addition & 1 deletion src/core/distmatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ for (elty, ext) in ((:ElInt, :i),
return nothing
end

function DistMatrix(::Type{$elty}, colDist::Dist = MC, rowDist::Dist = MR, grid::Grid = DefaultGrid[])
function DistMatrix(::Type{$elty}, colDist::Dist = MC, rowDist::Dist = MR, grid::Grid = DefaultGrid())
obj = Ref{Ptr{Cvoid}}(C_NULL)
ElError(ccall(($(string("ElDistMatrixCreateSpecific_", ext)), libEl), Cuint,
(Cint, Cint, Ptr{Cvoid}, Ref{Ptr{Cvoid}}),
Expand Down
33 changes: 31 additions & 2 deletions src/core/grid.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
using CEnum

@cenum ElGridOrderType::UInt32 begin
EL_ROW_MAJOR = 0
EL_COLUMN_MAJOR = 1
end

mutable struct Grid
obj::Ptr{Cvoid}
end
Expand All @@ -11,11 +18,33 @@ end

# Returns the default Grid. The default grid is finalized when Elemental is finalized
# so we shouldn't register a `destroy` as finalizer.
function Grid()
function DefaultGrid()
obj = Ref{Ptr{Cvoid}}(C_NULL)
ElError(ccall(("ElDefaultGrid", libEl), Cuint,
(Ref{Ptr{Cvoid}},), obj))
return Grid(obj[])
end

const DefaultGrid = Ref{Grid}()
# Returns the trivial Grid. The default grid is finalized when Elemental is finalized
# so we shouldn't register a `destroy` as finalizer.
function TrivialGrid()
obj = Ref{Ptr{Cvoid}}(C_NULL)
ElError(ccall(("ElTrivialGrid", libEl), Cuint,
(Ref{Ptr{Cvoid}},), obj))
return Grid(obj[])
end

function row(G::Grid)
row = Ref{Cint}()
ElError(ccall(("ElGridRow", libEl), Cuint,
(Ptr{Cvoid}, Ptr{Cint}), G.obj, row))
return row[]
end

function column(G::Grid)
col = Ref{Cint}()
ElError(ccall(("ElGridCol", libEl), Cuint,
(Ptr{Cvoid}, Ptr{Cint}), G.obj, col))
return col[]
end

2 changes: 1 addition & 1 deletion src/lapack_like/factor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function destroy(P::DistPermutation)
return nothing
end

function DistPermutation(grid::Grid = DefaultGrid[])
function DistPermutation(grid::Grid = DefaultGrid())
obj = Ref{Ptr{Cvoid}}(0)
ElError(ccall(("ElDistPermutationCreate", libEl), Cuint,
(Ref{Ptr{Cvoid}}, Ptr{Cvoid}),
Expand Down