MCPcopy Create free account
hub / github.com/KomputeProject/kompute / destroy

Method destroy

src/Manager.cpp:78–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void
79Manager::destroy()
80{
81
82 KP_LOG_DEBUG("Kompute Manager destroy() started");
83
84 if (this->mDevice == nullptr) {
85 KP_LOG_ERROR(
86 "Kompute Manager destructor reached with null Device pointer");
87 return;
88 }
89
90 if (this->mManageResources && this->mManagedSequences.size()) {
91 KP_LOG_DEBUG("Kompute Manager explicitly running destructor for "
92 "managed sequences");
93 for (const std::weak_ptr<Sequence>& weakSq : this->mManagedSequences) {
94 if (std::shared_ptr<Sequence> sq = weakSq.lock()) {
95 sq->destroy();
96 }
97 }
98 this->mManagedSequences.clear();
99 }
100
101 if (this->mManageResources && this->mManagedAlgorithms.size()) {
102 KP_LOG_DEBUG("Kompute Manager explicitly freeing algorithms");
103 for (const std::weak_ptr<Algorithm>& weakAlgorithm :
104 this->mManagedAlgorithms) {
105 if (std::shared_ptr<Algorithm> algorithm = weakAlgorithm.lock()) {
106 algorithm->destroy();
107 }
108 }
109 this->mManagedAlgorithms.clear();
110 }
111
112 if (this->mManageResources && this->mManagedTensors.size()) {
113 KP_LOG_DEBUG("Kompute Manager explicitly freeing tensors");
114 for (const std::weak_ptr<Tensor>& weakTensor : this->mManagedTensors) {
115 if (std::shared_ptr<Tensor> tensor = weakTensor.lock()) {
116 tensor->destroy();
117 }
118 }
119 this->mManagedTensors.clear();
120 }
121
122 if (this->mFreeDevice) {
123 KP_LOG_INFO("Destroying device");
124 this->mDevice->destroy(
125 (vk::Optional<const vk::AllocationCallbacks>)nullptr);
126 this->mDevice = nullptr;
127 KP_LOG_DEBUG("Kompute Manager Destroyed Device");
128 }
129
130 if (this->mInstance == nullptr) {
131 KP_LOG_ERROR(
132 "Kompute Manager destructor reached with null Instance pointer");
133 return;
134 }
135

Callers 2

~ManagerMethod · 0.95

Calls 2

sizeMethod · 0.80
clearMethod · 0.45

Tested by 1