Skip to content

Commit

Permalink
Improve a few function names
Browse files Browse the repository at this point in the history
map -> getMap   - to distingush between Julia's map function
comm -> getComm - allows comm as a variable and clear-er code
  • Loading branch information
neil-lindquist committed Mar 2, 2018
1 parent 902a10a commit fb80d2e
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 91 deletions.
10 changes: 5 additions & 5 deletions src/BasicDirectory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type BasicDirectory{GID <: Integer, PID <:Integer, LID <: Integer} <: Directory{
function BasicDirectory{GID, PID, LID}(map::BlockMap{GID, PID, LID}) where {GID, PID, LID}

if !(distributedGlobal(map))
new(map, Nullable{BlockMap}(), [], [], numProc(comm(map))!=1, [], [])
new(map, Nullable{BlockMap}(), [], [], numProc(getComm(map))!=1, [], [])
elseif linearMap(map)
commObj = comm(map)
commObj = getComm(map)

allMinGIDs = gatherAll(commObj, minMyGID(map))
allMinGIDs = vcat(allMinGIDs, [1+maxAllGID(map)])
Expand Down Expand Up @@ -126,7 +126,7 @@ function getDirectoryEntries(directory::BasicDirectory{GID, PID, LID}, map::Bloc
localEntries = Vector{LID}(numEntries)

if !distributedGlobal(map)
myPIDVal = myPid(comm(map))
myPIDVal = myPid(getComm(map))

for i = 1:numEntries
lidVal = lid(map, globalEntries[i])
Expand All @@ -143,7 +143,7 @@ function getDirectoryEntries(directory::BasicDirectory{GID, PID, LID}, map::Bloc
minAllGIDVal = minAllGID(map)
maxAllGIDVal = maxAllGID(map)

numProcVal = numProc(comm(map))
numProcVal = numProc(getComm(map))

n_over_p = numGlobalElements(map)/numProcVal

Expand Down Expand Up @@ -185,7 +185,7 @@ function getDirectoryEntries(directory::BasicDirectory{GID, PID, LID}, map::Bloc
localEntries[i] = lid
end
else #general case
distributor = createDistributor(comm(map))
distributor = createDistributor(getComm(map))

dirProcs = remoteIDList(map, numEntries, globalEntries)

Expand Down
11 changes: 2 additions & 9 deletions src/BlockMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ end

##### external methods #####

getComm(map::BlockMap) = map.data.comm

"""
myGID(map::BlockMap, gidVal::Integer)
Expand Down Expand Up @@ -708,12 +710,3 @@ function determineIsOneToOne(map::BlockMap)::Bool
gidsAllUniquelyOwned(get(data.directory))
end
end

"""
comm(map::BlockMap{GID, PID, LID})::Comm{GID, PID, LID}
Return the Comm for the map
"""
function comm(map::BlockMap{GID, PID, LID})::Comm{GID, PID, LID} where GID <: Integer where PID <: Integer where LID <: Integer
map.data.comm
end
12 changes: 6 additions & 6 deletions src/CRSGraphExternalMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getLocalRowCopy(graph::CRSGraph{GID, PID, LID}, localRow::LID)::Array{L
end

function pack(source::CRSGraph{GID, PID, LID}, exportLIDs::AbstractArray{LID, 1}, distor::Distributor{GID, PID, LID})::Array{Array{LID, 1}, 1} where {GID, PID, LID}
srcMap = map(source)
srcMap = getMap(source)
[getGlobalRowCopy(source, gid(srcMap, lid)) for lid in exportLIDs]
end

Expand Down Expand Up @@ -163,7 +163,7 @@ function unpackAndCombine(target::CRSGraph{GID, PID, LID},
@assert(isFillActive(target),
"Import and Export operations require a fill active graph")

tgtMap = map(target)
tgtMap = getMap(target)

for i = 1:length(importLIDs)
row = imports[i]
Expand Down Expand Up @@ -209,7 +209,7 @@ function insertLocalIndices(graph::CRSGraph{GID, PID, LID},
if !hasColMap(graph)
throw(InvalidStateError("Cannot insert local indices without a column map"))
end
if !myLID(map(graph), localRow)
if !myLID(getMap(graph), localRow)
throw(InvalidArgumentError("Row does not belong to this process"))
end
if !hasRowInfo(graph)
Expand Down Expand Up @@ -284,7 +284,7 @@ function insertGlobalIndices(graph::CRSGraph{GID, PID, LID}, globalRow::GID,
badColInds = [index for index in indices
if myGid(colMap, index)==0]
if length(badColInds) != 0
throw(InvalidArgumentError("$(myPid(comm(graph))): "
throw(InvalidArgumentError("$(myPid(getComm(graph))): "
* "Attempted to insert entries in owned row $globalRow, "
* "at the following column indices: $indices.\n"

Expand Down Expand Up @@ -513,7 +513,7 @@ function fillComplete(graph::CRSGraph{GID, PID, LID}, domainMap::BlockMap{GID, P
throw(InvalidStateError("Graph fill state must be active to call fillComplete(...)"))
end

const numProcs = numProc(comm(graph))
const numProcs = numProc(getComm(graph))

const assertNoNonlocalInserts = get(plist, :noNonlocalChanges, false)

Expand Down Expand Up @@ -556,7 +556,7 @@ function makeColMap(graph::CRSGraph{GID, PID, LID}) where {GID, PID, LID}
error, colMap = __makeColMap(graph, graph.domainMap)

if @debug
comm = JuliaPetra.comm(graph)
comm = getComm(graph)
globalError = maxAll(comm, error)

if globalError
Expand Down
18 changes: 9 additions & 9 deletions src/CRSGraphInternalMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const rowInfoSpare = Union{Void, RowInfo}[nothing]
end
end

(@debug) && (myPid(comm(graph)) == 1) && println("can't reuse $(@inbounds rowInfoSpare[1])")
(@debug) && (myPid(getComm(graph)) == 1) && println("can't reuse $(@inbounds rowInfoSpare[1])")
#couldn't reuse, create new instance
return RowInfo{LID}(graph, localRow, allocSize, numEntries, offset1D)
end
Expand Down Expand Up @@ -121,7 +121,7 @@ function computeGlobalConstants(graph::CRSGraph{GID, PID, LID}) where {

computeLocalConstants(graph)

commObj = comm(map(graph))
commObj = getComm(getRowMap(graph))

#if graph.haveGlobalConstants == false #short circuited above
graph.globalNumEntries, graph.globalNumDiags = sumAll(commObj,
Expand Down Expand Up @@ -544,7 +544,7 @@ end
function globalAssemble(graph::CRSGraph)
@assert isFillActive(graph) "Fill must be active before calling globalAssemble(graph)"

comm = JuliaPetra.comm(graph)
comm = getComm(graph)
myNumNonlocalRows = length(graph.nonlocals)

maxNonlocalRows = maxAll(comm, myNumNonlocalRows)
Expand Down Expand Up @@ -782,7 +782,7 @@ function insertGlobalIndicesImpl(graph::CRSGraph{GID, PID, LID},
@assert numNewToInsert >= 0 "More duplications than indices"

if rowInfo.numEntries + numNewToInsert > rowInfo.allocSize
throw(InvalidArgumentError("$(myPid(comm(graph))): "
throw(InvalidArgumentError("$(myPid(getComm(graph))): "
* "For local row $myRow, even after excluding "
* "$dupCount duplicate(s) in input, the new number "
* "of entries $(rowInfo.numEntries + numNewToInsert) "
Expand Down Expand Up @@ -851,7 +851,7 @@ function __makeColMap(graph::CRSGraph{GID, PID, LID}, wrappedDomMap::Nullable{Bl
wrappedColMap = graph.colMap

if isnull(wrappedColMap)
warn("$(myPid(comm(graph))): The graph is locally indexed, but does not have a column map")
warn("$(myPid(getComm(graph))): The graph is locally indexed, but does not have a column map")

error = true
myColumns = GID[]
Expand All @@ -866,7 +866,7 @@ function __makeColMap(graph::CRSGraph{GID, PID, LID}, wrappedDomMap::Nullable{Bl
myColumns = copy(myGlobalElements(colMap))
end
end
return (error, BlockMap(myColumns, comm(domMap)))
return (error, BlockMap(myColumns, getComm(domMap)))
end

#else if graph.isGloballyIndexed
Expand Down Expand Up @@ -906,7 +906,7 @@ function __makeColMap(graph::CRSGraph{GID, PID, LID}, wrappedDomMap::Nullable{Bl
numRemoteColGIDs = length(remoteGIDSet)

#line 214, abunch of explanation of serial short circuit
if numProc(comm(domMap)) == 1
if numProc(getComm(domMap)) == 1
if numRemoteColGIDs != 0
error = true
end
Expand Down Expand Up @@ -968,13 +968,13 @@ function __makeColMap(graph::CRSGraph{GID, PID, LID}, wrappedDomMap::Nullable{Bl

if numLocalCount != numLocalColGIDs
if @debug
warn("$(myPid(comm(graph))): numLocalCount = $numLocalCount "
warn("$(myPid(getComm(graph))): numLocalCount = $numLocalCount "
* "!= numLocalColGIDs = $numLocalColGIDs. "
* "This should not happen.")
end
error = true
end
end

return (error, BlockMap(myColumns, comm(domMap)))
return (error, BlockMap(myColumns, getComm(domMap)))
end
8 changes: 4 additions & 4 deletions src/CSRMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ computeGlobalConstants(matrix::CSRMatrix) = nothing
clearGlobalConstants(matrix::CSRMatrix) = nothing

function globalAssemble(matrix::CSRMatrix)
comm = JuliaPetra.comm(matrix)
comm = getComm(matrix)
if !isFillActive(matrix)
throw(InvalidStateError("Fill must be active to call this method"))
end
Expand Down Expand Up @@ -667,7 +667,7 @@ function fillComplete(matrix::CSRMatrix{Data, GID, PID, LID},
assertNoNonlocalInserts = get(plist, :noNonlocalChanges, false)
#skipping sort ghosts stuff

numProcs = numProc(comm(matrix))
numProcs = numProc(getComm(matrix))

needGlobalAssemble = !assertNoNonlocalInserts && numProcs > 1
if needGlobalAssemble
Expand Down Expand Up @@ -1064,7 +1064,7 @@ function applyNonTranspose!(Y::MultiVector{Data, GID, PID, LID}, operator::CSRMa
exporter = getGraph(operator).exporter

#assumed to be shared by all data structures
resultComm = comm(Y)
resultComm = getComm(Y)

YIsOverwritten = (beta == ZERO)
YIsReplicated = !distributedGlobal(Y) && numProc(resultComm) != 0
Expand Down Expand Up @@ -1128,7 +1128,7 @@ function applyTranspose!(Yin::MultiVector{Data, GID, PID, LID}, operator::CSRMat

YIsReplicated = distributedGlobal(Yin)
YIsOverwritted = (beta == ZERO)
if YIsReplicated && myPID(comm(operator)) != 1
if YIsReplicated && myPID(getComm(operator)) != 1
beta = ZERO
end

Expand Down
13 changes: 11 additions & 2 deletions src/Comm.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export Comm
export barrier, broadcastAll, gatherAll, sumAll, maxAll, minAll, scanSum
export myPid, numProc, createDistributor
export getComm

# methods (and docs) are currently based straight off Epetra_Comm
# tpetra's equivalent seemed to be a wrapper to other Trilinos packages
Expand Down Expand Up @@ -125,7 +126,7 @@ function barrier end
broadcastAll(comm::Comm, myVals::AbstractArray{T, 1}, root::Integer)::Array{T, 1}
Takes a list of input values from the root processor and sends it to each
other processor. The broadcasted values are then returned, including on
other processor. The broadcasted values are then returned, including on
the root process.
"""
function broadcastAll end
Expand Down Expand Up @@ -191,4 +192,12 @@ function numProc end
Creates a distributor for the given Comm object
"""
function createDistributor end
function createDistributor end


"""
getComm(obj)
Gets the Comm for the object, if aplicable
"""
function getComm end
20 changes: 11 additions & 9 deletions src/DistObject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
export doImport, doExport
export copyAndPermute, packAndPrepare, unpackAndCombine, checkSize
export releaseViews, createViews, createViewsNonConst
export getMap

# Note that all packet size information was removed due to the use of julia's
# built in serialization/objects

#|
#=
"""
A base type for constructing and using dense multi-vectors, vectors and matrices in parallel.
Expand All @@ -26,22 +27,23 @@ method returns the array of objects to export
unpackAndCombine(target::<:DistObject{GID, PID, LID},importLIDs::AbstractArray{LID, 1}, imports::AAbstractrray, distor::Distributor{GID, PID, LID}, cm::CombineMode)
Perform any unpacking and combining after communication
"""
|#
"""
SrcDistObject requires getMap(::SrcDistObject)
"""
=#


"""
Returns true if this object is a distributed global
"""
function distributedGlobal(obj)
distributedGlobal(map(obj))
distributedGlobal(getMap(obj))
end


"""
Get's the Comm instance being used by this object
"""
function comm(obj)
comm(map(obj))
function getComm(obj)
getComm(getMap(obj))
end


Expand Down Expand Up @@ -132,7 +134,7 @@ function doTransfer(source, target, cm::CombineMode,
readAlso = true #from TPetras rwo
if cm == INSERT || cm == REPLACE
numIDsToWrite = numSameIDs + length(permuteToLIDs) + length(remoteLIDs)
if numIDsToWrite == numMyElements(map(target))
if numIDsToWrite == numMyElements(getMap(target))
# overwriting all local data in the destination, so write-only suffices

#TODO look at FIXME on line 503
Expand Down
14 changes: 7 additions & 7 deletions src/Export.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ function Export(source::BlockMap{GID, PID, LID}, target::BlockMap{GID, PID, LID}
GID <: Integer, PID <: Integer, LID <: Integer}

if @debug
info("$(myPid(comm(source))): Export ctor\n")
info("$(myPid(getComm(source))): Export ctor\n")
end

expor = Export(ImportExportData(source, target))

exportGIDs = setupSamePermuteExport(expor)

if @debug
info("$(myPid(comm(source))): Export ctor: setupSamePermuteExport done\n")
info("$(myPid(getComm(source))): Export ctor: setupSamePermuteExport done\n")
end
if distributedGlobal(source)
setupRemote(expor, exportGIDs)
end
if @debug
info("$(myPid(comm(source))): Export ctor: done\n")
info("$(myPid(getComm(source))): Export ctor: done\n")
end

expor
Expand Down Expand Up @@ -148,7 +148,7 @@ function setupRemote(expor::Export{GID, PID, LID}, exportGIDs::AbstractArray{GID
target = targetMap(data)

if @debug
info("$(myPid(comm(target))): setupRemote\n")
info("$(myPid(getComm(target))): setupRemote\n")
end

exportPIDs = JuliaPetra.exportPIDs(data)
Expand All @@ -159,13 +159,13 @@ function setupRemote(expor::Export{GID, PID, LID}, exportGIDs::AbstractArray{GID
permute!(exportGIDs, order)

if @debug
info("$(myPid(comm(target))): setupRemote: Calling createFromSends\n")
info("$(myPid(getComm(target))): setupRemote: Calling createFromSends\n")
end

numRemoteIDs = createFromSends(distributor(data), exportPIDs)

if @debug
info("$(myPid(comm(target))): setupRemote: Calling doPostsAndWaits\n")
info("$(myPid(getComm(target))): setupRemote: Calling doPostsAndWaits\n")
end

remoteGIDs = resolve(distributor(data), exportGIDs)
Expand All @@ -179,7 +179,7 @@ function setupRemote(expor::Export{GID, PID, LID}, exportGIDs::AbstractArray{GID
end

if @debug
info("$(myPid(comm(target))): setupRemote: done\n")
info("$(myPid(getComm(target))): setupRemote: done\n")
end
end

Expand Down
Loading

0 comments on commit fb80d2e

Please sign in to comment.