This repository was archived by the owner on May 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +28
-13
lines changed Expand file tree Collapse file tree 6 files changed +28
-13
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ class CudaMgr : public GpuMgr {
151
151
bool isArchMaxwellOrLaterForAll () const ;
152
152
bool isArchVoltaOrGreaterForAll () const ;
153
153
154
+ size_t getTotalMem (const int device_num) const {
155
+ return getDeviceProperties (device_num)->globalMem ;
156
+ }
157
+
154
158
uint32_t getMaxBlockSize () const override {
155
159
return getAllDeviceProperties ().front ().maxThreadsPerBlock ;
156
160
}
Original file line number Diff line number Diff line change @@ -282,19 +282,9 @@ void DataMgr::populateMgrs(const Config& config,
282
282
int num_gpus = mgr->getDeviceCount ();
283
283
device_context->gpu_count = num_gpus;
284
284
for (int gpu_num = 0 ; gpu_num < num_gpus; ++gpu_num) {
285
- size_t device_mem_size = 0 ;
286
- // TODO: get rid of manager-specific branches by introducing some kind of device
287
- // properties in GpuMgr
288
- switch (p) {
289
- case GpuMgrPlatform::CUDA:
290
- device_mem_size = getCudaMgr ()->getDeviceProperties (gpu_num)->globalMem ;
291
- break ;
292
- case GpuMgrPlatform::L0:
293
- device_mem_size = getL0Mgr ()->getMaxAllocationSize (gpu_num);
294
- page_size = getL0Mgr ()->getPageSize (gpu_num);
295
- break ;
296
- default :
297
- CHECK (false );
285
+ size_t device_mem_size = mgr->getTotalMem (gpu_num);
286
+ if (p == GpuMgrPlatform::L0) {
287
+ page_size = getL0Mgr ()->getPageSize (gpu_num);
298
288
}
299
289
300
290
size_t gpu_max_mem_size = config.mem .gpu .max_size ;
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ struct GpuMgr {
57
57
virtual void synchronizeDevices () const = 0;
58
58
virtual int getDeviceCount () const = 0;
59
59
virtual GpuMgrPlatform getPlatform () const = 0;
60
+ virtual size_t getTotalMem (const int device_num) const = 0;
60
61
virtual uint32_t getMaxBlockSize () const = 0;
61
62
virtual int8_t getSubGroupSize () const = 0;
62
63
virtual uint32_t getGridSize () const = 0;
Original file line number Diff line number Diff line change @@ -419,6 +419,20 @@ size_t L0Manager::getMaxAllocationSize(const int device_num) const {
419
419
return device_properties.maxMemAllocSize ;
420
420
}
421
421
422
+ size_t L0Manager::getTotalMem (const int device_num) const {
423
+ CHECK_GE (device_num, 0 );
424
+ CHECK_LT (device_num, drivers_[0 ]->devices ().size ());
425
+ uint32_t p_count{0 };
426
+ L0_SAFE_CALL (zeDeviceGetMemoryProperties (
427
+ drivers_[0 ]->devices ()[device_num]->device (), &p_count, nullptr ));
428
+ CHECK_GT (p_count, 0u );
429
+ std::vector<ze_device_memory_properties_t > mem_properties;
430
+ mem_properties.resize (p_count);
431
+ L0_SAFE_CALL (zeDeviceGetMemoryProperties (
432
+ drivers_[0 ]->devices ()[device_num]->device (), &p_count, mem_properties.data ()));
433
+ return static_cast <size_t >(mem_properties[0 ].totalSize );
434
+ }
435
+
422
436
uint32_t L0Manager::getMaxBlockSize () const {
423
437
CHECK_GT (drivers_[0 ]->devices ().size (), size_t (0 ));
424
438
unsigned sz = drivers_[0 ]->devices ()[0 ]->maxGroupSize ();
Original file line number Diff line number Diff line change @@ -237,6 +237,7 @@ class L0Manager : public GpuMgr {
237
237
};
238
238
239
239
size_t getMaxAllocationSize (const int device_num) const ;
240
+ size_t getTotalMem (const int device_num) const override ;
240
241
size_t getPageSize (const int device_num) const { return 4096u ; }
241
242
242
243
uint32_t getMaxBlockSize () const override ;
Original file line number Diff line number Diff line change @@ -118,6 +118,11 @@ size_t L0Manager::getMaxAllocationSize(const int device_num) const {
118
118
return 0u ;
119
119
}
120
120
121
+ size_t L0Manager::getTotalMem (const int device_num) const {
122
+ CHECK (false );
123
+ return 0u ;
124
+ }
125
+
121
126
unsigned L0Manager::getMaxBlockSize () const {
122
127
CHECK (false );
123
128
return 0u ;
You can’t perform that action at this time.
0 commit comments