MCPcopy Create free account
hub / github.com/ROCm/clr / EnqueueSegment

Method EnqueueSegment

hipamd/src/hip_graph_internal.cpp:1580–1684  ·  view source on GitHub ↗

================================================================================================ Graph segment to queue dispatch matching

Source from the content-addressed store, hash-verified

1578// ================================================================================================
1579// Graph segment to queue dispatch matching
1580hipError_t GraphExec::EnqueueSegment(const Segment& segment, hip::Stream* stream,
1581 amd::AccumulateCommand* accumulate) {
1582 hipError_t status = hipSuccess;
1583
1584 // Find the SegmentBatch for this segment using O(1) map lookup
1585 SegmentBatch* segBatch = nullptr;
1586 auto segBatchIt = segmentBatches_.find(segment.id);
1587 if (segBatchIt != segmentBatches_.end()) {
1588 segBatch = &segBatchIt->second;
1589 }
1590
1591 size_t batchIndex = 0;
1592
1593 // Handle child graph segments - recursively enqueue the entire child graph
1594 if (segment.child_graph_ptr != nullptr) {
1595 auto childGraphExec = dynamic_cast<GraphExec*>(segment.child_graph_ptr);
1596 if (childGraphExec != nullptr) {
1597 // Child graphs share the same kernel arg manager as parent (for packet capture)
1598 if (childGraphExec->GetKernelArgManager() == nullptr) {
1599 auto kernArgMgr = GetKernelArgManager();
1600 if (kernArgMgr != nullptr) {
1601 kernArgMgr->retain(); // Increment ref count for child's reference
1602 childGraphExec->SetKernelArgManager(kernArgMgr);
1603 }
1604 }
1605
1606 // Recursively enqueue the child graph with its own dependency tracking
1607 // Child graphs use their own parallel_streams_, so pass empty vector
1608 hipError_t child_status = hipSuccess;
1609 amd::Command* child_last_cmd = childGraphExec->EnqueueSegmentedGraph(
1610 stream, {}, &child_status);
1611
1612 if (child_status != hipSuccess) {
1613 ClPrint(amd::LOG_ERROR, amd::LOG_CODE,
1614 "[hipGraph] EnqueueSegment: Failed to enqueue child graph, status=%d",
1615 child_status);
1616 return child_status;
1617 }
1618
1619 // Child graph's work is already enqueued to the stream
1620 // The returned last command tracks completion - release our reference
1621 if (child_last_cmd != nullptr) {
1622 child_last_cmd->release();
1623 }
1624 }
1625
1626 // Child graph segment has no regular nodes to process
1627 return hipSuccess;
1628 }
1629
1630 // Process all nodes in this segment
1631 for (size_t i = 0; i < segment.nodes.size(); ++i) {
1632 auto& node = segment.nodes[i];
1633 if (DEBUG_HIP_GRAPH_DOT_PRINT) {
1634 node->stream_id_ = stream->GetStreamId();
1635 }
1636 if (!node->GraphCaptureEnabled()) {
1637 // Node doesn't support capture - execute individually

Callers

nothing calls this directly

Calls 15

GetKernelArgManagerMethod · 0.80
SetKernelArgManagerMethod · 0.80
EnqueueSegmentedGraphMethod · 0.80
GetStreamIdMethod · 0.80
GetQueueMethod · 0.80
rebuildFilteredListsMethod · 0.80
emptyMethod · 0.80
endMethod · 0.45
retainMethod · 0.45
releaseMethod · 0.45
sizeMethod · 0.45
GraphCaptureEnabledMethod · 0.45

Tested by

no test coverage detected