Skip to content

Commit 3737c98

Browse files
author
Ewan Crawford
committed
Refactor raw arg update
1 parent 89193f0 commit 3737c98

File tree

5 files changed

+14
-36
lines changed

5 files changed

+14
-36
lines changed

sycl/source/detail/graph_impl.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ std::set<std::shared_ptr<node_impl>> graph_impl::getCGEdges(
405405
}
406406
}
407407

408-
return std::move(UniqueDeps);
408+
return UniqueDeps;
409409
}
410410

411411
void graph_impl::markCGMemObjs(
@@ -1563,7 +1563,7 @@ void exec_graph_impl::updateImpl(std::shared_ptr<node_impl> Node) {
15631563
}
15641564
}
15651565

1566-
UpdateDesc.hNewKernel = nullptr;
1566+
UpdateDesc.hNewKernel = UrKernel;
15671567
UpdateDesc.numNewMemObjArgs = MemobjDescs.size();
15681568
UpdateDesc.pNewMemObjArgList = MemobjDescs.data();
15691569
UpdateDesc.numNewPointerArgs = PtrDescs.size();
@@ -1852,24 +1852,7 @@ void dynamic_parameter_impl::updateValue(const raw_kernel_arg *NewRawValue,
18521852
size_t RawArgSize = NewRawValue->MArgSize;
18531853
const void *RawArgData = NewRawValue->MArgData;
18541854

1855-
for (auto &[NodeWeak, ArgIndex] : MNodes) {
1856-
auto NodeShared = NodeWeak.lock();
1857-
if (NodeShared) {
1858-
dynamic_parameter_impl::updateCGArgValue(
1859-
NodeShared->MCommandGroup, ArgIndex, RawArgData, RawArgSize);
1860-
}
1861-
}
1862-
1863-
for (auto &DynCGInfo : MDynCGs) {
1864-
auto DynCG = DynCGInfo.DynCG.lock();
1865-
if (DynCG) {
1866-
auto &CG = DynCG->MKernels[DynCGInfo.CGIndex];
1867-
dynamic_parameter_impl::updateCGArgValue(CG, DynCGInfo.ArgIndex,
1868-
RawArgData, RawArgSize);
1869-
}
1870-
}
1871-
1872-
std::memcpy(MValueStorage.data(), RawArgData, RawArgSize);
1855+
updateValue(RawArgData, RawArgSize);
18731856
}
18741857

18751858
void dynamic_parameter_impl::updateValue(const void *NewValue, size_t Size) {
@@ -1987,7 +1970,6 @@ dynamic_command_group_impl::dynamic_command_group_impl(
19871970

19881971
void dynamic_command_group_impl::finalizeCGFList(
19891972
const std::vector<std::function<void(handler &)>> &CGFList) {
1990-
// True if kernels use sycl::nd_range, and false if using sycl::range
19911973
for (size_t CGFIndex = 0; CGFIndex < CGFList.size(); CGFIndex++) {
19921974
const auto &CGF = CGFList[CGFIndex];
19931975
// Handler defined inside the loop so it doesn't appear to the runtime

sycl/source/detail/graph_impl.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ class node_impl : public std::enable_shared_from_this<node_impl> {
417417
throw sycl::exception(sycl::errc::invalid,
418418
"Cannot update execution range of a node with an "
419419
"execution range of different dimensions than what "
420-
"the node was original created with.");
420+
"the node was originally created with.");
421421
}
422422

423423
NDRDesc = sycl::detail::NDRDescT{ExecutionRange};
@@ -438,7 +438,7 @@ class node_impl : public std::enable_shared_from_this<node_impl> {
438438
throw sycl::exception(sycl::errc::invalid,
439439
"Cannot update execution range of a node with an "
440440
"execution range of different dimensions than what "
441-
"the node was original created with.");
441+
"the node was originally created with.");
442442
}
443443

444444
NDRDesc = sycl::detail::NDRDescT{ExecutionRange};
@@ -1173,11 +1173,6 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
11731173
/// @param Deps List of dependent nodes
11741174
void addDepsToNode(std::shared_ptr<node_impl> Node,
11751175
std::vector<std::shared_ptr<node_impl>> &Deps) {
1176-
// Remove empty shared pointers from the list
1177-
auto EmptyElementIter =
1178-
std::remove(Deps.begin(), Deps.end(), std::shared_ptr<node_impl>());
1179-
Deps.erase(EmptyElementIter, Deps.end());
1180-
11811176
if (!Deps.empty()) {
11821177
for (auto &N : Deps) {
11831178
N->registerSuccessor(Node);

sycl/source/handler.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,10 @@ event handler::finalize() {
556556
// node can set it as a predecessor.
557557
auto DependentNode = GraphImpl->getLastInorderNode(MQueue);
558558
std::vector<std::shared_ptr<ext::oneapi::experimental::detail::node_impl>>
559-
Deps = {DependentNode};
559+
Deps;
560+
if (DependentNode) {
561+
Deps.push_back(DependentNode);
562+
}
560563
NodeImpl = GraphImpl->add(NodeType, std::move(CommandGroup), Deps);
561564

562565
// If we are recording an in-order queue remember the new node, so it
@@ -566,7 +569,11 @@ event handler::finalize() {
566569
} else {
567570
auto LastBarrierRecordedFromQueue = GraphImpl->getBarrierDep(MQueue);
568571
std::vector<std::shared_ptr<ext::oneapi::experimental::detail::node_impl>>
569-
Deps = {LastBarrierRecordedFromQueue};
572+
Deps;
573+
574+
if (LastBarrierRecordedFromQueue) {
575+
Deps.push_back(LastBarrierRecordedFromQueue);
576+
}
570577
NodeImpl = GraphImpl->add(NodeType, std::move(CommandGroup), Deps);
571578

572579
if (NodeImpl->MCGType == sycl::detail::CGType::Barrier) {

sycl/test-e2e/Graph/Update/dyn_cgf_overwrite_range.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
77

8-
// XFAIL: level_zero
9-
// XFAIL-TRACKER: OFNAAO-307
10-
118
// Tests how the nd-range of a node is overwritten by the active command-group
129

1310
#include "../graph_common.hpp"

sycl/test-e2e/Graph/Update/dyn_cgf_update_before_finalize.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
// Extra run to check for immediate-command-list in Level Zero
66
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %}
77

8-
// XFAIL: level_zero
9-
// XFAIL-TRACKER: OFNAAO-307
10-
118
// Tests updating a dynamic command-group node after it has been added to
129
// a graph but before the graph has been finalized
1310

0 commit comments

Comments
 (0)