Skip to content

Instantly share code, notes, and snippets.

@fsmith001
Created July 26, 2022 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsmith001/28ef87b38c3b3a8e5b72cf6e0b5e0fb8 to your computer and use it in GitHub Desktop.
Save fsmith001/28ef87b38c3b3a8e5b72cf6e0b5e0fb8 to your computer and use it in GitHub Desktop.
trying to make the update() function work properly
abstract type Comm{GID <: Integer, PID <:Integer, LID <: Integer}
end
struct SerialComm{GID <: Integer, PID <:Integer, LID <: Integer} <: Comm{GID, PID, LID}
end
abstract type Directory{GID <: Integer, PID <:Integer, LID <: Integer}
end
mutable struct BlockMapData{GID <: Integer, PID <:Integer, LID <: Integer}
comm::Comm{GID, PID, LID}
directory::Union{Directory, Nothing}
lid::Vector{LID}
myGlobalElements::Vector{GID}
firstPointInElementList::Array{Integer}
elementSizeList::Array{Integer}
pointToElementList::Array{Integer}
numGlobalElements::GID
numMyElements::LID
elementSize::Integer
minMyElementSize::Integer
maxMyElementSize::Integer
minElementSize::Integer
maxElementSize::Integer
minAllGID::GID
maxAllGID::GID
minMyGID::GID
maxMyGID::GID
minLID::LID
maxLID::LID
numGlobalPoints::Integer
numMyPoints::Integer
constantElementSize::Bool
linearMap::Bool
distributedGlobal::Bool
oneToOneIsDetermined::Bool
oneToOne::Bool
lastContiguousGID::GID
lastContiguousGIDLoc::GID
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,
nothing,
LID[],
GID[],
numGlobalElements,
LID(0),
GID(0),
GID(0),
GID(0),
GID(0),
LID(0),
LID(0),
false,
false,
false,
false,
GID(0),
GID(0),
Dict{GID, LID}()
)
end
struct BlockMap{GID <: Integer, PID <:Integer, LID <: Integer}
data::BlockMapData{GID, PID, LID}
function BlockMap{GID, PID, LID}(data::BlockMapData) where {GID <: Integer, PID <:Integer, LID <: Integer}
new(data)
end
end
"""
BlockMap(numGlobalElements, comm)
Constructor for petra-defined uniform linear distribution of elements
"""
function BlockMap(numGlobalElements::Integer, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
BlockMap(GID(numGlobalElements), comm)
end
function BlockMap(numGlobalElements::GID, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
if numGlobalElements < 0
throw(InvalidArgumentError("NumGlobalElements = $(numGlobalElements). Should be >= 0"))
end
data = BlockMapData(numGlobalElements, comm)
map = BlockMap{GID, PID, LID}(data)
numProcVal = numProc(comm)
data.linearMap = true
myPIDVal = myPid(comm) - 1
data.numMyElements = floor(typeof(data.numGlobalElements),
data.numGlobalElements/numProcVal)
remainder = data.numGlobalElements % numProcVal
startIndex = myPIDVal * (data.numMyElements+1)
if myPIDVal < remainder
data.numMyElements += 1
else
startIndex -= (myPIDVal - remainder)
end
data.minAllGID = 1
data.maxAllGID = data.minAllGID + data.numGlobalElements - 1
data.minMyGID = startIndex + 1
data.maxMyGID = data.minMyGID + data.numMyElements - 1
data.distributedGlobal = isDistributedGlobal(map, data.numGlobalElements,
data.numMyElements)
EndOfConstructorOps(map)
map
end
"""
BlockMap(numGlobalElements, numMyElements, comm)
Constructor for user-defined linear distribution of elements
"""
function BlockMap(numGlobalElements::Integer, numMyElements::Integer, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
BlockMap(GID(numGlobalElements), LID(numMyElements), comm)
end
function BlockMap(numGlobalElements::GID, numMyElements::LID, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
if numGlobalElements < -1
throw(InvalidArgumentError("NumGlobalElements = $(numGlobalElements). Should be >= -1"))
end
if numMyElements < 0
throw(InvalidArgumentError("NumMyElements = $(numMyElements). Should be >= 0"))
end
data = BlockMapData(numGlobalElements, comm)
map = BlockMap{GID, PID, LID}(data)
data.numMyElements = numMyElements
data.linearMap = true
data.distributedGlobal = isDistributedGlobal(map, numGlobalElements, numMyElements)
#Local Map and uniprocessor case: Each processor gets a complete copy of all elements
if !data.distributedGlobal || numProc(comm) == 1
data.numGlobalElements = data.numMyElements
data.minAllGID = 1
data.maxAllGID = data.minAllGID + data.numGlobalElements - 1
data.minMyGID = 1
data.maxMyGID = data.minMyGID + data.numMyElements - 1
else
tmp_numMyElements = data.numMyElements
data.numGlobalElements = sumAll(data.comm, tmp_numMyElements)
data.minAllGID = 1
data.maxAllGID = data.minAllGID + data.numGlobalElements - 1
tmp_numMyElements = data.numMyElements
data.maxMyGID = scanSum(data.comm, tmp_numMyElements)
startIndex = data.maxMyGID - data.numMyElements
data.minMyGID = startIndex + 1
data.maxMyGID = data.minMyGID + data.numMyElements - 1
end
checkValidNGE(map, numGlobalElements)
EndOfConstructorOps(map)
map
end
"""
BlockMap(numGlobalElements, myGlobalElements, comm)
Constructor for user-defined arbitrary distribution of elements
"""
function BlockMap(numGlobalElements::Integer, myGlobalElements::AbstractArray{<:Integer}, comm::Comm{GID, PID,LID}
) where GID <: Integer where PID <: Integer where LID <: Integer
BlockMap(numGlobalElements, Array{GID}(myGlobalElements), comm)
end
function BlockMap(numGlobalElements::Integer, myGlobalElements::UnitRange{GID}, comm::Comm{GID, PID, LID}
) where {GID <: Integer, PID <: Integer, LID <: Integer}
numMyElements = LID(length(myGlobalElements))
data = BlockMapData(GID(0), comm)
map = BlockMap{GID, PID, LID}(data)
data.numMyElements = numMyElements
data.myGlobalElements = collect(myGlobalElements)
data.minMyGID = first(myGlobalElements)
data.maxMyGID = last(myGlobalElements)
#TODO this doesn't check if there is overlap between processors
# call the reduce to allow mixing this version with the abstract version
data.linearMap = Bool(minAll(data.comm, 1))
if numProc(comm) == 1
data.numGlobalElements = data.numMyElements
data.minAllGID = data.minMyGID
data.maxAllGID = data.maxMyGID
else
tmp_send = [
-((data.numMyElements > 0) ?
data.minMyGID : Inf)
, data.maxMyGID]
tmp_recv = maxAll(data.comm, tmp_send)
@assert typeof(tmp_recv[1]) <: Integer "Result type is $(typeof(tmp_recv[1])), should be subtype of Integer"
data.minAllGID = -tmp_recv[1]
data.maxAllGID = tmp_recv[2]
if numGlobalElements != -1
data.numGlobalElements = numGlobalElements
else
if data.linearMap
data.numGlobalElements = sumAll(data.comm, data.numMyElements)
else
#if 1+ GIDs shared between processors, need to total that correctly
allIDs = gatherAll(data.comm, myGlobalElements)
indexModifier = 1 - data.minAllGID
maxGID = data.maxAllGID
count = 0
arr = falses(maxGID + indexModifier)
for id in allIDs
if !arr[GID(id + indexModifier)]
arr[GID(id + indexModifier)] = true
count += 1
end
end
data.numGlobalElements = count
end
end
end
data.distributedGlobal = isDistributedGlobal(map, data.numGlobalElements, numMyElements)
EndOfConstructorOps(map)
map
end
function BlockMap(numGlobalElements::Integer, myGlobalElements::AbstractArray{GID}, comm::Comm{GID, PID,LID}
) where GID <: Integer where PID <: Integer where LID <: Integer
numMyElements = LID(length(myGlobalElements))
data = BlockMapData(GID(0), comm)
map = BlockMap{GID, PID, LID}(data)
data.numMyElements = numMyElements
linear = 1
if numMyElements > 0
data.myGlobalElements = Array{GID, 1}(undef, numMyElements)
data.myGlobalElements[1] = myGlobalElements[1]
data.minMyGID = myGlobalElements[1]
data.maxMyGID = myGlobalElements[1]
for i = 2:numMyElements
data.myGlobalElements[i] = myGlobalElements[i]
data.minMyGID = min(data.minMyGID, myGlobalElements[i])
data.maxMyGID = max(data.maxMyGID, myGlobalElements[i])
if myGlobalElements[i] != myGlobalElements[i-1] + 1
linear = 0
end
end
else
data.minMyGID = 1
data.maxMyGID = 0
end
#=
this doesn't check if there is overlap between processors
data.linearMap = Bool(minAll(data.comm, linear))
=#
if numProc(comm) == 1
data.numGlobalElements = data.numMyElements
data.minAllGID = data.minMyGID
data.maxAllGID = data.maxMyGID
else
tmp_send = [
-((data.numMyElements > 0) ?
data.minMyGID : Inf)
, data.maxMyGID]
tmp_recv = maxAll(data.comm, tmp_send)
@assert typeof(tmp_recv[1]) <: Integer "Result type is $(typeof(tmp_recv[1])), should be subtype of Integer"
data.minAllGID = -tmp_recv[1]
data.maxAllGID = tmp_recv[2]
if numGlobalElements != -1
data.numGlobalElements = numGlobalElements
else
if data.linearMap
data.numGlobalElements = sumAll(data.comm, data.numMyElements)
else
#if 1+ GIDs shared between processors, need to total that correctly
allIDs = gatherAll(data.comm, myGlobalElements)
indexModifier = 1 - data.minAllGID
maxGID = data.maxAllGID
count = 0
arr = falses(maxGID + indexModifier)
for id in allIDs
if !arr[GID(id + indexModifier)]
arr[GID(id + indexModifier)] = true
count += 1
end
end
data.numGlobalElements = count
end
end
end
data.distributedGlobal = isDistributedGlobal(map, data.numGlobalElements, numMyElements)
EndOfConstructorOps(map)
map
end
"""
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
"""
function BlockMap(numGlobalElements::Integer, numMyElements::Integer,
myGlobalElements::AbstractArray{GID}, userIsDistributedGlobal::Bool,
userMinAllGID::Integer, userMaxAllGID::Integer, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
BlockMap(GID(numGlobalElements), LID(numMyElements), Array{GID}(myGlobalElements), userIsDistributedGlobal,
GID(userMinAllGID), GID(userMaxAllGID), comm)
end
function BlockMap(numGlobalElements::GID, numMyElements::LID,
myGlobalElements::AbstractArray{GID}, userIsDistributedGlobal::Bool,
userMinAllGID::GID, userMaxAllGID::GID, comm::Comm{GID, PID, LID}) where GID <: Integer where PID <: Integer where LID <: Integer
if numGlobalElements < -1
throw(InvalidArgumentError("NumGlobalElements = $(numGlobalElements). Should be >= -1"))
end
if numMyElements < 0
throw(InvalidArgumentError("NumMyElements = $(numMyElements). Should be >= 0"))
end
if userMinAllGID < 1
throw(InvalidArgumentError("Minimum global element index = $(data.minAllGID). Should be >= 1"))
end
data = BlockMapData(numGlobalElements, comm)
map = BlockMap{GID, PID, LID}(data)
data.numMyElements = numMyElements
linear = 1
if numMyElements > 0
data.myGlobalElements = Vector{GID}(undef, numMyElements)
data.myGlobalElements[1] = myGlobalElements[1]
data.minMyGID = myGlobalElements[1]
data.maxMyGID = myGlobalElements[1]
for i = 2:numMyElements
data.myGlobalElements[i] = myGlobalElements[i]
data.minMyGID = min(data.minMyGID, myGlobalElements[i])
data.maxMyGID = max(data.maxMyGID, myGlobalElements[i])
if myGlobalElements[i] != myGlobalElements[i-1] + 1
linear = 0
end
end
else
data.minMyGID = 1
data.maxMyGID = 0
end
data.linearMap = Bool(minAll(comm, linear))
data.distributedGlobal = userIsDistributedGlobal
if !data.distributedGlobal || numProc(comm) == 1
data.numGlobalElements = data.numMyElements
checkValidNGE(map, numGlobalElements)
data.minAllGID = data.minMyGID
data.maxAllGID = data.maxMyGID
else
if numGlobalElements == -1
data.numGlobalElements = sumAll(data.comm, data.numMyElements)
else
data.numGlobalElements = numGlobalElements
end
checkValidNGE(data.numGlobalELements)
data.minAllGID = userMinAllGID
data.maxAllGID = userMaxAllGID
end
EndOfConstructorOps(map)
map
end
abstract type MultiVector{Data <: Number, GID <: Integer, PID <: Integer, LID <: Integer} <: AbstractArray{Data, 2}
end
mutable struct DenseMultiVector{Data <: Number, GID <: Integer, PID <: Integer, LID <: Integer} <: MultiVector{Data, GID, PID, LID}
data::Array{Data, 2}
numVectors::LID
map::BlockMap{GID, PID, LID}
end
function DenseMultiVector{Data}(map::BlockMap{GID, PID, LID}, numVecs::Integer, zeroOut=true) where {Data <: Number, GID <: Integer, PID <: Integer, LID <: Integer}
localLength = numMyElements(map)
if zeroOut
data = zeros(Data, (localLength, numVecs))
else
data = Array{Data, 2}(undef, localLength, numVecs)
end
DenseMultiVector{Data, GID, PID, LID}(data, numVecs, map)
end
function DenseMultiVector(map::BlockMap{GID, PID, LID}, data::AbstractArray{Data, 2}) where {Data <: Number, GID <: Integer, PID <: Integer, LID <: Integer}
localLength = numMyElements(map)
if size(data, 1) != localLength
throw(InvalidArgumentError("Length of vectors does not match local length indicated by map"))
end
DenseMultiVector{Data, GID, PID, LID}(data, size(data, 2), map)
end
function Base.getindex(A::MultiVector, row::Integer, col::Integer)
@boundscheck begin
if !(1<=col<=numVectors(A))
throw(BoundsError(A, (row, col)))
end
end
lRow = lid(getMap(A), row)
@boundscheck begin
if lRow < 1
throw(BoundsError(A, (row, col)))
end
end
@inbounds value = getLocalArray(A)[lRow, col]
value
end
function Base.getindex(A::MultiVector, i::Integer)
if numVectors(A) != 1
throw(ArgumentError("Can only use single index if there is just 1 vector"))
end
lRow = lid(getMap(A), i)
@boundscheck begin
if lRow < 1
throw(BoundsError(A, I))
end
end
@inbounds value = getLocalArray(A)[lRow, 1]
value
end
function Base.setindex!(A::MultiVector, v, row::Integer, col::Integer)
@boundscheck begin
if !(1<=col<=numVectors(A))
throw(BoundsError(A, (row, col)))
end
end
lRow = lid(getMap(A), row)
@boundscheck begin
if lRow < 1
throw(BoundsError(A, (row, col)))
end
end
@inbounds getLocalArray(A)[lRow, 1] = v
v
end
function Base.setindex!(A::MultiVector, v, i::Integer)
if numVectors(A) != 0
throw(ArgumentError("Can only use single index if there is just 1 vector"))
end
lRow = lid(getMap(A), i)
@boundscheck begin
if lRow < 1
throw(BoundsError(A, I))
end
end
@inbounds getLocalArray(A)[lRow, 1] = v
v
end
function numVectors end
function getLocalArray end
numVectors(mVect::DenseMultiVector) = mVect.numVectors
getMap(mVect::DenseMultiVector) = mVect.map
getLocalArray(mVect::DenseMultiVector) = mVect.data
@inline function lid(map::BlockMap{GID, PID, LID}, gid::Integer) where GID <: Integer where PID <: Integer where LID <: Integer
data = map.data
if (gid < data.minMyGID) || (gid > data.maxMyGID)
LID(0)
elseif data.linearMap
LID(gid - data.minMyGID + 1)
elseif gid >= data.myGlobalElements[1] && gid <= data.lastContiguousGID
LID(gid - data.myGlobalElements[1] + 1)
elseif haskey(data.lidHash, GID(gid))
data.lidHash[gid]
else
LID(0)
end
end
#############################################################################################
function update(a, A::MultiVector, b, B::MultiVector)
if numVectors(A) == numVectors(B) && localLength(A) == localLength(B)
myComm = SerialComm{Int, Int, Int}()
myMap = BlockMap(numVectors(A), localLength(A), myComm)
data = Array{Float32}(undef, localLength(A), numVectors(A))
result = DenseMultiVector{}(myMap, data)
A = scale!(A, a)
B = scale!(B, b)
for i = 1:numVectors(A)
for j = 1:localLength(A)
thisSum = A[i,j] + B[i,j]
#Base.setindex!(result, thisSum, i, j)
result[i,j] = thisSum
end
end
else
println("Error: MultiVectors must be the same size")
end
return result
end
myComm = SerialComm{Int, Int, Int}()
curMap = BlockMap(2, 2, myComm)
v1 = DenseMultiVector(curMap, ones(Float64, 2, 2))
v2 = DenseMultiVector(curMap, ones(Float64, 2, 2))
println("Update: ", update(2, v1, 3, v2))
@simonp0420
Copy link

simonp0420 commented Jul 26, 2022

When I include this file, I obtain a Julia error. Line 563 invokes the BlockMap method defined on line 133. This method proceeds to line 141 where it calls the BlockMapData method defined on line 45. On line 46 an error is encountered where it looks like the code is trying to call the built-in constructor for the BlockMapData type, but the number of arguments is wrong. The call has 19 arguments, but the default constructor requires 30 arguments.

In your original posting on Discourse, you said that the code runs but gives the wrong answers. I can't get it to run, for the reason outlined above. I'm guessing there is additional code you didn't supply. Please check on this and let me know.

@fsmith001
Copy link
Author

Yes, I agree with what you are saying. Originally, the code was running when I ran just the file in a window with a couple other files. When I ran it in the same window as the whole project (JuliaPetra), it was displaying the BlockMapData error; thus, whether or not the exact same file was running was inconsistent based on the window I was running it in. So yes, before it was running but with wrong answers, but now it does not run and I cannot recall making any changes that would do this.

I included the mutable struct BlockMapData (which takes 30 arguments) and the function BlockMapData (takes 19 arguments), so these are two distinct constructors I believe? I'm not sure why they would produce an error?

@simonp0420
Copy link

Julia automatically provides a constructor method for any defined struct that has exactly as many arguments as the struct has fields. In addition, the file provides a second constructor starting at line 45. Usually, these secondary constructors are for convenience, as in this case where only two arguments are needed, and the others are presumably given default values. Are you sure that there are no other BlockMapData constructors in the original code? Also, are you sure that the code copied into this gist was copied without errors?

If you can somehow run the original code that did not error, after it is done running, and before terminating that julia session, you could try typing

julia> methods(BlockMapData)

at the Julia prompt as shown above. If it shows more than the two methods that are defined in the gist file, then there must be additional methods that need to be copied to the gist.

@simonp0420
Copy link

simonp0420 commented Jul 26, 2022

I did some searching on Github and found that JuliaPetra is a registered package! I had no idea! I installed it and ran the package tests. They failed for the same reason as the code in the gist fails:

Precompiling project...
  2 dependencies successfully precompiled in 1 seconds (10 already precompiled)
     Testing Running tests...
Comm Tests: Error During Test at /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:23
  Got exception outside of a @test
  LoadError: MethodError: no method matching JuliaPetra.BlockMapData(::SerialComm{Int32, Bool, Int16}, ::Nothing, ::Vector{Int16}, ::Vector{Int32}, ::Int32, ::Int16, ::Int32, ::Int32, ::Int32, ::Int32, ::Int16, ::Int16, ::Bool, ::Bool, ::Bool, ::Bool, ::Int32, ::Int32, ::Dict{Int32, Int16})
  Closest candidates are:
    JuliaPetra.BlockMapData(::Comm{GID, PID, LID}, ::Union{Nothing, Directory}, ::Vector{LID}, ::Vector{GID}, ::Array{Integer}, ::Array{Integer}, ::Array{Integer}, ::GID, ::LID, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::GID, ::GID, ::GID, ::GID, ::LID, ::LID, ::Integer, ::Integer, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::GID, ::GID, ::Dict{GID, LID}) where {GID<:Integer, PID<:Integer, LID<:Integer} at /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMapData.jl:5
  Stacktrace:
    [1] JuliaPetra.BlockMapData(numGlobalElements::Int32, comm::SerialComm{Int32, Bool, Int16})
      @ JuliaPetra /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMapData.jl:40
    [2] BlockMap(numGlobalElements::Int32, numMyElements::Int16, comm::SerialComm{Int32, Bool, Int16})
      @ JuliaPetra /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMap.jl:92
    [3] BlockMap(numGlobalElements::Int64, numMyElements::Int64, comm::SerialComm{Int32, Bool, Int16})
      @ JuliaPetra /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMap.jl:81
    [4] top-level scope
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/Import-Export Tests.jl:6
    [5] include(fname::String)
      @ Base.MainInclude ./client.jl:451
    [6] macro expansion
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:25 [inlined]
    [7] macro expansion
      @ ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/Test/src/Test.jl:1283 [inlined]
    [8] macro expansion
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:24 [inlined]
    [9] macro expansion
      @ ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/Test/src/Test.jl:1283 [inlined]
   [10] top-level scope
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:17
   [11] include(fname::String)
      @ Base.MainInclude ./client.jl:451
   [12] top-level scope
      @ none:6
   [13] eval
      @ ./boot.jl:373 [inlined]
   [14] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:268
   [15] _start()
      @ Base ./client.jl:495
  in expression starting at /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/Import-Export Tests.jl:6
Data Structure Tests: Error During Test at /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:33
  Got exception outside of a @test
  MethodError: no method matching JuliaPetra.BlockMapData(::SerialComm{Int32, Bool, Int16}, ::Nothing, ::Vector{Int16}, ::Vector{Int32}, ::Int32, ::Int16, ::Int32, ::Int32, ::Int32, ::Int32, ::Int16, ::Int16, ::Bool, ::Bool, ::Bool, ::Bool, ::Int32, ::Int32, ::Dict{Int32, Int16})
  Closest candidates are:
    JuliaPetra.BlockMapData(::Comm{GID, PID, LID}, ::Union{Nothing, Directory}, ::Vector{LID}, ::Vector{GID}, ::Array{Integer}, ::Array{Integer}, ::Array{Integer}, ::GID, ::LID, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::GID, ::GID, ::GID, ::GID, ::LID, ::LID, ::Integer, ::Integer, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::GID, ::GID, ::Dict{GID, LID}) where {GID<:Integer, PID<:Integer, LID<:Integer} at /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMapData.jl:5
  Stacktrace:
    [1] JuliaPetra.BlockMapData(numGlobalElements::Int32, comm::SerialComm{Int32, Bool, Int16})
      @ JuliaPetra /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMapData.jl:40
    [2] BlockMap(numGlobalElements::Int32, numMyElements::Int16, comm::SerialComm{Int32, Bool, Int16})
      @ JuliaPetra /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMap.jl:92
    [3] BlockMap(numGlobalElements::Int64, numMyElements::Int64, comm::SerialComm{Int32, Bool, Int16})
      @ JuliaPetra /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/src/BlockMap.jl:81
    [4] denseMultiVectorTests(comm::SerialComm{Int32, Bool, Int16})
      @ Main /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/DenseMultiVectorTests.jl:10
    [5] macro expansion
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:34 [inlined]
    [6] macro expansion
      @ ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/Test/src/Test.jl:1283 [inlined]
    [7] macro expansion
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:34 [inlined]
    [8] macro expansion
      @ ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/Test/src/Test.jl:1283 [inlined]
    [9] top-level scope
      @ /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:17
   [10] include(fname::String)
      @ Base.MainInclude ./client.jl:451
   [11] top-level scope
      @ none:6
   [12] eval
      @ ./boot.jl:373 [inlined]
   [13] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:268
   [14] _start()
      @ Base ./client.jl:495
Test Summary:          | Pass  Error  Total
Serial tests           |   48      2     50
  Util Tests           |    6             6
  Comm Tests           |   42      1     43
  Data Structure Tests |           1      1
ERROR: LoadError: Some tests did not pass: 48 passed, 0 failed, 2 errored, 0 broken.
in expression starting at /mnt/simonp_win/simonp_win/julia/dev/JuliaPetraDev/JuliaPetra.jl/test/runtests.jl:14
ERROR: Package JuliaPetra errored during testing

I would guess that some change that has been introduced has also introduced the bug. I suggest looking through the old commits till you find one where the tests pass, then looking carefully at the changes until you find what caused the errors. I.e. "git bisecting".

@fsmith001
Copy link
Author

Yes, thank you for looking into this! I will look into the old commits and hopefully will find my issue there. I appreciate all your help with this!

@simonp0420
Copy link

You're welcome. Good luck!

@fsmith001
Copy link
Author

I thought my issues with this were going to be over; however, I believe I fixed the BlockMapData issue as the update function will run now, but once again the problem is with an incorrect output.

Once again, here is my code for update. When I "include JuliaPetra" it runs without needing anything else in the file. I expect the output to be [5.0 5.0; 5.0 5.0] but it is [5.0 0.0; 5.0 1.0f-45].

function update(a, A::MultiVector, b, B::MultiVector)
    if numVectors(A) == numVectors(B) && localLength(A) == localLength(B)
        myComm = SerialComm{Int, Int, Int}()
        myMap = BlockMap(numVectors(A), localLength(A), myComm)
        data = Array{Float32}(undef, localLength(A), numVectors(A))
        result = DenseMultiVector{}(myMap, data)

        A = scale!(A, a)
        B = scale!(B, b)

        for i = 1:numVectors(A)
            for j = 1:localLength(A)
                thisSum = A[i,j] + B[i,j]
                result[i,j] = thisSum
            end
        end
    else
        println("Error: MultiVectors must be the same size")
    end
    return result
end

myComm = SerialComm{Int, Int, Int}()
curMap = BlockMap(2, 2, myComm)
v1 = DenseMultiVector(curMap, ones(Float64, 2, 2))
v2 = DenseMultiVector(curMap, ones(Float64, 2, 2))
println("Update: ", update(2, v1, 3, v2))

I would appreciate any help/ideas with this!

@simonp0420
Copy link

simonp0420 commented Jul 28, 2022 via email

@fsmith001
Copy link
Author

Sorry about that, does the repo work if you try it now?

@simonp0420
Copy link

simonp0420 commented Jul 28, 2022 via email

@fsmith001
Copy link
Author

I fixed the duplicates but now there are some others issues. I will need to take some time to work on this, but thank you for your help.

@simonp0420
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment