Skip to content

Commit

Permalink
Merge pull request #78 from joular/77-incorrect-power-value-when-mult…
Browse files Browse the repository at this point in the history
…iple-nvidia-gpus-present

Fix Nvidia GPU power calculations with multiple Nvidia GPUs
  • Loading branch information
adelnoureddine authored Jan 27, 2025
2 parents b0b72dd + 3377617 commit f9cdfb0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/nvidia_smi.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package body Nvidia_SMI is
Args : Argument_List_Access;
Status : aliased Integer;
Subs : String_Split.Slice_Set; -- Used to slice the read data from stat file
Seps : constant String := CR & LF; -- Seperator (space) for slicing string
Seps : constant String := CR & LF; -- Seperator (line return) for slicing string
Slice_number_count : String_Split.Slice_Number;
GPU_Energy : Long_Float := 0.0;
begin
Expand All @@ -41,13 +41,13 @@ package body Nvidia_SMI is
else
String_Split.Create (S => Subs, -- Store sliced data in Subs
From => Response, -- Read data to slice
Separators => Seps, -- Separator (here space)
Separators => Seps, -- Separator (here line return)
Mode => String_Split.Multiple);

Slice_number_count := String_Split.Slice_Count (Subs);

for I in 1 .. Slice_number_count loop
GPU_Energy := GPU_Energy + Long_Float'Value (String_Split.Slice (Subs, 1));
GPU_Energy := GPU_Energy + Long_Float'Value (String_Split.Slice (Subs, I));
end loop;

return GPU_Energy;
Expand Down

0 comments on commit f9cdfb0

Please sign in to comment.