Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fsmith001 committed Jul 27, 2022
1 parent 0e668ee commit 31b4c9c
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/BlockMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function BlockMap(numGlobalElements::Integer, myGlobalElements::AbstractArray{GI
end

"""
BlockMap(numGlobalElements, numMyElements, myGlobalElements, isDistributedGlobal, minAllGID, maxAllGID, comm)
BlockMap(numGlobalElements, numMyElements, myGlobalElements, isDistributedGlobal, userminAllGID, usermaxAllGID, comm)
Constructor for user-defined arbitrary distribution of elements with all information on globals provided by the user
"""
Expand Down
3 changes: 2 additions & 1 deletion src/BlockMapData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mutable struct BlockMapData{GID <: Integer, PID <:Integer, LID <: Integer}
lidHash::Dict{GID, LID}
end


function BlockMapData(numGlobalElements::GID, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
BlockMapData(
comm,
Expand All @@ -60,4 +61,4 @@ function BlockMapData(numGlobalElements::GID, comm::Comm{GID, PID, LID}) where G
GID(0),
Dict{GID, LID}()
)
end
end
45 changes: 35 additions & 10 deletions src/CSRGraphConstructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Allocation profile for matrix/graph entries
"""
@enum ProfileType STATIC_PROFILE DYNAMIC_PROFILE

#TODO document the type and constructors

mutable struct CSRGraph{GID <: Integer, PID <: Integer, LID <: Integer} <: RowGraph{GID, PID, LID}
rowMap::BlockMap{GID, PID, LID}
colMap::Union{BlockMap{GID, PID, LID}, Nothing}
Expand Down Expand Up @@ -180,8 +178,12 @@ end

#### Constructors #####

"""
CSRGraph(rowMap::BlockMap, maxNumEntriesPerRow::Integer, pftype::ProfileType, plist::.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, maxNumEntriesPerRow::Integer,
pftype::ProfileType; plist...) where {
pftype::ProfileType, plist...) where {
GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, LID(maxNumEntriesPerRow), pftype, Dict(plist))
end
Expand All @@ -193,7 +195,7 @@ end

#= Should be handled by the following constructors
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LID},
maxNumEntriesPerRow::Integer, pftype::ProfileType; plist...) where {
maxNumEntriesPerRow::Integer, pftype::ProfileType, plist...) where {
GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, colMap, LID(maxNumEntriesPerRow), pftype, Dict(plist))
end
Expand All @@ -204,8 +206,12 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LI
end
=#

"""
CSRGraph(rowMap::BlockMap, colMap::Union{BlockMap, Nothing}, maxNumEntriesPerRow::Integer, pftype::ProfileType, plist.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::Union{BlockMap{GID, PID, LID}, Nothing},
maxNumEntriesPerRow::Integer, pftype::ProfileType; plist...) where {
maxNumEntriesPerRow::Integer, pftype::ProfileType, plist...) where {
GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, colMap, maxNumEntriesPerRow, pftype, Dict(plist))
end
Expand Down Expand Up @@ -239,8 +245,12 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::Union{BlockMap{GID, P
graph
end

"""
CSRGraph(rowMap::BlockMap, numEntPerRow::AbstractArray, pftype::ProfileType, plist.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, numEntPerRow::AbstractArray{<:Integer, 1},
pftype::ProfileType; plist...) where {
pftype::ProfileType, plist...) where {
GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, numEntPerRow, pftype, Dict(plist))
end
Expand All @@ -250,8 +260,12 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, numEntPerRow::AbstractArray{<
CSRGraph(rowMap, nothing, numEntPerRow, pftype, plist)
end

"""
CSRGraph(rowMap::BlockMap, colMap::BlockMap, numEntPerRow::AbstractArray, pftype::ProfileType, plist.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LID},
numEntPerRow::AbstractArray{<:Integer, 1}, pftype::ProfileType;
numEntPerRow::AbstractArray{<:Integer, 1}, pftype::ProfileType,
plist...) where {GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, colMap, numEntPerRow, pftype, Dict(plist))
end
Expand All @@ -261,8 +275,12 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LI
CSRGraph(rowMap, colMap, numEntPerRow, pftype, plist)
end

"""
CSRGraph(rowMap::BlockMap, colMap::Union{BlockMap, Nothing}, numEntPerRow::AbstractArray, pftype::ProfileType, plist.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::Union{BlockMap{GID, PID, LID}, Nothing},
numEntPerRow::AbstractArray{<:Integer, 1}, pftype::ProfileType;
numEntPerRow::AbstractArray{<:Integer, 1}, pftype::ProfileType,
plist...) where {GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, colMap, numEntPerRow, pftype, Dict(plist))
end
Expand Down Expand Up @@ -304,9 +322,12 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::Union{BlockMap{GID, P
graph
end

"""
CSRGraph(rowMap::BlockMap, colMap::BlockMap, rowPointers::AbstractArray, columnIndices::Array, plist.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LID},
rowPointers::AbstractArray{LID, 1}, columnIndices::Array{LID, 1};
rowPointers::AbstractArray{LID, 1}, columnIndices::Array{LID, 1},
plist...) where {GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, colMap, rowPointers, columnIndices, Dict(plist))
end
Expand Down Expand Up @@ -339,8 +360,12 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LI
graph
end

"""
CSRGraph(rowMap::BlockMap, colMap::BlockMap, localGraph::LocalCSRGraph, plist.../Dict)
"""
function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::BlockMap{GID, PID, LID},
localGraph::LocalCSRGraph{LID, LID}; plist...) where {
localGraph::LocalCSRGraph{LID, LID}, plist...) where {
GID <: Integer, PID <: Integer, LID <: Integer}
CSRGraph(rowMap, colMap, localGraph, Dict(plist))
end
Expand Down
135 changes: 131 additions & 4 deletions src/CSRMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,11 +1138,14 @@ function localApply(Y::MultiVector{Data, GID, PID, LID},
for i in LID(1):LID(len)
ind::LID = unsafe_load(indices, i)
val::Data = unsafe_load(values, i)
@inbounds sum += val*rawX[ind, vect]
#@inbounds sum += val*rawX[ind, vect]
sum += val*rawX[ind, vect]
end
sum = applyConjugation(mode, sum*alpha)
@inbounds rawY[row, vect] *= beta
@inbounds rawY[row, vect] += sum
#@inbounds rawY[row, vect] *= beta
rawY[row, vect] *= beta
#@inbounds rawY[row, vect] += sum
rawY[row, vect] += sum
end
end
else
Expand All @@ -1159,9 +1162,133 @@ function localApply(Y::MultiVector{Data, GID, PID, LID},
end
end
end

Y
end

"""
invRowMax(A::CSRMatrix{})
Returns a vector of the inverse of the maximum absolute values of each row of A
"""
function invRowMax(A::CSRMatrix{})
rows = getGlobalNumRows(A)
inv = Vector{Float64}(undef, rows)

for i = 1:rows
(inds, vals) = getGlobalRowView(A, i)
cols = 0
for m = 1:length(inds)
if cols < inds[m]
cols = inds[m]
end
end
max = 0
for j = 1:cols
if abs(vals[j]) > max
max = abs(vals[j])
end
end
inv[i] = 1/max
end
return inv
end

"""
invRowSum(A::CSRMatrix{})
Returns a vector of the inverse of the sums of each row of A
"""
function invRowSum(A::CSRMatrix{})
rows = getGlobalNumRows(A)
inv = Vector{Float64}(undef, rows)

for i = 1:rows
(inds, vals) = getGlobalRowView(A, i)
cols = 0
for m = 1:length(inds)
if cols < inds[m]
cols = inds[m]
end
end
sum = 0
for j = 1:cols
sum += vals[j]
end
inv[i] = 1/sum
end
end

"""
invColMax(A::CSRMatrix{})
Returns a vector of the inverse of the maximum absolute values of each column of A
"""
function invColMax(A::CSRMatrix{})
rows = getGlobalNumRows(A)
inv = Vector{Float64}(undef, rows)
thisVal = Vector{Float64}(undef, rows)
cols = 0

for i = 1:rows
(inds, vals) = getGlobalRowView(A, i)
for j = 1:length(inds)
if inds[j] > cols
cols = inds[j]
end
end
end

for i = 1:cols
for j = 1:rows
(inds, vals) = getGlobalRowView(A, j)
thisVal[j] = vals[i]
end
max = 0
for k = 1:rows
if abs(thisVal[k]) > max
max = abs(thisVal[k])
end
end
inv[i] = 1/max
end
return inv
end


"""
invColSum(A::CSRMatrix{})
Returns a vector of the inverse of the sums of each column of A
"""
function invColSum(A::CSRMatrix{})
rows = getGlobalNumRows(A)
inv = Vector{Float64}(undef, rows)
thisVal = Vector{Float64}(undef, rows)
cols = 0

for i = 1:rows
(inds, vals) = getGlobalRowView(A, i)
for j = 1:length(inds)
if inds[j] > cols
cols = inds[j]
end
end
end

for i = 1:cols
for j = 1:rows
(inds, vals) = getGlobalRowView(A, j)
thisVal[j] = vals[i]
end
@show thisVal
sum = 0
for k = 1:rows
sum += thisVal[k]
end
inv[i] = 1/sum
end
return inv
end


#### TODO: Computational methods####
25 changes: 15 additions & 10 deletions src/Export.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ struct Export{GID <: Integer, PID <:Integer, LID <: Integer}
exportData::ImportExportData{GID, PID, LID}
end

#TODO document

## Constructors ##

"""
Export(source::BlockMap, target::BlockMap, remotePIDs::Union{AbstractArray, Nothing}, plist...)
"""
function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID}, remotePIDs::Union{AbstractArray{PID}, Nothing}=nothing; plist...) where {GID <: Integer, PID <: Integer, LID <: Integer}
Export(source, target,
Dict(Tuple{Symbol, Any}[pair for pair in plist]))
end

function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID},
plist::Dict{Symbol}) where {GID <: Integer, PID <: Integer, LID <: Integer}
Export(source, target, nothing, plist)
end

function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID},
remotePIDs::Union{AbstractArray{PID}, Nothing}, plist::Dict{Symbol}) where {
"""
Export(source::BlockMap, target::BlockMap, remotePIDs::Union{AbstractArray, Nothing}, plist::Dict)
"""
function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID}, remotePIDs::Union{AbstractArray{PID}, Nothing}, plist::Dict{Symbol}) where {
GID <: Integer, PID <: Integer, LID <: Integer}

expor = Export(ImportExportData(source, target))
Expand All @@ -39,6 +36,14 @@ function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID}
expor
end

"""
Export(source::BlockMap, target::BlockMap, plist::Dict)
"""
function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID},
plist::Dict{Symbol}) where {GID <: Integer, PID <: Integer, LID <: Integer}
Export(source, target, nothing, plist)
end


## internal construction methods ##

Expand Down
2 changes: 1 addition & 1 deletion src/MPIUtil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MPI

#TODO document

# The RSend constand isn't defined on windows
# The RSend constant isn't defined on windows
const MPI_RSEND = if Sys.iswindows()
(:MPI_RSEND, MPI.libmpi)
else
Expand Down
Loading

0 comments on commit 31b4c9c

Please sign in to comment.