Skip to content

Commit b60c02d

Browse files
fix: Add asserts to ensure NonCopyable and NonMovable n/n
Related-To: NEO-14068 Signed-off-by: Filip Hazubski <[email protected]>
1 parent aeff551 commit b60c02d

36 files changed

+71
-51
lines changed

level_zero/sysman/source/api/vf_management/sysman_vf_management.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77

88
#pragma once
9+
#include "shared/source/helpers/non_copyable_or_moveable.h"
10+
911
#include "level_zero/api/sysman/zes_handles_struct.h"
1012
#include <level_zero/zes_api.h>
1113

@@ -31,7 +33,7 @@ class VfManagement : _zes_vf_handle_t {
3133
}
3234
};
3335

34-
struct VfManagementHandleContext {
36+
struct VfManagementHandleContext : NEO::NonCopyableAndNonMovableClass {
3537
VfManagementHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
3638
~VfManagementHandleContext();
3739

@@ -47,5 +49,7 @@ struct VfManagementHandleContext {
4749
std::once_flag initVfManagementOnce;
4850
};
4951

52+
static_assert(NEO::NonCopyableAndNonMovable<VfManagementHandleContext>);
53+
5054
} // namespace Sysman
5155
} // namespace L0

opencl/source/context/context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Context : public BaseObject<_cl_context> {
6868

6969
const StackVec<NEO::GraphicsAllocation *, 1> &getAllocationsVector();
7070
};
71+
static_assert(NEO::NonCopyable<AbstractBuffersPool<BufferPool, Buffer, MemObj>>);
7172

7273
class BufferPoolAllocator : public AbstractBuffersAllocator<BufferPool, Buffer, MemObj> {
7374
using BaseType = AbstractBuffersAllocator<BufferPool, Buffer, MemObj>;

opencl/source/event/event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
7878
int32_t callbackExecutionStatusTarget; // minimum event execution status that will triger this callback
7979
void *userData;
8080
};
81+
static_assert(NEO::NonCopyableAndNonMovable<IFList<Callback, true, true>>);
8182

8283
struct ProfilingInfo {
8384
uint64_t cpuTimeInNs;

opencl/source/event/event_tracker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -24,6 +24,7 @@ struct TrackedEvent : IFNode<TrackedEvent> {
2424
Event *ev = nullptr;
2525
int64_t eventId = 1;
2626
};
27+
static_assert(NEO::NonCopyableAndNonMovable<IFList<TrackedEvent, true, true>>);
2728

2829
class EventsTracker {
2930

opencl/source/helpers/task_information.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace NEO {
3131
template void KernelOperation::ResourceCleaner::operator()<LinearStream>(LinearStream *);
3232
template void KernelOperation::ResourceCleaner::operator()<IndirectHeap>(IndirectHeap *);
3333

34+
static_assert(NEO::NonCopyableAndNonMovable<DecRefInternalAtScopeEnd<MemObj>>);
35+
3436
CommandMapUnmap::CommandMapUnmap(MapOperationType operationType, MemObj &memObj, MemObjSizeArray &copySize, MemObjOffsetArray &copyOffset, bool readOnly,
3537
CommandQueue &commandQueue)
3638
: Command(commandQueue), memObj(memObj), copySize(copySize), copyOffset(copyOffset), readOnly(readOnly), operationType(operationType) {

shared/source/command_stream/aub_command_stream_receiver_hw.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -79,9 +79,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
7979
const DeviceBitfield deviceBitfield);
8080
~AUBCommandStreamReceiverHw() override;
8181

82-
AUBCommandStreamReceiverHw(const AUBCommandStreamReceiverHw &) = delete;
83-
AUBCommandStreamReceiverHw &operator=(const AUBCommandStreamReceiverHw &) = delete;
84-
8582
MOCKABLE_VIRTUAL void openFile(const std::string &fileName);
8683
MOCKABLE_VIRTUAL bool reopenFile(const std::string &fileName);
8784
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);

shared/source/command_stream/command_stream_receiver.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "shared/source/helpers/common_types.h"
1616
#include "shared/source/helpers/completion_stamp.h"
1717
#include "shared/source/helpers/kmd_notify_properties.h"
18+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1819
#include "shared/source/helpers/options.h"
1920
#include "shared/source/memory_manager/graphics_allocation.h"
2021
#include "shared/source/utilities/spinlock.h"
@@ -78,7 +79,7 @@ enum class DispatchMode {
7879
batchedDispatch // dispatching is batched, explicit clFlush is required
7980
};
8081

81-
class CommandStreamReceiver {
82+
class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass {
8283
public:
8384
static constexpr size_t startingResidencyContainerSize = 128;
8485

@@ -93,8 +94,6 @@ class CommandStreamReceiver {
9394
CommandStreamReceiver(ExecutionEnvironment &executionEnvironment,
9495
uint32_t rootDeviceIndex,
9596
const DeviceBitfield deviceBitfield);
96-
CommandStreamReceiver(const CommandStreamReceiver &) = delete;
97-
CommandStreamReceiver &operator=(const CommandStreamReceiver &) = delete;
9897

9998
virtual ~CommandStreamReceiver();
10099

@@ -709,6 +708,8 @@ class CommandStreamReceiver {
709708
bool latestFlushIsTaskCountUpdateOnly = false;
710709
};
711710

711+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiver>);
712+
712713
typedef CommandStreamReceiver *(*CommandStreamReceiverCreateFunc)(bool withAubDump,
713714
ExecutionEnvironment &executionEnvironment,
714715
uint32_t rootDeviceIndex,

shared/source/command_stream/command_stream_receiver_with_aub_dump.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -27,9 +27,6 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR {
2727
uint32_t rootDeviceIndex,
2828
const DeviceBitfield deviceBitfield);
2929

30-
CommandStreamReceiverWithAUBDump(const CommandStreamReceiverWithAUBDump &) = delete;
31-
CommandStreamReceiverWithAUBDump &operator=(const CommandStreamReceiverWithAUBDump &) = delete;
32-
3330
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
3431
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
3532

shared/source/command_stream/submissions_aggregator.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "shared/source/command_container/cmdcontainer.h"
1010
#include "shared/source/command_stream/csr_definitions.h"
1111
#include "shared/source/command_stream/task_count_helper.h"
12+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1213
#include "shared/source/helpers/pipe_control_args.h"
1314
#include "shared/source/utilities/idlist.h"
1415

@@ -72,10 +73,8 @@ struct BatchBuffer {
7273
bool taskCountUpdateOnly = false;
7374
};
7475

75-
struct CommandBuffer : public IDNode<CommandBuffer> {
76+
struct CommandBuffer : public IDNode<CommandBuffer>, NEO::NonCopyableAndNonMovableClass {
7677
CommandBuffer(Device &device);
77-
CommandBuffer &operator=(const CommandBuffer &) = delete;
78-
CommandBuffer &operator=(CommandBuffer &&) = delete;
7978
~CommandBuffer() override;
8079
ResidencyContainer surfaces;
8180
BatchBuffer batchBuffer;
@@ -89,6 +88,8 @@ struct CommandBuffer : public IDNode<CommandBuffer> {
8988
Device &device;
9089
};
9190

91+
static_assert(NEO::NonCopyableAndNonMovable<CommandBuffer>);
92+
9293
struct CommandBufferList : public IDList<CommandBuffer, false, true, false> {};
9394

9495
using ResourcePackage = StackVec<GraphicsAllocation *, 128>;

shared/source/gen12lp/aub_command_stream_receiver_gen12lp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2022 Intel Corporation
2+
* Copyright (C) 2019-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -43,4 +43,5 @@ uint32_t AUBCommandStreamReceiverHw<Family>::getGUCWorkQueueItemHeader() {
4343
}
4444

4545
template class AUBCommandStreamReceiverHw<Family>;
46+
static_assert(NEO::NonCopyableAndNonMovable<NEO::AUBCommandStreamReceiverHw<Family>>);
4647
} // namespace NEO

shared/source/gen12lp/linux/command_stream_receiver_gen12lp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2023 Intel Corporation
2+
* Copyright (C) 2019-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -15,4 +15,5 @@ namespace NEO {
1515
template class DeviceCommandStreamReceiver<Gen12LpFamily>;
1616
template class DrmCommandStreamReceiver<Gen12LpFamily>;
1717
template class CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<Gen12LpFamily>>;
18+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<Gen12LpFamily>>>);
1819
} // namespace NEO

shared/source/gen12lp/tbx_command_stream_receiver_gen12lp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2022 Intel Corporation
2+
* Copyright (C) 2019-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -37,4 +37,5 @@ void populateFactoryTable<TbxCommandStreamReceiverHw<Family>>() {
3737

3838
template class TbxCommandStreamReceiverHw<Family>;
3939
template class CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<Family>>;
40+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<Family>>>);
4041
} // namespace NEO

shared/source/gen12lp/windows/command_stream_receiver_gen12lp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2022 Intel Corporation
2+
* Copyright (C) 2019-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -15,4 +15,5 @@ namespace NEO {
1515
template class DeviceCommandStreamReceiver<Gen12LpFamily>;
1616
template class WddmCommandStreamReceiver<Gen12LpFamily>;
1717
template class CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<Gen12LpFamily>>;
18+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<Gen12LpFamily>>>);
1819
} // namespace NEO

shared/source/memory_manager/deferrable_deletion.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* Copyright (C) 2020-2024 Intel Corporation
2+
* Copyright (C) 2020-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
9+
#include "shared/source/helpers/non_copyable_or_moveable.h"
910
#include "shared/source/utilities/idlist.h"
1011

1112
namespace NEO {
@@ -18,4 +19,6 @@ class DeferrableDeletion : public IDNode<DeferrableDeletion> {
1819
bool isExternalHostptr() const { return externalHostptr; }
1920
bool externalHostptr = false;
2021
};
22+
23+
static_assert(NEO::NonCopyableAndNonMovable<IDList<DeferrableDeletion>>);
2124
} // namespace NEO

shared/source/utilities/buffer_pool_allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct AbstractBuffersPool : public NonCopyableClass {
6161
AbstractBuffersPool(MemoryManager *memoryManager, OnChunkFreeCallback onChunkFreeCallback);
6262
AbstractBuffersPool(MemoryManager *memoryManager, OnChunkFreeCallback onChunkFreeCallback, const SmallBuffersParams &params);
6363
AbstractBuffersPool(AbstractBuffersPool<PoolT, BufferType, BufferParentType> &&bufferPool);
64-
AbstractBuffersPool &operator=(AbstractBuffersPool &&) = delete;
64+
AbstractBuffersPool &operator=(AbstractBuffersPool &&other) noexcept = delete;
6565
virtual ~AbstractBuffersPool() = default;
6666

6767
void tryFreeFromPoolBuffer(BufferParentType *possiblePoolBuffer, size_t offset, size_t size);

shared/source/utilities/idlist.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
#include "shared/source/helpers/debug_helpers.h"
11+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1112

1213
#include <atomic>
1314
#include <thread>
@@ -168,7 +169,7 @@ struct IDNode {
168169
};
169170

170171
template <typename NodeObjectType, bool threadSafe = true, bool ownsNodes = false, bool supportRecursiveLock = true>
171-
class IDList {
172+
class IDList : NEO::NonCopyableAndNonMovableClass {
172173
public:
173174
using ThisType = IDList<NodeObjectType, threadSafe, ownsNodes, supportRecursiveLock>;
174175

@@ -192,9 +193,6 @@ class IDList {
192193
this->cleanup();
193194
}
194195

195-
IDList(const IDList &) = delete;
196-
IDList &operator=(const IDList &) = delete;
197-
198196
void pushFrontOne(NodeObjectType &node) {
199197
processLocked<ThisType, &ThisType::pushFrontOneImpl>(&node);
200198
}

shared/source/utilities/iflist.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
#include "shared/source/helpers/mt_helpers.h"
11+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1112

1213
#include <atomic>
1314
#include <memory>
@@ -89,7 +90,7 @@ struct IFNode {
8990
};
9091

9192
template <typename NodeObjectType, bool threadSafe = true, bool ownsNodes = false>
92-
class IFList {
93+
class IFList : NEO::NonCopyableAndNonMovableClass {
9394
public:
9495
IFList()
9596
: head(nullptr) {
@@ -103,9 +104,6 @@ class IFList {
103104
this->cleanup();
104105
}
105106

106-
IFList(const IFList &) = delete;
107-
IFList &operator=(const IFList &) = delete;
108-
109107
template <bool c = threadSafe>
110108
typename std::enable_if<c, void>::type pushFrontOne(NodeObjectType &node) {
111109
node.next = head;

shared/source/utilities/reference_tracked_object.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (C) 2018-2022 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
99
#include "shared/source/helpers/debug_helpers.h"
10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1011

1112
#include <atomic>
1213
#include <memory>
@@ -169,7 +170,7 @@ inline ReferenceTrackedObject<DerivedClass>::~ReferenceTrackedObject() {
169170
}
170171

171172
template <typename RefTrackedObj>
172-
class DecRefInternalAtScopeEnd final {
173+
class DecRefInternalAtScopeEnd final : NEO::NonCopyableAndNonMovableClass {
173174
public:
174175
DecRefInternalAtScopeEnd(RefTrackedObj &obj) : object{obj} {
175176
}
@@ -178,11 +179,6 @@ class DecRefInternalAtScopeEnd final {
178179
object.decRefInternal();
179180
}
180181

181-
DecRefInternalAtScopeEnd(const DecRefInternalAtScopeEnd &) = delete;
182-
DecRefInternalAtScopeEnd(DecRefInternalAtScopeEnd &&) = delete;
183-
DecRefInternalAtScopeEnd &operator=(const DecRefInternalAtScopeEnd &) = delete;
184-
DecRefInternalAtScopeEnd &operator=(DecRefInternalAtScopeEnd &&) = delete;
185-
186182
private:
187183
RefTrackedObj &object;
188184
};

shared/source/xe2_hpg_core/aub_command_stream_receiver_xe2_hpg_core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -24,4 +24,5 @@ void populateFactoryTable<AUBCommandStreamReceiverHw<Family>>() {
2424
}
2525

2626
template class AUBCommandStreamReceiverHw<Family>;
27+
static_assert(NEO::NonCopyableAndNonMovable<AUBCommandStreamReceiverHw<Family>>);
2728
} // namespace NEO

shared/source/xe2_hpg_core/linux/command_stream_receiver_xe2_hpg_core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -15,4 +15,5 @@ namespace NEO {
1515
template class DeviceCommandStreamReceiver<Xe2HpgCoreFamily>;
1616
template class DrmCommandStreamReceiver<Xe2HpgCoreFamily>;
1717
template class CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<Xe2HpgCoreFamily>>;
18+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<Xe2HpgCoreFamily>>>);
1819
} // namespace NEO

shared/source/xe2_hpg_core/tbx_command_stream_receiver_xe2_hpg_core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -29,4 +29,5 @@ void populateFactoryTable<TbxCommandStreamReceiverHw<Family>>() {
2929

3030
template class TbxCommandStreamReceiverHw<Family>;
3131
template class CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<Family>>;
32+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<Family>>>);
3233
} // namespace NEO

shared/source/xe2_hpg_core/windows/command_stream_receiver_xe2_hpg_core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -15,4 +15,5 @@ namespace NEO {
1515
template class DeviceCommandStreamReceiver<Xe2HpgCoreFamily>;
1616
template class WddmCommandStreamReceiver<Xe2HpgCoreFamily>;
1717
template class CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<Xe2HpgCoreFamily>>;
18+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<Xe2HpgCoreFamily>>>);
1819
} // namespace NEO

shared/source/xe3_core/aub_command_stream_receiver_xe3_core.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ void populateFactoryTable<AUBCommandStreamReceiverHw<Family>>() {
2323
}
2424

2525
template class AUBCommandStreamReceiverHw<Family>;
26+
static_assert(NEO::NonCopyableAndNonMovable<AUBCommandStreamReceiverHw<Family>>);
2627
} // namespace NEO

shared/source/xe3_core/linux/command_stream_receiver_xe3_core.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ namespace NEO {
1515
template class DeviceCommandStreamReceiver<Xe3CoreFamily>;
1616
template class DrmCommandStreamReceiver<Xe3CoreFamily>;
1717
template class CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<Xe3CoreFamily>>;
18+
static_assert(NEO::NonCopyableAndNonMovable<CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<Xe3CoreFamily>>>);
1819
} // namespace NEO

0 commit comments

Comments
 (0)