@@ -333,14 +333,17 @@ 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
- cpuTotal := taskInfo .AllocatedResView .AllocatableRes .CpuCoreLimit * float64 (taskInfo .NodeNum )
336
+ if taskInfo .NodeNum == 0 {
337
+ return fmt .Errorf ("the number of nodes is empty" )
338
+ }
339
+ cpuTotal := taskInfo .AllocatedResView .AllocatableRes .CpuCoreLimit
337
340
if math .Abs (cpuTotal - 1 ) < 1e-9 {
338
341
fmt .Printf ("Cores: %.2f\n " , cpuTotal )
339
342
} else {
340
343
fmt .Printf (
341
344
"Nodes: %v\n " +
342
345
"Cores per node: %.2f\n " ,
343
- taskInfo .NodeNum , taskInfo .AllocatedResView . AllocatableRes . CpuCoreLimit )
346
+ taskInfo .NodeNum , cpuTotal / float64 ( taskInfo .NodeNum ) )
344
347
}
345
348
346
349
if taskInfo .Status == protos .TaskStatus_Pending {
@@ -361,8 +364,9 @@ func PrintTaskInfo(taskInfo *protos.TaskInfo, records []*ResourceUsageRecord) er
361
364
362
365
// Calculate mem efficiency
363
366
memEfficiency := 0.0
364
- mallocMemMbPerNode := float64 (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes ) / (1024 * 1024 )
365
- totalMallocMemMb := mallocMemMbPerNode * float64 (taskInfo .NodeNum )
367
+ mallocMemMbPerNode := float64 (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes ) /
368
+ float64 (taskInfo .NodeNum ) / (1024 * 1024 )
369
+ totalMallocMemMb := float64 (taskInfo .ReqResView .AllocatableRes .MemoryLimitBytes )
366
370
if totalMallocMemMb != 0 {
367
371
memEfficiency = totalMemMb / totalMallocMemMb * 100
368
372
}
@@ -398,7 +402,11 @@ func PrintTaskInfoInJson(taskInfo *protos.TaskInfo, records []*ResourceUsageReco
398
402
return nil , fmt .Errorf ("failed to get groupname for GID %d: %w" , taskInfo .Gid , err )
399
403
}
400
404
401
- cpuTotal := taskInfo .AllocatedResView .AllocatableRes .CpuCoreLimit * float64 (taskInfo .NodeNum )
405
+ if taskInfo .NodeNum == 0 {
406
+ return nil , fmt .Errorf ("the number of nodes is empty" )
407
+ }
408
+ cpuTotal := taskInfo .AllocatedResView .AllocatableRes .CpuCoreLimit
409
+ coresPerNode := cpuTotal / float64 (taskInfo .NodeNum )
402
410
taskJsonInfo := & CeffTaskInfo {
403
411
JobID : taskInfo .TaskId ,
404
412
QoS : taskInfo .Qos ,
@@ -409,7 +417,7 @@ func PrintTaskInfoInJson(taskInfo *protos.TaskInfo, records []*ResourceUsageReco
409
417
Account : taskInfo .Account ,
410
418
JobState : taskInfo .Status ,
411
419
Nodes : taskInfo .NodeNum ,
412
- CoresPerNode : taskInfo . AllocatedResView . AllocatableRes . CpuCoreLimit ,
420
+ CoresPerNode : coresPerNode ,
413
421
}
414
422
415
423
if taskInfo .Status == protos .TaskStatus_Pending {
@@ -430,8 +438,9 @@ func PrintTaskInfoInJson(taskInfo *protos.TaskInfo, records []*ResourceUsageReco
430
438
431
439
// Calculate mem efficiency
432
440
memEfficiency := 0.0
433
- mallocMemMbPerNode := float64 (taskInfo .AllocatedResView .AllocatableRes .MemoryLimitBytes ) / (1024 * 1024 )
434
- totalMallocMemMb := mallocMemMbPerNode * float64 (taskInfo .NodeNum )
441
+ mallocMemMbPerNode := float64 (taskInfo .ReqResView .AllocatableRes .MemoryLimitBytes ) /
442
+ float64 (taskInfo .NodeNum ) / (1024 * 1024 )
443
+ totalMallocMemMb := float64 (taskInfo .ReqResView .AllocatableRes .MemoryLimitBytes )
435
444
if totalMallocMemMb != 0 {
436
445
memEfficiency = totalMemMb / totalMallocMemMb * 100
437
446
}
0 commit comments