Skip to content

Commit

Permalink
main.jl and minor errors
Browse files Browse the repository at this point in the history
main.jl made to test out constructing multivectors and performing functions on them
  • Loading branch information
fsmith001 committed Jun 26, 2022
1 parent a580ab3 commit 996d437
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 43 deletions.
Binary file added .DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "julia",
"request": "launch",
"name": "Run active Julia file",
"program": "${file}",
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"juliaEnv": "${command:activeJuliaEnvironment}"
}
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name = "JuliaPetra"
uuid = "0a7d185b-be57-59df-ac21-86d8a1799c2e"
authors = ["Neil Lindquist <[email protected]>"]
authors = ["Neil Lindquist <[email protected]>", "Fiona Smith <[email protected]>"]
version = "0.2.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
TypeStability = "73ec333a-e3df-5994-9c7a-5ef2077ce03e"

[compat]
MPI = "0.7.0"
Expand Down
4 changes: 2 additions & 2 deletions src/BlockMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ end
function remoteIDList(map::BlockMap{GID, PID, LID}, gidList::AbstractArray{GID}
)::Tuple{AbstractArray{PID}, AbstractArray{LID}} where GID <: Integer where PID <: Integer where LID <: Integer
data = map.data
if data.directory == nothing
if data.directory === nothing
data.directory = createDirectory(data.comm, map)
end

Expand Down Expand Up @@ -743,7 +743,7 @@ function determineIsOneToOne(map::BlockMap)::Bool
if numProc(data.comm) < 2
true
else
if data.directory == nothing
if data.directory === nothing
data.directory = createDirectory(data.comm, map)
end
gidsAllUniquelyOwned(data.directory)
Expand Down
6 changes: 3 additions & 3 deletions src/CSRGraphConstructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ mutable struct CSRGraph{GID <: Integer, PID <: Integer, LID <: Integer} <: RowGr
#skipping sizeof checks
#skipping max value checks related to size_t

@assert(indicesType != LOCAL_INDICES || colMap != nothing,
@assert(indicesType != LOCAL_INDICES || colMap !== nothing,
"Cannot have local indices with a null column Map")

#ensure LID is a subset of GID (for positive numbers)
Expand Down Expand Up @@ -228,7 +228,7 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::Union{BlockMap{GID, P
STORAGE_1D_UNPACKED
: STORAGE_2D),

(colMap == nothing) ? GLOBAL_INDICES : LOCAL_INDICES,
(colMap === nothing) ? GLOBAL_INDICES : LOCAL_INDICES,
plist
)
allocateIndices(graph, graph.indicesType, LID(maxNumEntriesPerRow))
Expand Down Expand Up @@ -286,7 +286,7 @@ function CSRGraph(rowMap::BlockMap{GID, PID, LID}, colMap::Union{BlockMap{GID, P
STORAGE_1D_UNPACKED
: STORAGE_2D),

(colMap == nothing) ? GLOBAL_INDICES : LOCAL_INDICES,
(colMap === nothing) ? GLOBAL_INDICES : LOCAL_INDICES,
plist
)

Expand Down
13 changes: 7 additions & 6 deletions src/CSRGraphExternalMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ getLocalNumDiags(graph::CSRGraph) = graph.nodeNumDiags
getGlobalMaxNumRowEntries(graph::CSRGraph) = graph.globalMaxNumRowEntries
getLocalMaxNumRowEntries(graph::CSRGraph) = graph.nodeMaxNumRowEntries

hasColMap(graph::CSRGraph) = graph.colMap != nothing
hasColMap(graph::CSRGraph) = graph.colMap !== nothing

isLowerTriangular(graph::CSRGraph) = graph.lowerTriangle
isUpperTriangular(graph::CSRGraph) = graph.upperTriangle
Expand Down Expand Up @@ -319,7 +319,7 @@ function insertGlobalIndices(graph::CSRGraph{GID, PID, LID}, globalRow::GID,

myRow = lid(graph.rowMap, globalRow)
if myRow != 0
if false #for debuggin
if false #for debugging
if hasColMap(graph)
colMap = graph.colMap

Expand Down Expand Up @@ -370,7 +370,8 @@ function insertGlobalIndicesFiltered(graph::CSRGraph{GID, PID, LID}, globalRow::
colMap = getColMap(graph)
indices = [index for index in indices if myLid(colMap, index)]
end
insertGlobalIndicesImpl(myRow, indices)
#insertGlobalIndicesImpl(myRow, indices)
insertGlobalIndicesImpl(graph, myRow, indices)
else
#nonlocal row
append!(graph.nonlocals[globalRow], indices)
Expand Down Expand Up @@ -508,13 +509,13 @@ end
fillComplete(graph::CSRGraph; plist...) = fillComplete(graph, Dict(plist))

function fillComplete(graph::CSRGraph, plist::Dict)
if graph.domainMap == nothing
if graph.domainMap === nothing
domMap = graph.rowMap
else
domMap = graph.domainMap
end

if graph.rangeMap == nothing
if graph.rangeMap === nothing
ranMap = graph.colMap
else
ranMap = graph.rangeMap
Expand Down Expand Up @@ -609,7 +610,7 @@ function setAllIndices(graph::CSRGraph{GID, PID, LID},

localNumRows = getLocalNumRows(graph)

if graph.colMap == nothing
if graph.colMap === nothing
throw(InvalidStateError("The graph must have a "
* "column map before calling setAllIndices"))
end
Expand Down
16 changes: 8 additions & 8 deletions src/CSRGraphInternalMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ end

function makeImportExport(graph::CSRGraph{GID, PID, LID}) where {
GID <: Integer, PID <: Integer, LID <: Integer}
@assert (graph.colMap != nothing) "Cannot make imports and exports without a column map"
@assert (graph.colMap !== nothing) "Cannot make imports and exports without a column map"

if graph.importer == nothing
if graph.importer === nothing
if !sameAs(graph.domainMap, graph.colMap)
graph.importer = Import(graph.domainMap, graph.colMap)
end
end

if graph.exporter == nothing
if graph.exporter === nothing
if !sameAs(graph.rangeMap, graph.rowMap)
graph.exporter = Export(graph.rowMap, graph.rangeMap)
end
Expand All @@ -378,9 +378,9 @@ function checkInternalState(graph::CSRGraph)
"Graph must be either fill active or fill "
* "complete$(isFillActive(graph) ? "not both" : "").")
@assert(!isFillComplete(graph)
|| (graph.colMap != nothing
&& graph.domainMap != nothing
&& graph.rangeMap != nothing),
|| (graph.colMap !== nothing
&& graph.domainMap !== nothing
&& graph.rangeMap !== nothing),
"Graph is fill complete, but at least one of {column, range, domain} map is null")
@assert((graph.storageStatus != STORAGE_1D_PACKED
&& graph.storageStatus != STORAGE_1D_UNPACKED)
Expand Down Expand Up @@ -853,14 +853,14 @@ function __makeColMap(graph::CSRGraph{GID, PID, LID}, domMap::Union{BlockMap{GID
) where {GID, PID, LID}
error = false

if domMap == nothing
if domMap === nothing
return nothing
end

if isLocallyIndexed(graph)
colMap = graph.colMap

if colMap == nothing
if colMap === nothing
warn("$(myPid(getComm(graph))): The graph is locally indexed, but does not have a column map")

error = true
Expand Down
5 changes: 3 additions & 2 deletions src/CSRMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ end
#### Row Matrix functions ####

getRowMap(mat::CSRMatrix) = mat.rowMap
hasColMap(mat::CSRMatrix) = mat.colMap != nothing
hasColMap(mat::CSRMatrix) = !isnothing(mat.colMap)
getColMap(mat::CSRMatrix) = mat.colMap
getGraph(mat::CSRMatrix) = mat.myGraph

Expand Down Expand Up @@ -921,7 +921,8 @@ function getLocalDiagCopy(matrix::CSRMatrix{Data, GID, PID, LID})::MultiVector{D
localColMap = getLocalMap(colMap)
localMatrix = matrix.localMatrix

diag1D[:] = getDiagCopyWithoutOffsets(matrix, localRowMap, localColMap, localMatrix)
#diag1D[:] = getDiagCopyWithoutOffsets(matrix, localRowMap, localColMap, localMatrix)
diag1D[:] = getDiagCopyWithoutOffsets(localRowMap, localColMap, localMatrix)

diag
else
Expand Down
8 changes: 4 additions & 4 deletions src/DistObject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ end

function doImport(source, target, importer::Union{Import{GID, PID, LID}, Nothing},
cm::CombineMode) where {GID <:Integer, PID <: Integer, LID <: Integer}
if importer != nothing
if importer !== nothing
doImport(source, target, importer, cm)
end
end
Expand All @@ -115,7 +115,7 @@ end

function doExport(source, target, exporter::Union{Export{GID, PID, LID}, Nothing},
cm::CombineMode) where {GID <:Integer, PID <: Integer, LID <: Integer}
if exporter != nothing
if exporter !== nothing
doImport(source, target, exporter, cm)
end
end
Expand All @@ -137,7 +137,7 @@ end

function doImport(source, target, exporter::Union{Export{GID, PID, LID}, Nothing},
cm::CombineMode) where {GID <:Integer, PID <: Integer, LID <: Integer}
if exporter != nothing
if exporter !== nothing
doImport(source, target, exporter, cm)
end
end
Expand All @@ -159,7 +159,7 @@ end

function doExport(source, target, importer::Union{Import{GID, PID, LID}, Nothing},
cm::CombineMode) where {GID <:Integer, PID <: Integer, LID <: Integer}
if importer != nothing
if importer !== nothing
doImport(source, target, importer, cm)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/Import.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function setupExport(impor::Import{GID, PID, LID}, remoteGIDs::AbstractArray{GID
data = impor.importData
source = sourceMap(impor)

useRemotePIDs = userRemotePIDs != nothing
useRemotePIDs = userRemotePIDs !== nothing

# Sanity Checks
if useRemotePIDs && length(userRemotePIDs) != length(remoteGIDs)
Expand Down
8 changes: 4 additions & 4 deletions src/MPIDistributor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function createReverseDistributor(dist::MPIDistributor{GID, PID, LID}
) where {GID <: Integer, PID <: Integer, LID <: Integer}
myProc = myPid(dist.comm)

if dist.planReverse == nothing
if dist.planReverse === nothing
totalSendLength = reduce(+, dist.lengths_to)

maxRecvLength::GID = 0
Expand Down Expand Up @@ -571,7 +571,7 @@ function resolveWaits(dist::MPIDistributor)::Array
dist.status = MPI.Waitall!(dist.request)
end

if dist.importObjs == nothing
if dist.importObjs === nothing
throw(InvalidStateError("Cannot resolve waits when no posts have been made"))
end

Expand All @@ -597,7 +597,7 @@ function resolveReversePosts(dist::MPIDistributor{GID, PID, LID},
throw(InvalidStateError("Cannot do reverse comm when data is not blocked by processor"))
end

if dist.planReverse == nothing
if dist.planReverse === nothing
createReverseDistributor(dist)
end

Expand All @@ -607,7 +607,7 @@ end

function resolveReverseWaits(dist::MPIDistributor{GID, PID, LID}
)::Vector where {GID <: Integer, PID <: Integer, LID <: Integer}
if dist.planReverse == nothing
if dist.planReverse === nothing
throw(InvalidStateError("Cannot resolve reverse waits if there is no reverse plan"))
end

Expand Down
25 changes: 25 additions & 0 deletions src/MultiVector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,43 @@ Returns the local length of the vectors in the MultiVector
"""
localLength(mVect::MultiVector) = numMyElements(getMap(mVect))

"""
Base.fill!(::MultiVector, values)
Returns a filled multivector, filled with the given values
"""
function Base.fill!(mVect::MultiVector, values)
fill!(getLocalArray(mVect), values)
mVect
end

"""
scale!(::MultiVector, ::Number)
Returns a new multivector scaled by the given alpha
"""
function scale!(mVect::MultiVector, alpha::Number)
rmul!(getLocalArray(mVect), alpha)
mVect
end

"""
scale!(::MultiVector, ::AbstractArray)
Returns a new multivector scaled by values in the given array
"""
function scale!(mVect::MultiVector{Data, GID, PID, LID}, alpha::AbstractArray{<:Number, 1}) where {Data, GID, PID, LID}
for v in LID(1):numVectors(mVect)
@inbounds getVectorView(mVect, v)[:] *= alpha[v]
end
mVect
end

"""
dot(::MultiVector, ::MutliVector) :: AbstractArray
Returns an array that is the dot product of two given multivectors
"""
function dot(vect1::MultiVector{Data, GID, PID, LID}, vect2::MultiVector{Data, GID, PID, LID}
)::AbstractArray{Data, 2} where {Data, GID, PID, LID}
numVects = numVectors(vect1)
Expand All @@ -87,6 +107,11 @@ function dot(vect1::MultiVector{Data, GID, PID, LID}, vect2::MultiVector{Data, G
sumAll(getComm(vect1), dotProducts)::Array{Data, 2}
end

"""
norm(::MultiVector, ::Real)
Computes the norm of a Multivector where the number given determines the type of norm (e.g., L1, L2, etc.)
"""
function norm(mVect::MultiVector{Data, GID, PID, LID}, n::Real) where {Data, GID, PID, LID}
numVects = numVectors(mVect)
localVectLength = localLength(mVect)
Expand Down
Loading

0 comments on commit 996d437

Please sign in to comment.