Refactor NG911 call storage from Call structs to separate field vectors#946
Open
CodersRepo wants to merge 2 commits into
Open
Refactor NG911 call storage from Call structs to separate field vectors#946CodersRepo wants to merge 2 commits into
CodersRepo wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors NG911 simulation call state storage on the CPU from Call structs (AoS) into separate field vectors (SoA), aligning the CPU layout with the existing GPU representation to simplify/accelerate host↔device copies.
Changes:
- Replaced per-vertex waiting queues and per-server “currently serving” storage with
CallCircularBufferandCallSlotArrays. - Replaced
All911Edges::call_with per-field vectors (callTime_,callX_, etc.) and updated vertex/edge logic accordingly. - Simplified CUDA transfer code paths by directly
cudaMemcpy-ing field vectors instead of packing/unpackingCallstructs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Simulator/Vertices/NG911/All911Vertices.h | Switches vertex queues/serving call storage to new SoA helper types; updates responder lookup signature. |
| Simulator/Vertices/NG911/All911Vertices.cpp | Refactors CPU advance/integration logic to read/write per-field call storage. |
| Simulator/Vertices/NG911/All911Vertices_d.cpp | Updates host↔device copies to memcpy SoA buffers directly. |
| Simulator/Edges/NG911/All911Edges.h | Replaces vector<Call> call_ with per-field vectors. |
| Simulator/Edges/NG911/All911Edges.cpp | Initializes the new per-field vectors. |
| Simulator/Edges/NG911/All911Edges_d.cpp | Refactors edge host↔device copies to use SoA vectors directly. |
| Simulator/Utils/InputManager.h | Adds getEvents() overload to fill CallCircularBuffer for NG911. |
| Simulator/Utils/CallCircularBuffer.h | New SoA circular buffer implementation for calls (CPU-side mirror of GPU layout). |
| Simulator/Utils/CallSlotArrays.h | New fixed-size per-vertex/per-server SoA storage for “serving” calls. |
| Simulator/Utils/CallUtils.h | New helpers for responder-type conversion and assembling Call structs from SoA fields. |
Comment on lines
594
to
+598
| // Calculate the driving time to the incident in seconds | ||
| double driveTime = (dist2incident / avgDrivingSpeed_) * 3600; | ||
| serverCountdown_[vertexIdx][availUnit] = driveTime + incident.onSiteTime; | ||
| serverCountdown_[vertexIdx][availUnit] = driveTime + vertexQueue.onSiteTime()[queueEnd]; | ||
|
|
||
| serverCountdown_[vertexIdx][availUnit] = incident.duration; | ||
| LOG4CPLUS_DEBUG(vertexLogger_, "Response, driving time: " << driveTime << ", On-site time: " | ||
| << incident.onSiteTime); | ||
| serverCountdown_[vertexIdx][availUnit] = vertexQueue.duration()[queueEnd]; |
Comment on lines
632
to
636
| vertexType requiredType; | ||
| if (call.type == "Law") | ||
| if (responderType == 7) | ||
| requiredType = vertexType::LAW; | ||
| else if (call.type == "EMS") | ||
| else if (responderType == 5) | ||
| requiredType = vertexType::EMS; |
Comment on lines
+181
to
+185
| /// @brief Inserts events into a CallCircularBuffer for NG911 simulations. | ||
| CallCircularBuffer &getEvents(const VertexId_t &vertexId, uint64_t firstStep, uint64_t lastStep, | ||
| CallCircularBuffer &buffer) | ||
| { | ||
| queue<T> &eventQueue = eventsMap_[vertexId]; |
Comment on lines
+10
to
+28
| #include "BGTypes.h" | ||
| #include "InputEvent.h" | ||
| #include <cstdint> | ||
| #include <string> | ||
|
|
||
| /// Responder type codes matching vertexType enum values for EMS, FIRE, and LAW. | ||
| inline int responderTypeToInt(const std::string &type) | ||
| { | ||
| if (type == "Law") { | ||
| return 7; | ||
| } | ||
| if (type == "EMS") { | ||
| return 5; | ||
| } | ||
| if (type == "Fire") { | ||
| return 6; | ||
| } | ||
| return 0; | ||
| } |
Comment on lines
+30
to
+34
| inline std::string responderTypeToString(int responderType) | ||
| { | ||
| if (responderType == 7) { | ||
| return "Law"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #
Description
Brief description
Refactored NG911 call storage from struct-of-arrays (Call, CircularBuffer, vector<vector>) to separate field vectors on the CPU, matching the existing GPU layout.
New helpers
CallCircularBuffer - vertex waiting queues
CallSlotArrays - calls being served per server
CallUtils - responder type conversion and Call assembly
Updated storage
Vertices: vertexQueues_ and servingCall_ now use the new buffer types
Edges: call_ replaced with separate vectors (callVertexId_, callTime_, callDuration_, etc.)
Benefits
CPU and GPU use the same field layout
Host/device copies are direct cudaMemcpy calls instead of unpacking Call structs
Sets up future use of RecordableVector / DeviceVector
The Call struct is still used for reading input XML via InputManager; only simulation state was moved to separate vectors.
Checklist (Mandatory for new features)
Testing (Mandatory for all changes)
test-medium-connected.xmlPassedtest-large-long.xmlPassed