Skip to content

Refactor NG911 call storage from Call structs to separate field vectors#946

Open
CodersRepo wants to merge 2 commits into
SharedDevelopmentfrom
issue-862-sperate-call-struts-vector-in-911-simulations
Open

Refactor NG911 call storage from Call structs to separate field vectors#946
CodersRepo wants to merge 2 commits into
SharedDevelopmentfrom
issue-862-sperate-call-struts-vector-in-911-simulations

Conversation

@CodersRepo

Copy link
Copy Markdown

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)

  • Added Documentation
  • Added Unit Tests

Testing (Mandatory for all changes)

  • GPU Test: test-medium-connected.xml Passed
  • GPU Test: test-large-long.xml Passed

@CodersRepo CodersRepo self-assigned this Jun 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CallCircularBuffer and CallSlotArrays.
  • 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/unpacking Call structs.

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";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants