Skip to content

Commit aabddb7

Browse files
authored
Merge pull request #22 from alibuild/alibot-cleanup-14117
Please consider the following formatting changes to #14117
2 parents 4b0825a + 497a9d4 commit aabddb7

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

Common/ML/src/OrtInterface.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void OrtModel::memoryOnDevice(int32_t deviceIndex)
143143
if (deviceIndex >= 0) {
144144
(pImplOrt->runOptions).AddConfigEntry("disable_synchronize_execution_providers", "1");
145145
(pImplOrt->sessionOptions).AddConfigEntry("session.use_device_allocator_for_initializers", "1"); // See kOrtSessionOptionsUseDeviceAllocatorForInitializers, https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
146-
(pImplOrt->sessionOptions).AddConfigEntry("session.use_env_allocators", "1"); // This should enable to use the volatile memory allocation defined in O2/GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.cxx; not working yet: ONNX still assigns new memory at init time
146+
(pImplOrt->sessionOptions).AddConfigEntry("session.use_env_allocators", "1"); // This should enable to use the volatile memory allocation defined in O2/GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.cxx; not working yet: ONNX still assigns new memory at init time
147147

148148
// Arena memory shrinkage comes at performance cost
149149
/// For now prefer to use single allocation, enabled by O2/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu -> SetONNXGPUStream -> rocm_options.arena_extend_strategy = 0;

GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void GPUReconstructionHIP::SetONNXGPUStream(Ort::SessionOptions& session_options
699699
// api.GetCurrentGpuDeviceId(deviceId);
700700
OrtROCMProviderOptions rocm_options;
701701
rocm_options.has_user_compute_stream = 1; // Indicate that we are passing a user stream
702-
rocm_options.arena_extend_strategy = 0; // kNextPowerOfTwo = 0, kSameAsRequested = 1 -> https://github.com/search?q=repo%3Amicrosoft%2Fonnxruntime%20kSameAsRequested&type=code
702+
rocm_options.arena_extend_strategy = 0; // kNextPowerOfTwo = 0, kSameAsRequested = 1 -> https://github.com/search?q=repo%3Amicrosoft%2Fonnxruntime%20kSameAsRequested&type=code
703703
rocm_options.user_compute_stream = mInternals->Streams[stream];
704704
session_options.AppendExecutionProvider_ROCM(rocm_options);
705705
#endif // ORT_ROCM_BUILD

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.cxx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct MockedOrtAllocator : OrtAllocator {
125125

126126
void LeakCheck();
127127

128-
private:
128+
private:
129129
MockedOrtAllocator(const MockedOrtAllocator&) = delete;
130130
MockedOrtAllocator& operator=(const MockedOrtAllocator&) = delete;
131131

@@ -136,7 +136,8 @@ struct MockedOrtAllocator : OrtAllocator {
136136
GPUReconstruction* rec;
137137
};
138138

139-
MockedOrtAllocator::MockedOrtAllocator(GPUReconstruction* r, OrtMemoryInfo* info) {
139+
MockedOrtAllocator::MockedOrtAllocator(GPUReconstruction* r, OrtMemoryInfo* info)
140+
{
140141
OrtAllocator::version = ORT_API_VERSION;
141142
OrtAllocator::Alloc = [](OrtAllocator* this_, size_t size) { return static_cast<MockedOrtAllocator*>(this_)->Alloc(size); };
142143
OrtAllocator::Free = [](OrtAllocator* this_, void* p) { static_cast<MockedOrtAllocator*>(this_)->Free(p); };
@@ -146,42 +147,50 @@ MockedOrtAllocator::MockedOrtAllocator(GPUReconstruction* r, OrtMemoryInfo* info
146147
memory_info = info;
147148
}
148149

149-
MockedOrtAllocator::~MockedOrtAllocator() {
150+
MockedOrtAllocator::~MockedOrtAllocator()
151+
{
150152
// Ort::GetApi().ReleaseMemoryInfo(memory_info);
151153
}
152154

153-
void* MockedOrtAllocator::Alloc(size_t size) {
155+
void* MockedOrtAllocator::Alloc(size_t size)
156+
{
154157
return rec->AllocateVolatileDeviceMemory(size);
155158
}
156159

157-
void* MockedOrtAllocator::Reserve(size_t size) {
160+
void* MockedOrtAllocator::Reserve(size_t size)
161+
{
158162
return rec->AllocateVolatileDeviceMemory(size);
159163
}
160164

161-
void MockedOrtAllocator::Free(void* p) {
165+
void MockedOrtAllocator::Free(void* p)
166+
{
162167
rec->ReturnVolatileDeviceMemory();
163168
}
164169

165-
const OrtMemoryInfo* MockedOrtAllocator::Info() const {
170+
const OrtMemoryInfo* MockedOrtAllocator::Info() const
171+
{
166172
return memory_info;
167173
}
168174

169-
size_t MockedOrtAllocator::NumAllocations() const {
175+
size_t MockedOrtAllocator::NumAllocations() const
176+
{
170177
return num_allocations.load();
171178
}
172179

173-
size_t MockedOrtAllocator::NumReserveAllocations() const {
180+
size_t MockedOrtAllocator::NumReserveAllocations() const
181+
{
174182
return num_reserve_allocations.load();
175183
}
176184

177-
void MockedOrtAllocator::LeakCheck() {
185+
void MockedOrtAllocator::LeakCheck()
186+
{
178187
if (memory_inuse.load())
179188
LOG(warning) << "memory leak!!!";
180189
}
181190

182191
void GPUTPCNNClusterizerHost::volatileOrtAllocator(Ort::Env* env, Ort::MemoryInfo* memInfo, GPUReconstruction* rec, int32_t chooseMockedAlloc)
183192
{
184-
if(chooseMockedAlloc == 0) {
193+
if (chooseMockedAlloc == 0) {
185194
mockedAlloc_class = std::make_shared<MockedOrtAllocator>(rec, (OrtMemoryInfo*)memInfo);
186195
Ort::GetApi().RegisterAllocator((OrtEnv*)(*env), mockedAlloc_class.get());
187196
LOG(info) << "(ORT) Mocked ORT allocator for classification network registered";

0 commit comments

Comments
 (0)