Skip to content

Commit 0a8d0f2

Browse files
simplify cuda get mem info
1 parent 6140464 commit 0a8d0f2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/backends/cuda/cuda_device.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,22 +1187,18 @@ string CUDADevice::query(luisa::string_view property) noexcept {
11871187
return "cuda";
11881188
}
11891189
if (property == "total_memory") {
1190-
string memory = "0";
1191-
with_handle([&memory]{
1190+
return with_handle([]{
11921191
size_t free_mem, total_mem;
11931192
cuMemGetInfo(&free_mem, &total_mem);
1194-
memory = std::to_string(total_mem);
1193+
return std::to_string(total_mem);
11951194
});
1196-
return memory;
11971195
}
11981196
if (property == "free_memory") {
1199-
string memory = "0";
1200-
with_handle([&memory]{
1197+
return with_handle([]{
12011198
size_t free_mem, total_mem;
12021199
cuMemGetInfo(&free_mem, &total_mem);
1203-
memory = std::to_string(free_mem);
1200+
return std::to_string(free_mem);
12041201
});
1205-
return memory;
12061202
}
12071203
LUISA_WARNING_WITH_LOCATION("Unknown device property '{}'.", property);
12081204
return {};

0 commit comments

Comments
 (0)