Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit e35584d

Browse files
committed
Add getTotalMem GpuMgr method
1 parent 5073f8b commit e35584d

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

omniscidb/CudaMgr/CudaMgr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ class CudaMgr : public GpuMgr {
151151
bool isArchMaxwellOrLaterForAll() const;
152152
bool isArchVoltaOrGreaterForAll() const;
153153

154+
size_t getTotalMem(const int device_num) const {
155+
return getDeviceProperties(device_num)->globalMem;
156+
}
157+
154158
uint32_t getMaxBlockSize() const override {
155159
return getAllDeviceProperties().front().maxThreadsPerBlock;
156160
}

omniscidb/DataMgr/DataMgr.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,19 +282,9 @@ void DataMgr::populateMgrs(const Config& config,
282282
int num_gpus = mgr->getDeviceCount();
283283
device_context->gpu_count = num_gpus;
284284
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);
298288
}
299289

300290
size_t gpu_max_mem_size = config.mem.gpu.max_size;

omniscidb/DataMgr/GpuMgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct GpuMgr {
5757
virtual void synchronizeDevices() const = 0;
5858
virtual int getDeviceCount() const = 0;
5959
virtual GpuMgrPlatform getPlatform() const = 0;
60+
virtual size_t getTotalMem(const int device_num) const = 0;
6061
virtual uint32_t getMaxBlockSize() const = 0;
6162
virtual int8_t getSubGroupSize() const = 0;
6263
virtual uint32_t getGridSize() const = 0;

omniscidb/L0Mgr/L0Mgr.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,20 @@ size_t L0Manager::getMaxAllocationSize(const int device_num) const {
419419
return device_properties.maxMemAllocSize;
420420
}
421421

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+
422436
uint32_t L0Manager::getMaxBlockSize() const {
423437
CHECK_GT(drivers_[0]->devices().size(), size_t(0));
424438
unsigned sz = drivers_[0]->devices()[0]->maxGroupSize();

omniscidb/L0Mgr/L0Mgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class L0Manager : public GpuMgr {
237237
};
238238

239239
size_t getMaxAllocationSize(const int device_num) const;
240+
size_t getTotalMem(const int device_num) const override;
240241
size_t getPageSize(const int device_num) const { return 4096u; }
241242

242243
uint32_t getMaxBlockSize() const override;

omniscidb/L0Mgr/L0MgrNoL0.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ size_t L0Manager::getMaxAllocationSize(const int device_num) const {
118118
return 0u;
119119
}
120120

121+
size_t L0Manager::getTotalMem(const int device_num) const {
122+
CHECK(false);
123+
return 0u;
124+
}
125+
121126
unsigned L0Manager::getMaxBlockSize() const {
122127
CHECK(false);
123128
return 0u;

0 commit comments

Comments
 (0)