@@ -242,7 +242,7 @@ func CalculateTotalUsagePtr(records []*ResourceUsageRecord, targetJobID int64) (
242
242
}
243
243
}
244
244
totalCPUUseS = float64 (totalCPUUseNs ) / 1e9
245
- totalMemMb = float64 (totalMemoryByte ) / ( 1024 * 1024 )
245
+ totalMemMb = util . FormatMemToMB (totalMemoryByte )
246
246
247
247
return totalCPUUseS , totalMemMb , nil
248
248
}
@@ -333,9 +333,6 @@ func PrintTaskInfo(taskInfo *protos.TaskInfo, records []*ResourceUsageRecord) er
333
333
fmt .Printf ("JobState: %v (exit code %d)\n " , taskInfo .Status .String (), taskInfo .ExitCode )
334
334
}
335
335
336
- if taskInfo .NodeNum == 0 {
337
- return fmt .Errorf ("the number of nodes is empty" )
338
- }
339
336
cpuTotal := taskInfo .AllocatedResView .AllocatableRes .CpuCoreLimit * float64 (taskInfo .NodeNum )
340
337
if math .Abs (cpuTotal - 1 ) < 1e-9 {
341
338
fmt .Printf ("Cores: %.2f\n " , cpuTotal )
@@ -364,7 +361,7 @@ func PrintTaskInfo(taskInfo *protos.TaskInfo, records []*ResourceUsageRecord) er
364
361
365
362
// Calculate mem efficiency
366
363
memEfficiency := 0.0
367
- mallocMemMbPerNode := float64 (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes ) / ( 1024 * 1024 )
364
+ mallocMemMbPerNode := util . FormatMemToMB (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes )
368
365
totalMallocMemMb := mallocMemMbPerNode * float64 (taskInfo .NodeNum )
369
366
if totalMallocMemMb != 0 {
370
367
memEfficiency = totalMemMb / totalMallocMemMb * 100
@@ -433,7 +430,7 @@ func PrintTaskInfoInJson(taskInfo *protos.TaskInfo, records []*ResourceUsageReco
433
430
434
431
// Calculate mem efficiency
435
432
memEfficiency := 0.0
436
- mallocMemMbPerNode := float64 (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes ) / ( 1024 * 1024 )
433
+ mallocMemMbPerNode := util . FormatMemToMB (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes )
437
434
totalMallocMemMb := mallocMemMbPerNode * float64 (taskInfo .NodeNum )
438
435
if totalMallocMemMb != 0 {
439
436
memEfficiency = totalMemMb / totalMallocMemMb * 100
0 commit comments