File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1186,6 +1186,22 @@ string CUDADevice::query(luisa::string_view property) noexcept {
11861186 if (property == " device_name" ) {
11871187 return " cuda" ;
11881188 }
1189+ if (property == " total_memory" ) {
1190+ string memory = " 0" ;
1191+ with_handle ([&memory]{
1192+ size_t free_mem, total_mem;
1193+ cuMemGetInfo (&free_mem, &total_mem);
1194+ memory = to_string (total_mem);
1195+ });
1196+ return memory;
1197+ }
1198+ if (property == " free_memory" ) {
1199+ string memory = " 0" ;
1200+ with_handle ([&memory]{
1201+ size_t free_mem, total_mem;
1202+ cuMemGetInfo (&free_mem, &total_mem);
1203+ memory = to_string (free_mem);
1204+ });
11891205 LUISA_WARNING_WITH_LOCATION (" Unknown device property '{}'." , property);
11901206 return {};
11911207}
Original file line number Diff line number Diff line change @@ -670,6 +670,17 @@ void MetalDevice::destroy_accel(uint64_t handle) noexcept {
670670}
671671
672672string MetalDevice::query (luisa::string_view property) noexcept {
673+
674+ if (property == " total_memory" ) {
675+ string memory = " 0" ;
676+ memory = std::to_string (_handle->recommendedMaxWorkingSetSize ());
677+ return memory;
678+ }
679+ if (property == " free_memory" ) {
680+ string memory = " 0" ;
681+ memory = std::to_string (_handle->recommendedMaxWorkingSetSize ());
682+ return memory;
683+ }
673684 LUISA_WARNING_WITH_LOCATION (" Device property \" {}\" is not supported on Metal." , property);
674685 return {};
675686}
You can’t perform that action at this time.
0 commit comments