Announcement

Collapse
No announcement yet.

Experimental read_ati_extension patch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Experimental read_ati_extension patch

    This patch is experimental as it's based on undocumented (officially) functions in aticonfig, however it should work fine on any HD series ATI card.
    The arguments to aticonfig were obtained from here: http://www.phoronix.com/forums/showp...2&postcount=18

    This patch will read the GPU temp, current 3D clock and default 3D clock (there's all sorts of other info it could read, but let's start simple).

    Code:
    diff --git a/pts-core/functions/pts-functions_system_graphics.php b/pts-core/functions/pts-functions_system_graphics.php
    index 84de190..fa1c696 100644
    --- a/pts-core/functions/pts-functions_system_graphics.php
    +++ b/pts-core/functions/pts-functions_system_graphics.php
    @@ -26,10 +26,15 @@ function pts_record_gpu_temperature()
     }
     function graphics_processor_temperature()
     {
    -       $temp_c = read_nvidia_extension("GPUCoreTemp");
    +       $temp_c = -1;
    
    -       if(empty($temp_c))
    -               $temp_c = -1;
    +       $nv_temp_c = read_nvidia_extension("GPUCoreTemp");
    +       $ati_temp_c = read_ati_extension("CoreTemperature");
    +
    +       if(!empty($nv_temp_c))
    +               $temp_c = $nv_temp_c;
    +       elseif(!empty($ati_temp_c))
    +               $temp_c = $ati_temp_c;
    
            return $temp_c;
     }
    @@ -145,13 +150,20 @@ function graphics_processor_stock_frequency()
            $core_freq = 0;
            $mem_freq = 0;
    
    -       $freq = read_nvidia_extension("GPUDefault3DClockFreqs");
    +       $nvfreq = read_nvidia_extension("GPUDefault3DClockFreqs");
    +       $atifreq = read_ati_extension("Stock3DFrequencies");
    
    -       if(!empty($freq)) // NVIDIA GPU
    +       if(!empty($nvfreq)) // NVIDIA GPU
    +       {
    +               $nvfreq = explode(',', $nvfreq);
    +               $core_freq = $nvfreq[0];
    +               $mem_freq = $nvfreq[1];
    +       }
    +       elseif(!empty($atifreq)) // ATI GPU
            {
    -               $freq = explode(',', $freq);
    -               $core_freq = $freq[0];
    -               $mem_freq = $freq[1];
    +               $atifreq = explode(',', $atifreq);
    +               $core_freq = $atifreq[0];
    +               $mem_freq = $atifreq[1];
            }
    
            return array($core_freq, $mem_freq);
    @@ -161,13 +173,20 @@ function graphics_processor_frequency()
            $core_freq = 0;
            $mem_freq = 0;
    
    -       $freq = read_nvidia_extension("GPUCurrentClockFreqs");
    +       $nvfreq = read_nvidia_extension("GPUCurrentClockFreqs");
    +       $atifreq = read_ati_extension("Current3DFrequencies");
    
    -       if(!empty($freq)) // NVIDIA GPU
    +       if(!empty($nvfreq)) // NVIDIA GPU
    +       {
    +               $nvfreq = explode(',', $nvfreq);
    +               $core_freq = $nvfreq[0];
    +               $mem_freq = $nvfreq[1];
    +       }
    +       elseif(!empty($atifreq)) // ATI GPU
            {
    -               $freq = explode(',', $freq);
    -               $core_freq = $freq[0];
    -               $mem_freq = $freq[1];
    +               $atifreq = explode(',', $atifreq);
    +               $core_freq = $atifreq[0];
    +               $mem_freq = $atifreq[1];
            }
    
            return array($core_freq, $mem_freq);
    diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php
    index 1d0cb7f..75197b0 100644
    --- a/pts-core/functions/pts-functions_system_parsing.php
    +++ b/pts-core/functions/pts-functions_system_parsing.php
    @@ -159,5 +159,50 @@ function read_nvidia_extension($attribute)
    
            return $nv_info;
     }
    +function read_ati_extension($attribute)
    +{
    +       $ati_info = "";
    +
    +       //mangler to get correct info out of aticonfig
    +       if("CoreTemperature" == $attribute)
    +       {
    +                       $info = shell_exec("aticonfig --pplib-cmd \"get temperature 0\" 2>&1");
    +                       if(($pos = strpos($info, "thermal")) > 0)
    +                       {
    +                               $ati_info = substr($info, strpos($info, "is") + 3);
    +                               $ati_info = substr($ati_info, 0, strpos($ati_info, "\n"));
    +                               $ati_info = trim(substr($ati_info, 0, strrpos($ati_info, ".")));
    +                       }
    +       }
    +       elseif("Stock3DFrequencies" == $attribute)
    +       {
    +                       $info = shell_exec("aticonfig --pplib-cmd \"get clock\" 2>&1");
    +                       if(($pos = strpos($info, "Engine")) > 0)
    +                       {
    +                               $core_info = substr($info, strpos($info, "-") + 2);
    +                               $core_info = substr($core_info, 0, strpos($core_info, " "));
    +                               $mem_info = substr($info, strpos($info, "Memory Clock"));
    +                               $mem_info = substr($mem_info, strpos($mem_info, "-") + 2);
    +                               $mem_info = trim(substr($mem_info, 0, strpos($mem_info, " ")));
    +                               $ati_info = $core_info . "," . $mem_info;
    +                       }
    +       }
    +       elseif("Current3DFrequencies" == $attribute)
    +       {
    +                       $info = shell_exec("aticonfig --pplib-cmd \"get activity\" 2>&1");
    +                       if(($pos = strpos($info, "Activity")) > 0)
    +                       {
    +                               $core_info = substr($info, strpos($info, "Core Clock:") + 12);
    +                               $core_info = substr($core_info, 0, strpos($core_info, "\n"));
    +                               $core_info = trim(substr($core_info, 0, strrpos($core_info, "MHZ")));
    +                               $mem_info = substr($info, strpos($info, "Memory Clock:") + 14);
    +                               $mem_info = substr($mem_info, 0, strpos($mem_info, "\n"));
    +                               $mem_info = trim(substr($mem_info, 0, strrpos($mem_info, "MHZ")));
    +                               $ati_info = $core_info . "," . $mem_info;
    +                       }
    +       }
    +
    +       return $ati_info;
    +}
    
     ?>
    I now get my 2D clocks reported in system-info:
    [uncle_fungus@Gecko phoronix-test-suite]$ ./phoronix-test-suite system-info

    ======================================
    Phoronix Test Suite v0.6.0 (TRONDHEIM)
    System Information
    ======================================

    Hardware:
    Processor: Intel Core 2 Quad CPU Q6600 @ 2.39GHz (Total Cores: 4), Motherboard: Unknown, Chipset: Intel 82G33/G31/P35/P31, System Memory: 7999MB, Disk Space: 10GB, Graphics: ATI Radeon HD 3870 (300/1126MHz), Screen Resolution: 3360x1050

    Software:
    OS: MandrivaLinux 2008.1, Kernel: 2.6.24.4-server-1mnb (x86_64), X.Org Server: 1.4.0.90, OpenGL: 2.1.7412 (fglrx), Compiler: GCC 4.2.3
    GPU temp from sensors (not lm_sensors )
    [uncle_fungus@Gecko phoronix-test-suite]$ MONITOR=all ./phoronix-test-suite sensors

    ====================================
    Current Sensor Readings:

    GPU Thermal Monitor: 44 ?C
    CPU Thermal Monitor: 40.0 ?C
    System Thermal Monitor: 37.0 ?C
    CPU Voltage Monitor: 1.13 Volts
    ====================================

  • #2
    Thanks, just committed though please test as I won't be back in my office until next week (with R600 hardware) and I quickly changed a few things in it to clean it up.

    I have been informed by AMD that this patch will only work with R600 hardware and that it will break in the future (hopefully when delivering a solid implementation).
    Michael Larabel
    https://www.michaellarabel.com/

    Comment


    • #3
      I thought as much, but at least this should work in the interim.

      I'll test the committed code just a soon as git will let me pull down the changes.

      Comment

      Working...
      X