Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ba2tro committed Oct 4, 2024
1 parent 148649c commit 33d4b20
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/controlplane/2a_cnc_interactive.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include("setup.jl")

phys_graph = PhysicalGraph(graph, 1, 8, regsize)
controller = Controller(sim, net, 6, phys_graph, 0.1)
controller = Controller(sim, net, 6, phys_graph)
@process controller()

req_gen = RequestGenerator(sim, net, 1, 8, 6, phys_graph)
Expand All @@ -11,7 +11,7 @@ consumer = EntanglementConsumer(sim, net, 1, 8)
@process consumer()

for node in 1:7
tracker = RequestTracker(sim, net, node, 0.1)
tracker = RequestTracker(sim, net, node)
@process tracker()
end

Expand Down
24 changes: 16 additions & 8 deletions src/ProtocolZoo/ProtocolZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ See also: [`SwapperProt`](@ref), [`EntanglementTracker`](@ref), [`EntanglementRe
swapping_node::Int
"""The number of rounds the swapper should run for"""
rounds::Int
"""Whether the swap request is the final request on a path, hence signaling the request being served"""
last::Int
"""path id for which the request was generated"""
id::Int
"""the source node that generated the request"""
src::Int
end
Base.show(io::IO, tag::SwapRequest) = print(io, "Node $(tag.swapping_node) perform a swap")
Tag(tag::SwapRequest) = Tag(SwapRequest, tag.swapping_node, tag.rounds)
Tag(tag::SwapRequest) = Tag(SwapRequest, tag.swapping_node, tag.rounds, tag.last, tag.id, tag.src)

Check warning on line 196 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L195-L196

Added lines #L195 - L196 were not covered by tests

"""
$TYPEDEF
Expand Down Expand Up @@ -530,8 +536,6 @@ $TYPEDFIELDS
net::RegisterNet
"""the vertex of the node where the tracker is working"""
node::Int
"""duration of request generation and processing"""
ticktock::Float64
end

@resumable function (prot::RequestTracker)()
Expand All @@ -551,16 +555,19 @@ end
entangler = EntanglerProt(prot.sim, prot.net, prot.node, neighbor; rounds=rounds, randomize=true)
@process entangler()

Check warning on line 556 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L541-L556

Added lines #L541 - L556 were not covered by tests
else
msg = querydelete!(mb, requesttagsymbol, ❓, ❓)
msg = querydelete!(mb, requesttagsymbol, ❓, ❓, ❓, ❓, ❓)
@debug "RequestTracker @$(prot.node): Received $msg"
isnothing(msg) && continue
workwasdone = true
(src, (_, _, rounds)) = msg
(msg_src, (_, _, rounds, last, path_id, src)) = msg
@debug "RequestTracker @$(prot.node): Performing a swap"
swapper = SwapperProt(prot.sim, prot.net, prot.node; nodeL = <(prot.node), nodeH = >(prot.node), chooseL=argmin, chooseH=argmax, rounds=rounds)
@process swapper()
if last == 1
comp_msg = Tag(RequestCompletion, path_id)
put!(channel(prot.net, prot.node=>src; permit_forward=true), comp_msg)

Check warning on line 568 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L558-L568

Added lines #L558 - L568 were not covered by tests
end
end
@yield timeout(prot.sim, prot.ticktock)
end
end
@debug "RequestTracker @$(prot.node): Starting message wait at $(now(prot.sim)) with MessageBuffer containing: $(mb.buffer)"
Expand Down Expand Up @@ -594,7 +601,7 @@ $TYPEDFIELDS
"""The object containing physical graph metadata for the network"""
phys_graph::PhysicalGraph
"""rate of arrival of requests/number of requests sent unit time"""
λ::Int = 4
λ::Int = 3
end

function RequestGenerator(sim, net, src, dst, controller, phys_graph; kwargs...)
Expand All @@ -608,18 +615,19 @@ end
path_index = path_selection(prot.phys_graph)
if isnothing(path_index)
prot.phys_graph.failures[] += 1
@yield timeout(prot.sim, rand(d))
continue

Check warning on line 619 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L611-L619

Added lines #L611 - L619 were not covered by tests
end
msg = Tag(DistributionRequest, prot.src, prot.dst, path_index)
put!(channel(prot.net, prot.src=>prot.controller; permit_forward=true), msg)

Check warning on line 622 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L621-L622

Added lines #L621 - L622 were not covered by tests
@yield timeout(prot.sim, rand(d))

# incoming message from the controller after a request has been served
in_msg = querydelete!(mb, RequestCompletion, ❓)
if !isnothing(in_msg)
(src, (_, path_id)) = in_msg
prot.phys_graph.workloads[path_id] -= 1

Check warning on line 628 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L625-L628

Added lines #L625 - L628 were not covered by tests
end
@yield timeout(prot.sim, rand(d))
end

Check warning on line 631 in src/ProtocolZoo/ProtocolZoo.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/ProtocolZoo.jl#L630-L631

Added lines #L630 - L631 were not covered by tests
end

Expand Down
8 changes: 2 additions & 6 deletions src/ProtocolZoo/controllers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ See also [`RequestGenerator`](@ref), [`RequestTracker`](@ref)
node::Int
"""The object containing physical graph metadata for the network"""
phys_graph::PhysicalGraph
"""duration of a single full cycle of entanglement generation and swapping along a specific path"""
ticktock::Float64
end

@resumable function (prot::Controller)()
Expand All @@ -98,16 +96,14 @@ end
end

Check warning on line 96 in src/ProtocolZoo/controllers.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/controllers.jl#L96

Added line #L96 was not covered by tests

for i in 2:length(path)-1
msg = Tag(SwapRequest, path[i], 1)
last = i == length(path) - 1 ? 1 : 0
msg = Tag(SwapRequest, path[i], 1, last, path_ind, src)
if prot.node == path[i]
put!(mb, msg)

Check warning on line 102 in src/ProtocolZoo/controllers.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/controllers.jl#L98-L102

Added lines #L98 - L102 were not covered by tests
else
put!(channel(prot.net, prot.node=>msg[2];permit_forward=true), msg)

Check warning on line 104 in src/ProtocolZoo/controllers.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/controllers.jl#L104

Added line #L104 was not covered by tests
end
end

Check warning on line 106 in src/ProtocolZoo/controllers.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtocolZoo/controllers.jl#L106

Added line #L106 was not covered by tests
out_msg = Tag(RequestCompletion, path_ind)
put!(channel(prot.net, prot.node=>src;permit_forward=true), out_msg)
@yield timeout(prot.sim, prot.ticktock)
end
@debug "Controller @$(prot.node): Starting message wait at $(now(prot.sim)) with MessageBuffer containing: $(mb.buffer)"
@yield wait(mb)
Expand Down

0 comments on commit 33d4b20

Please sign in to comment.