@@ -74,42 +74,47 @@ class node_impl {
7474
7575 // / Tests if two nodes have the same content,
7676 // / i.e. same command group
77+ // / This function should only be used for internal purposes.
78+ // / A true return from this operator is not a guarantee that the nodes are
79+ // / equals according to the Common reference semantics. But this function is
80+ // / an helper to verify that two nodes contain equivalent Command Groups.
7781 // / @param Node node to compare with
82+ // / @return true if two nodes have equivament command groups. false otherwise.
7883 bool operator ==(const node_impl &Node) {
7984 if (MCGType != Node.MCGType )
8085 return false ;
8186
82- if (MCGType == sycl::detail::CG::CGTYPE::Kernel) {
87+ switch (MCGType) {
88+ case sycl::detail::CG::CGTYPE::Kernel: {
8389 sycl::detail::CGExecKernel *ExecKernelA =
8490 static_cast <sycl::detail::CGExecKernel *>(MCommandGroup.get ());
8591 sycl::detail::CGExecKernel *ExecKernelB =
8692 static_cast <sycl::detail::CGExecKernel *>(Node.MCommandGroup .get ());
87-
88- if (ExecKernelA->MKernelName .compare (ExecKernelB->MKernelName ) != 0 )
89- return false ;
93+ return ExecKernelA->MKernelName .compare (ExecKernelB->MKernelName ) == 0 ;
9094 }
91- if (MCGType == sycl::detail::CG::CGTYPE::CopyUSM) {
95+ case sycl::detail::CG::CGTYPE::CopyUSM: {
9296 sycl::detail::CGCopyUSM *CopyA =
9397 static_cast <sycl::detail::CGCopyUSM *>(MCommandGroup.get ());
9498 sycl::detail::CGCopyUSM *CopyB =
9599 static_cast <sycl::detail::CGCopyUSM *>(MCommandGroup.get ());
96- if ((CopyA->getSrc () != CopyB->getSrc ()) ||
97- (CopyA->getDst () != CopyB->getDst ()) ||
98- (CopyA->getLength () == CopyB->getLength ()))
99- return false ;
100+ return (CopyA->getSrc () == CopyB->getSrc ()) &&
101+ (CopyA->getDst () == CopyB->getDst ()) &&
102+ (CopyA->getLength () == CopyB->getLength ());
100103 }
101- if ((MCGType == sycl::detail::CG::CGTYPE::CopyAccToAcc) ||
102- (MCGType == sycl::detail::CG::CGTYPE::CopyAccToPtr) ||
103- (MCGType == sycl::detail::CG::CGTYPE::CopyPtrToAcc)) {
104+ case sycl::detail::CG::CGTYPE::CopyAccToAcc:
105+ case sycl::detail::CG::CGTYPE::CopyAccToPtr:
106+ case sycl::detail::CG::CGTYPE::CopyPtrToAcc: {
104107 sycl::detail::CGCopy *CopyA =
105108 static_cast <sycl::detail::CGCopy *>(MCommandGroup.get ());
106109 sycl::detail::CGCopy *CopyB =
107110 static_cast <sycl::detail::CGCopy *>(MCommandGroup.get ());
108- if ((CopyA->getSrc () != CopyB->getSrc ()) ||
109- (CopyA->getDst () != CopyB->getDst ()))
110- return false ;
111+ return (CopyA->getSrc () == CopyB->getSrc ()) &&
112+ (CopyA->getDst () == CopyB->getDst ());
113+ }
114+ default :
115+ assert (false && " Unexpected command group type!" );
116+ return false ;
111117 }
112- return true ;
113118 }
114119
115120 // / Recursively add nodes to execution stack.
0 commit comments