How to use gpu_model method of phodevi_gpu class

Best Phoronix-test-suite code snippet using phodevi_gpu.gpu_model

phodevi_gpu.php

Source:phodevi_gpu.php Github

copy

Full Screen

...25 case 'identifier':26 $property = new phodevi_device_property('gpu_string', phodevi::std_caching);27 break;28 case 'model':29 $property = new phodevi_device_property('gpu_model', phodevi::smart_caching);30 break;31 case 'frequency':32 $property = new phodevi_device_property('gpu_frequency_string', phodevi::std_caching);33 break;34 case 'stock-frequency':35 $property = new phodevi_device_property('gpu_stock_frequency', phodevi::std_caching);36 break;37 case 'memory-capacity':38 $property = new phodevi_device_property('gpu_memory_size', phodevi::smart_caching);39 break;40 case 'oc-offset-string':41 $property = new phodevi_device_property('gpu_oc_offset_string', phodevi::no_caching);42 break;43 case 'aa-level':44 $property = new phodevi_device_property('gpu_aa_level', phodevi::no_caching);45 break;46 case 'af-level':47 $property = new phodevi_device_property('gpu_af_level', phodevi::no_caching);48 break;49 case 'compute-cores':50 $property = new phodevi_device_property('gpu_compute_cores', phodevi::smart_caching);51 break;52 case 'available-modes':53 $property = new phodevi_device_property('gpu_available_modes', phodevi::std_caching);54 break;55 case 'screen-resolution':56 $property = new phodevi_device_property('gpu_screen_resolution', phodevi::std_caching);57 break;58 case 'screen-resolution-string':59 $property = new phodevi_device_property('gpu_screen_resolution_string', phodevi::std_caching);60 break;61 case '2d-acceleration':62 $property = new phodevi_device_property('gpu_2d_acceleration', phodevi::std_caching);63 break;64 }65 return $property;66 }67 public static function gpu_2d_acceleration()68 {69 $xorg_log = isset(phodevi::$vfs->xorg_log) ? phodevi::$vfs->xorg_log : false;70 $accel_2d = false;71 if($xorg_log)72 {73 if(strpos($xorg_log, 'EXA(0)'))74 {75 $accel_2d = 'EXA';76 }77 else if(stripos($xorg_log, 'GLAMOR acceleration'))78 {79 $accel_2d = 'GLAMOR';80 }81 else if(strpos($xorg_log, 'SNA initialized'))82 {83 $accel_2d = 'SNA';84 }85 else if(strpos($xorg_log, 'UXA(0)'))86 {87 $accel_2d = 'UXA';88 }89 else if(strpos($xorg_log, 'Gallium3D XA'))90 {91 $accel_2d = 'Gallium3D XA';92 }93 else if(strpos($xorg_log, 'shadowfb'))94 {95 $accel_2d = 'ShadowFB';96 }97 }98 return $accel_2d;99 }100 public static function set_property($identifier, $args)101 {102 switch($identifier)103 {104 case 'screen-resolution':105 $property = self::gpu_set_resolution($args);106 break;107 }108 return $property;109 }110 public static function gpu_set_resolution($args)111 {112 if(count($args) != 2 || phodevi::is_windows() || phodevi::is_macosx() || !pts_client::executable_in_path('xrandr'))113 {114 return false;115 }116 $width = $args[0];117 $height = $args[1];118 shell_exec('xrandr -s ' . $width . 'x' . $height . ' 2>&1');119 return phodevi::read_property('gpu', 'screen-resolution') == array($width, $height); // Check if video resolution set worked120 }121 public static function gpu_oc_offset_string()122 {123 $offset = 0;124 if(is_file('/sys/class/drm/card0/device/pp_sclk_od'))125 {126 // AMDGPU OverDrive127 $pp_sclk_od = pts_file_io::file_get_contents('/sys/class/drm/card0/device/pp_sclk_od');128 if(is_numeric($pp_sclk_od) && $pp_sclk_od > 0)129 {130 $offset = 'AMD OverDrive GPU Overclock: ' . $pp_sclk_od . '%';131 }132 }133 return $offset;134 }135 public static function gpu_aa_level()136 {137 // Determine AA level if over-rode138 $aa_level = false;139 if(phodevi::is_nvidia_graphics())140 {141 $nvidia_fsaa = phodevi_parser::read_nvidia_extension('FSAA');142 switch($nvidia_fsaa)143 {144 case 1:145 $aa_level = '2x Bilinear';146 break;147 case 5:148 $aa_level = '4x Bilinear';149 break;150 case 7:151 $aa_level = '8x';152 break;153 case 8:154 $aa_level = '16x';155 break;156 case 10:157 $aa_level = '8xQ';158 break;159 case 12:160 $aa_level = '16xQ';161 break;162 }163 }164 else if(phodevi::is_ati_graphics() && phodevi::is_linux())165 {166 $ati_fsaa = phodevi_linux_parser::read_amd_pcsdb('OpenGL,AntiAliasSamples');167 $ati_fsaa_filter = phodevi_linux_parser::read_amd_pcsdb('OpenGL,AAF');168 if(!empty($ati_fsaa))169 {170 if($ati_fsaa_filter == '0x00000000')171 {172 // Filter: Box173 switch($ati_fsaa)174 {175 case '0x00000002':176 $aa_level = '2x Box';177 break;178 case '0x00000004':179 $aa_level = '4x Box';180 break;181 case '0x00000008':182 $aa_level = '8x Box';183 break;184 }185 }186 else if($ati_fsaa_filter == '0x00000001')187 {188 // Filter: Narrow-tent189 switch($ati_fsaa)190 {191 case '0x00000002':192 $aa_level = '4x Narrow-tent';193 break;194 case '0x00000004':195 $aa_level = '8x Narrow-tent';196 break;197 case '0x00000008':198 $aa_level = '12x Narrow-tent';199 break;200 }201 }202 else if($ati_fsaa_filter == '0x00000002')203 {204 // Filter: Wide-tent205 switch($ati_fsaa)206 {207 case '0x00000002':208 $aa_level = '6x Wide-tent';209 break;210 case '0x00000004':211 $aa_level = '8x Wide-tent';212 break;213 case '0x00000008':214 $aa_level = '16x Wide-tent';215 break;216 }217 }218 else if($ati_fsaa_filter == '0x00000003')219 {220 // Filter: Edge-detect221 switch($ati_fsaa)222 {223 case '0x00000004':224 $aa_level = '12x Edge-detect';225 break;226 case '0x00000008':227 $aa_level = '24x Edge-detect';228 break;229 }230 }231 }232 }233 else if(phodevi::is_mesa_graphics())234 {235 $gallium_msaa = getenv('GALLIUM_MSAA');236 if(is_numeric($gallium_msaa) && $gallium_msaa > 0)237 {238 // Simple test to try to figure out if the GALLIUM_MSAA anti-aliasing value was forced239 $aa_level = $gallium_msaa . 'x MSAA';240 }241 }242 else if(getenv('__GL_FSAA_MODE'))243 {244 $gl_msaa = getenv('__GL_FSAA_MODE');245 if(is_numeric($gl_msaa) && $gl_msaa > 0)246 {247 $aa_level = '__GL_FSAA_MODE=' . $gallium_msaa;248 }249 }250 return $aa_level;251 }252 public static function gpu_af_level()253 {254 // Determine AF level if over-rode255 $af_level = false;256 if(phodevi::is_nvidia_graphics())257 {258 $nvidia_af = phodevi_parser::read_nvidia_extension('LogAniso');259 switch($nvidia_af)260 {261 case 1:262 $af_level = '2x';263 break;264 case 2:265 $af_level = '4x';266 break;267 case 3:268 $af_level = '8x';269 break;270 case 4:271 $af_level = '16x';272 break;273 }274 }275 else if(phodevi::is_ati_graphics() && phodevi::is_linux())276 {277 $ati_af = phodevi_linux_parser::read_amd_pcsdb('OpenGL,AnisoDegree');278 if(!empty($ati_af))279 {280 switch($ati_af)281 {282 case '0x00000002':283 $af_level = '2x';284 break;285 case '0x00000004':286 $af_level = '4x';287 break;288 case '0x00000008':289 $af_level = '8x';290 break;291 case '0x00000010':292 $af_level = '16x';293 break;294 }295 }296 }297 else if(getenv('__GL_LOG_MAX_ANISO'))298 {299 $max_aniso = getenv('__GL_LOG_MAX_ANISO');300 if(is_numeric($max_aniso) && $max_aniso > 0)301 {302 switch($max_aniso)303 {304 case 1:305 $max_aniso = '2x';306 break;307 case 2:308 $max_aniso = '4x';309 break;310 case 3:311 $max_aniso = '8x';312 break;313 case 4:314 $max_aniso = '16x';315 break;316 }317 $af_level = $max_aniso;318 }319 }320 return $af_level;321 }322 public static function gpu_compute_cores()323 {324 // Determine AF level if over-rode325 $cores = 0;326 if(phodevi::is_nvidia_graphics())327 {328 $cores = phodevi_parser::read_nvidia_extension('CUDACores');329 }330 return $cores;331 }332 public static function gpu_xrandr_resolution()333 {334 $resolution = false;335 if(pts_client::executable_in_path('xrandr') && getenv('DISPLAY'))336 {337 // Read resolution from xrandr338 // First try reading "current" screen 0 as it should better handle multiple monitors, etc.339 // e.g. Screen 0: minimum 1 x 1, current 2560 x 1341, maximum 8192 x 8192340 $info = shell_exec('xrandr 2>&1');341 $info = substr($info, strpos($info, 'current ') + 8);342 $info = explode(' x ', trim(substr($info, 0, strpos($info, ','))));343 if(count($info) == 2 && is_numeric($info[0]) && is_numeric($info[1]))344 {345 $resolution = $info;346 }347 if($resolution == false)348 {349 $info = shell_exec('xrandr 2>&1 | grep "*"');350 if(strpos($info, '*') !== false)351 {352 $res = pts_strings::trim_explode('x', $info);353 if(isset($res[1]))354 {355 $res[0] = substr($res[0], strrpos($res[0], ' '));356 $res[1] = substr($res[1], 0, strpos($res[1], ' '));357 $res = array_map('trim', $res);358 if(is_numeric($res[0]) && is_numeric($res[1]))359 {360 $resolution = array($res[0], $res[1]);361 }362 }363 }364 }365 }366 return $resolution;367 }368 public static function gpu_screen_resolution()369 {370 $resolution = false;371 if((($default_mode = getenv('DEFAULT_VIDEO_MODE')) != false))372 {373 $default_mode = explode('x', $default_mode);374 if(count($default_mode) == 2 && is_numeric($default_mode[0]) && is_numeric($default_mode[1]))375 {376 return $default_mode;377 }378 }379 if(phodevi::is_macosx())380 {381 $info = pts_strings::trim_explode(' ', phodevi_osx_parser::read_osx_system_profiler('SPDisplaysDataType', 'Resolution'));382 $resolution = array();383 $resolution[0] = $info[0];384 $resolution[1] = $info[2];385 }386 else if(phodevi::is_linux() || phodevi::is_bsd() || phodevi::is_solaris())387 {388 if($resolution == false && pts_client::executable_in_path('xrandr'))389 {390 $resolution = self::gpu_xrandr_resolution();391 }392 if($resolution == false && phodevi::is_linux())393 {394 // Before calling xrandr first try to get the resolution through KMS path395 foreach(pts_file_io::glob('/sys/class/drm/card*/*/modes') as $connector_path)396 {397 $connector_path = dirname($connector_path) . '/';398 if(is_file($connector_path . 'enabled') && pts_file_io::file_get_contents($connector_path . 'enabled') == 'enabled')399 {400 $mode = pts_arrays::first_element(explode("\n", pts_file_io::file_get_contents($connector_path . 'modes')));401 $info = pts_strings::trim_explode('x', $mode);402 if(count($info) == 2)403 {404 $resolution = $info;405 break;406 }407 }408 }409 }410 if($resolution == false && phodevi::is_nvidia_graphics())411 {412 // Way to find resolution through NVIDIA's NV-CONTROL extension413 // But rely upon xrandr first since when using NVIDIA TwinView the reported FrontEndResolution may be the smaller of the two414 if(($frontend_res = phodevi_parser::read_nvidia_extension('FrontendResolution')) != false)415 {416 $resolution = pts_strings::comma_explode($frontend_res);417 }418 }419 if($resolution == false)420 {421 // Fallback to reading resolution from xdpyinfo422 foreach(phodevi_parser::read_xdpy_monitor_info() as $monitor_line)423 {424 $this_resolution = substr($monitor_line, strpos($monitor_line, ': ') + 2);425 $this_resolution = substr($this_resolution, 0, strpos($this_resolution, ' '));426 $this_resolution = explode('x', $this_resolution);427 if(count($this_resolution) == 2 && is_numeric($this_resolution[0]) && is_numeric($this_resolution[1]))428 {429 $resolution = $this_resolution;430 break;431 }432 }433 }434 if($resolution == false && is_readable('/sys/class/graphics/fb0/virtual_size'))435 {436 // As last fall-back try reading size of fb437 $virtual_size = explode(',', pts_file_io::file_get_contents('/sys/class/graphics/fb0/virtual_size'));438 if(count($virtual_size) == 2 && is_numeric($virtual_size[0]) && is_numeric($virtual_size[1]))439 {440 $resolution = $virtual_size;441 }442 }443 }444 return $resolution == false ? array(-1, -1) : $resolution;445 }446 public static function gpu_screen_resolution_string()447 {448 // Return the current screen resolution449 $resolution = implode('x', phodevi::read_property('gpu', 'screen-resolution'));450 if($resolution == '-1x-1')451 {452 $resolution = null;453 }454 return $resolution;455 }456 public static function gpu_available_modes()457 {458 // XRandR available modes459 $current_resolution = phodevi::read_property('gpu', 'screen-resolution');460 $current_pixel_count = $current_resolution[0] * $current_resolution[1];461 $available_modes = array();462 $supported_ratios = array(1.60, 1.25, 1.33, 1.70, 1.71, 1.78);463 $ignore_modes = array(464 array(640, 400),465 array(720, 480), array(832, 624),466 array(960, 540), array(960, 600),467 array(896, 672), array(928, 696),468 array(960, 720), array(1152, 864),469 array(1280, 720), array(1360, 768),470 array(1776, 1000), array(1792, 1344),471 array(1800, 1440), array(1856, 1392),472 array(2048, 1536)473 );474 if($override_check = (($override_modes = getenv('OVERRIDE_VIDEO_MODES')) != false))475 {476 $override_modes = pts_strings::comma_explode($override_modes);477 for($i = 0; $i < count($override_modes); $i++)478 {479 $override_modes[$i] = explode('x', $override_modes[$i]);480 }481 }482 // Attempt reading available modes from xrandr483 if(pts_client::executable_in_path('xrandr') && !phodevi::is_macosx()) // MacOSX has xrandr but currently on at least my setup will emit a Bus Error when called484 {485 $xrandr_lines = array_reverse(explode("\n", shell_exec('xrandr 2>&1')));486 foreach($xrandr_lines as $xrandr_mode)487 {488 if(($cut_point = strpos($xrandr_mode, '(')) > 0)489 {490 $xrandr_mode = substr($xrandr_mode, 0, $cut_point);491 }492 $res = pts_strings::trim_explode('x', $xrandr_mode);493 if(count($res) == 2)494 {495 $res[0] = substr($res[0], strrpos($res[0], ' '));496 $res[1] = substr($res[1], 0, strpos($res[1], ' '));497 if(is_numeric($res[0]) && is_numeric($res[1]))498 {499 $m = array($res[0], $res[1]);500 if(!in_array($m, $available_modes))501 {502 // Don't repeat modes503 array_push($available_modes, $m);504 }505 }506 }507 }508 }509 if(count($available_modes) <= 2)510 {511 // Fallback to providing stock modes512 $stock_modes = array(513 array(800, 600),514 array(1024, 768),515 array(1280, 800),516 array(1280, 1024),517 array(1400, 900),518 array(1400, 1050),519 array(1600, 900),520 array(1680, 1050),521 array(1600, 1200),522 array(1920, 1080),523 array(1920, 1200),524 array(2560, 1600),525 array(3840, 2160));526 $available_modes = array();527 for($i = 0; $i < count($stock_modes); $i++)528 {529 if($stock_modes[$i][0] <= $current_resolution[0] && $stock_modes[$i][1] <= $current_resolution[1])530 {531 array_push($available_modes, $stock_modes[$i]);532 }533 }534 }535 if(!in_array(phodevi::read_property('gpu', 'screen-resolution'), $available_modes))536 {537 array_push($available_modes, phodevi::read_property('gpu', 'screen-resolution'));538 }539 foreach($available_modes as $mode_index => $mode)540 {541 $this_ratio = pts_math::set_precision($mode[0] / $mode[1], 2);542 if($override_check && !in_array($mode, $override_modes))543 {544 // Using override modes and this mode is not present545 unset($available_modes[$mode_index]);546 }547 else if($current_pixel_count > 614400 && ($mode[0] * $mode[1]) < 480000 && stripos(phodevi::read_name('gpu'), 'llvmpipe') === false)548 {549 // For displays larger than 1024 x 600, drop modes below 800 x 600 unless llvmpipe is being used550 unset($available_modes[$mode_index]);551 }552 else if($current_pixel_count > 480000 && !in_array($this_ratio, $supported_ratios))553 {554 // For displays larger than 800 x 600, ensure reading from a supported ratio555 unset($available_modes[$mode_index]);556 }557 else if(in_array($mode, $ignore_modes))558 {559 // Mode is to be ignored560 unset($available_modes[$mode_index]);561 }562 }563 // Sort available modes in order564 $unsorted_modes = $available_modes;565 $available_modes = array();566 $mode_pixel_counts = array();567 foreach($unsorted_modes as $this_mode)568 {569 if(count($this_mode) == 2)570 {571 array_push($mode_pixel_counts, $this_mode[0] * $this_mode[1]);572 }573 }574 // Sort resolutions by true pixel count resolution575 sort($mode_pixel_counts);576 foreach($mode_pixel_counts as &$mode_pixel_count)577 {578 foreach($unsorted_modes as $mode_index => $mode)579 {580 if($mode[0] * $mode[1] == $mode_pixel_count)581 {582 array_push($available_modes, $mode);583 unset($unsorted_modes[$mode_index]);584 break;585 }586 }587 }588 if(count($available_modes) == 0 && $override_check)589 {590 // Write in the non-standard modes that were overrode591 foreach($override_modes as $mode)592 {593 if(is_array($mode) && count($mode) == 2)594 {595 array_push($available_modes, $mode);596 }597 }598 }599 return $available_modes;600 }601 public static function gpu_memory_size()602 {603 // Graphics memory capacity604 $video_ram = -1;605 if(($vram = getenv('VIDEO_MEMORY')) != false && is_numeric($vram))606 {607 $video_ram = $vram;608 }609 else if(is_file('/sys/kernel/debug/dri/0/memory'))610 {611 // This is how some of the Nouveau DRM VRAM is reported612 $memory = file_get_contents('/sys/kernel/debug/dri/0/memory');613 if(($x = strpos($memory, 'VRAM total: ')) !== false)614 {615 $memory = substr($memory, ($x + 12));616 if(($x = strpos($memory, 'KiB')) !== false)617 {618 $memory = substr($memory, 0, $x);619 if(is_numeric($memory))620 {621 $video_ram = $memory / 1024;622 }623 }624 }625 }626 else if(phodevi::is_nvidia_graphics() && ($NVIDIA = phodevi_parser::read_nvidia_extension('VideoRam')) > 0) // NVIDIA blob627 {628 $video_ram = $NVIDIA / 1024;629 }630 else if(phodevi::is_macosx())631 {632 $info = phodevi_osx_parser::read_osx_system_profiler('SPDisplaysDataType', 'VRAM');633 $info = explode(' ', $info);634 $video_ram = $info[0];635 if($info[1] == 'GB')636 {637 $video_ram *= 1024;638 }639 }640 else641 {642 // Try reading video memoty from GLX_MESA_query_renderer output in glxinfo643 $glxinfo_video_mem = str_replace('MB', null, phodevi_parser::glxinfo_read_line('Video memory'));644 if(is_numeric($glxinfo_video_mem) && $glxinfo_video_mem > 1)645 {646 // Do some rounding as at least AMDGPU/RadeonSI reports less than real amount647 $video_ram = $glxinfo_video_mem % 128 === 0 ? $glxinfo_video_mem : round(($glxinfo_video_mem + 128 / 2) / 128) * 128;648 }649 }650 // Disabling 27 Nov 2016 as seems to cause problems with AMDGPU-0PRO but falls back gracefully outside of this xorg-log parsing for correct amount651 /*652 if($video_ram == -1 && isset(phodevi::$vfs->xorg_log))653 {654 // Attempt Video RAM detection using X log655 // fglrx driver reports video memory to: (--) fglrx(0): VideoRAM: XXXXXX kByte, Type: DDR656 // xf86-video-ati, xf86-video-intel, and xf86-video-radeonhd also report their memory information in a similar format657 $info = phodevi::$vfs->xorg_log;658 if(($pos = stripos($info, 'RAM:') + 5) > 5 || ($pos = strpos($info, 'RAM=') + 4) > 4)659 {660 $info = substr($info, $pos);661 $info = substr($info, 0, strpos($info, ' '));662 if(!is_numeric($info) && ($cut = strpos($info, ',')))663 {664 $info = substr($info, 0, $cut);665 }666 if(is_numeric($info) && $info > 65535)667 {668 $video_ram = intval($info) / 1024;669 }670 }671 }672 */673 if($video_ram == -1 && isset(phodevi::$vfs->dmesg))674 {675 // Fallback to try to find vRAM from dmesg676 $info = phodevi::$vfs->dmesg;677 if(($x = strpos($info, 'Detected VRAM RAM=')) !== false)678 {679 // Radeon DRM at least reports: [drm] Detected VRAM RAM=2048M, BAR=256M680 $info = substr($info, $x + 18);681 $info = substr($info, 0, strpos($info, 'M'));682 }683 else if(($x = strpos($info, 'M of VRAM')) !== false)684 {685 // Radeon DRM around Linux ~3.0 reports e.g.: [drm] radeon: 2048M of VRAM memory ready686 $info = substr($info, 0, $x);687 $info = substr($info, strrpos($info, ' ') + 1);688 }689 else if(($x = strpos($info, 'MiB VRAM')) !== false)690 {691 // Nouveau DRM around Linux ~3.0 reports e.g.: [drm] nouveau XXX: Detected 1024MiB VRAM692 $info = substr($info, 0, $x);693 $info = substr($info, strrpos($info, ' ') + 1);694 }695 else if(($x = strpos($info, 'VRAM: ')) !== false)696 {697 // Nouveau DRM around Linux ~3.6 reports e.g.: DRM] VRAM: 512 MiB698 $info = substr($info, ($x + 6));699 $info = substr($info, 0, strpos($info, ' '));700 if(substr($info, -1) == 'M')701 {702 $info = substr($info, 0, -1);703 }704 }705 if(is_numeric($info))706 {707 $video_ram = $info;708 }709 }710 if($video_ram == -1 || !is_numeric($video_ram) || $video_ram < 64)711 {712 $video_ram = 64; // default to 64MB of video RAM as something sane...713 }714 return $video_ram;715 }716 public static function gpu_string()717 {718 $info = phodevi_parser::read_glx_renderer();719 if(stripos($info, 'llvmpipe'))720 {721 return 'LLVMpipe';722 }723 else724 {725 return phodevi::read_property('gpu', 'model') . ' ' . phodevi::read_property('gpu', 'frequency');726 }727 }728 public static function gpu_frequency_string()729 {730 $freq = phodevi::read_property('gpu', 'stock-frequency');731 $freq_string = null;732 if($freq[0] != 0)733 {734 $freq_string = $freq[0];735 if($freq[1] != 0)736 {737 $freq_string .= '/' . $freq[1];738 }739 $freq_string .= 'MHz';740 }741 return ($freq_string != null ? ' (' . $freq_string . ')' : null);742 }743 public static function gpu_stock_frequency()744 {745 // Graphics processor stock frequency746 $core_freq = 0;747 $mem_freq = 0;748 if(phodevi::is_nvidia_graphics() && phodevi::is_macosx() == false) // NVIDIA GPU749 {750 // GPUDefault3DClockFreqs is the default and does not show under/over-clocking751 $clock_freqs_3d = pts_strings::comma_explode(phodevi_parser::read_nvidia_extension('GPU3DClockFreqs'));752 $clock_freqs_current = pts_strings::comma_explode(phodevi_parser::read_nvidia_extension('GPUCurrentClockFreqs'));753 if(is_array($clock_freqs_3d) && isset($clock_freqs_3d[1]))754 {755 list($core_freq, $mem_freq) = $clock_freqs_3d;756 }757 if(is_array($clock_freqs_current) && isset($clock_freqs_current[1]))758 {759 $core_freq = max($core_freq, $clock_freqs_current[0]);760 $mem_freq = max($mem_freq, $clock_freqs_current[1]);761 }762 }763 else if(phodevi::is_ati_graphics() && phodevi::is_linux()) // ATI GPU764 {765 $od_clocks = phodevi_linux_parser::read_ati_overdrive('CurrentPeak');766 if(is_array($od_clocks) && count($od_clocks) >= 2) // ATI OverDrive767 {768 list($core_freq, $mem_freq) = $od_clocks;769 }770 }771 else if(phodevi::is_linux()) // More liberally attempt open-source freq detection than phodevi::is_mesa_graphics()772 {773 if(is_file('/sys/class/drm/card0/device/performance_level'))774 {775 // NOUVEAU776 /*777 EXAMPLE OUTPUTS:778 memory 1000MHz core 500MHz voltage 1300mV fanspeed 100%779 3: memory 333MHz core 500MHz shader 1250MHz fanspeed 100%780 c: memory 333MHz core 500MHz shader 1250MHz781 */782 $performance_level = pts_file_io::file_get_contents('/sys/class/drm/card0/device/performance_level');783 $performance_level = explode(' ', $performance_level);784 $core_string = array_search('core', $performance_level);785 if($core_string !== false && isset($performance_level[($core_string + 1)]))786 {787 $core_string = str_ireplace('MHz', null, $performance_level[($core_string + 1)]);788 if(is_numeric($core_string))789 {790 $core_freq = $core_string;791 }792 }793 $mem_string = array_search('memory', $performance_level);794 if($mem_string !== false && isset($performance_level[($mem_string + 1)]))795 {796 $mem_string = str_ireplace('MHz', null, $performance_level[($mem_string + 1)]);797 if(is_numeric($mem_string))798 {799 $mem_freq = $mem_string;800 }801 }802 }803 else if(is_file('/sys/class/drm/card0/device/pstate'))804 {805 // Nouveau806 // pstate is present with Linux 3.13 as the new performance states on Fermi/Kepler807 $performance_state = pts_file_io::file_get_contents('/sys/class/drm/card0/device/pstate');808 $performance_level = substr($performance_state, 0, strpos($performance_state, ' *'));809 if($performance_level == null)810 {811 // Method for Linux 3.17+812 $performance_level = substr($performance_state, strpos($performance_state, 'AC: ') + 4);813 if(($t = strpos($performance_level, PHP_EOL)))814 {815 $performance_level = substr($performance_level, 0, $t);816 }817 }818 else819 {820 // Method for Linux ~3.13 through Linux 3.16821 $performance_level = substr($performance_level, strrpos($performance_level, ': ') + 2);822 }823 $performance_level = explode(' ', $performance_level);824 $core_string = array_search('core', $performance_level);825 if($core_string !== false && isset($performance_level[($core_string + 1)]))826 {827 $core_string = str_ireplace('MHz', null, $performance_level[($core_string + 1)]);828 if(strpos($core_string, '-') !== false)829 {830 // to work around a range of values, e.g.831 // 0a: core 405-1032 MHz memory 1620 MHz AC DC *832 $core_string = max(explode('-', $core_string));833 }834 if(is_numeric($core_string))835 {836 $core_freq = $core_string;837 }838 }839 $mem_string = array_search('memory', $performance_level);840 if($mem_string !== false && isset($performance_level[($mem_string + 1)]))841 {842 $mem_string = str_ireplace('MHz', null, $performance_level[($mem_string + 1)]);843 if(strpos($mem_string, '-') !== false)844 {845 // to work around a range of values, e.g.846 // 0a: core 405-1032 MHz memory 1620 MHz AC DC *847 $mem_string = max(explode('-', $mem_string));848 }849 if(is_numeric($mem_string))850 {851 $mem_freq = $mem_string;852 }853 }854 }855 //856 // RADEON / AMDGPU Logic857 //858 if(isset(phodevi::$vfs->radeon_pm_info))859 {860 // radeon_pm_info should be present with Linux 2.6.34+ but was changed with Linux 3.11 Radeon DPM861 if(stripos(phodevi::$vfs->radeon_pm_info, 'default'))862 {863 foreach(pts_strings::trim_explode("\n", phodevi::$vfs->radeon_pm_info) as $pm_line)864 {865 if($pm_line == null)866 {867 continue;868 }869 list($descriptor, $value) = pts_strings::colon_explode($pm_line);870 switch($descriptor)871 {872 case 'default engine clock':873 $core_freq = pts_arrays::first_element(explode(' ', $value)) / 1000;874 break;875 case 'default memory clock':876 $mem_freq = pts_arrays::first_element(explode(' ', $value)) / 1000;877 break;878 }879 }880 }881 if($core_freq == 0 && ($x = stripos(phodevi::$vfs->radeon_pm_info, 'sclk: ')) != false)882 {883 $x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('sclk: '));884 $x = substr($x, 0, strpos($x, ' '));885 if(is_numeric($x) && $x > 100)886 {887 if($x > 10000)888 {889 $x = $x / 100;890 }891 $core_freq = $x;892 }893 if(($x = stripos(phodevi::$vfs->radeon_pm_info, 'mclk: ')) != false)894 {895 $x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('mclk: '));896 $x = substr($x, 0, strpos($x, ' '));897 if(is_numeric($x) && $x > 100)898 {899 if($x > 10000)900 {901 $x = $x / 100;902 }903 $mem_freq = $x;904 }905 }906 }907 }908 if($core_freq == null && isset(phodevi::$vfs->dmesg) && strrpos(phodevi::$vfs->dmesg, ' sclk:'))909 {910 // Attempt to read the LAST power level reported to dmesg, this is the current way for Radeon DPM on Linux 3.11+911 $dmesg_parse = phodevi::$vfs->dmesg;912 if(($x = strrpos($dmesg_parse, ' sclk:')))913 {914 $dmesg_parse = substr($dmesg_parse, $x);915 $dmesg_parse = explode(' ', substr($dmesg_parse, 0, strpos($dmesg_parse, PHP_EOL)));916 $sclk = array_search('sclk:', $dmesg_parse);917 if($sclk !== false && isset($dmesg_parse[($sclk + 1)]) && is_numeric($dmesg_parse[($sclk + 1)]))918 {919 $sclk = $dmesg_parse[($sclk + 1)];920 if($sclk > 10000)921 {922 $sclk = $sclk / 100;923 }924 $core_freq = $sclk;925 }926 $mclk = array_search('mclk:', $dmesg_parse);927 if($mclk !== false && isset($dmesg_parse[($mclk + 1)]) && is_numeric($dmesg_parse[($mclk + 1)]))928 {929 $mclk = $dmesg_parse[($mclk + 1)];930 if($mclk > 10000)931 {932 $mclk = $mclk / 100;933 }934 $mem_freq = $mclk;935 }936 }937 }938 //939 // INTEL940 //941 // try to read the maximum dynamic frequency942 if($core_freq == 0 && is_file('/sys/class/drm/card0/gt_max_freq_mhz'))943 {944 $gt_max_freq_mhz = pts_file_io::file_get_contents('/sys/class/drm/card0/gt_max_freq_mhz');945 if(is_numeric($gt_max_freq_mhz) && $gt_max_freq_mhz > 100)946 {947 // Tested on Linux 3.11. Assume the max frequency on any competent GPU is beyond 100MHz948 $core_freq = $gt_max_freq_mhz;949 }950 }951 if($core_freq == 0 && is_file('/sys/kernel/debug/dri/0/i915_max_freq'))952 {953 $i915_max_freq = pts_file_io::file_get_contents('/sys/kernel/debug/dri/0/i915_max_freq');954 $freq_mhz = substr($i915_max_freq, strpos($i915_max_freq, ': ') + 2);955 if(is_numeric($freq_mhz))956 {957 $core_freq = $freq_mhz;958 }959 }960 // Fallback to base frequency961 if($core_freq == 0 && isset(phodevi::$vfs->i915_cur_delayinfo))962 {963 $i915_cur_delayinfo = phodevi::$vfs->i915_cur_delayinfo;964 $freq = strpos($i915_cur_delayinfo, 'Max overclocked frequency: ');965 if($freq === false)966 {967 $freq = strpos($i915_cur_delayinfo, 'Max non-overclocked (RP0) frequency: ');968 }969 if($freq === false)970 {971 $freq = strpos($i915_cur_delayinfo, 'Nominal (RP1) frequency: ');972 }973 if($freq !== false)974 {975 $freq_mhz = substr($i915_cur_delayinfo, strpos($i915_cur_delayinfo, ': ', $freq) + 2);976 $freq_mhz = trim(substr($freq_mhz, 0, strpos($freq_mhz, 'MHz')));977 if(is_numeric($freq_mhz))978 {979 $core_freq = $freq_mhz;980 }981 }982 }983 }984 $core_freq = !is_numeric($core_freq) ? 0 : round($core_freq);985 $mem_freq = !is_numeric($mem_freq) ? 0 : round($mem_freq);986 return array($core_freq, $mem_freq);987 }988 public static function gpu_model()989 {990 // Report graphics processor string991 $info = phodevi_parser::read_glx_renderer();992 $video_ram = phodevi::read_property('gpu', 'memory-capacity');993 if(phodevi::is_ati_graphics() && phodevi::is_linux())994 {995 $crossfire_status = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/Crossfire/chain/*,Enable');996 $crossfire_status = pts_arrays::to_array($crossfire_status);997 $crossfire_card_count = 0;998 for($i = 0; $i < count($crossfire_status); $i++)999 {1000 if($crossfire_status[$i] == '0x00000001')1001 {1002 $crossfire_card_count += 2; // For now assume each chain is 2 cards, but proper way would be NumSlaves + 1...

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1$gpu = new phodevi_gpu();2echo $gpu->gpu_model();3$gpu = new phodevi_gpu();4echo $gpu->gpu_driver();5$gpu = new phodevi_gpu();6echo $gpu->gpu_vram();7$gpu = new phodevi_gpu();8echo $gpu->gpu_vram_used();9$gpu = new phodevi_gpu();10echo $gpu->gpu_vram_total();11$gpu = new phodevi_gpu();12echo $gpu->gpu_vram_used_percent();13$gpu = new phodevi_gpu();14echo $gpu->gpu_vram_used();15$gpu = new phodevi_gpu();16echo $gpu->gpu_vram_total();17$gpu = new phodevi_gpu();18echo $gpu->gpu_vram_used_percent();19$gpu = new phodevi_gpu();20echo $gpu->gpu_vram_used();21$gpu = new phodevi_gpu();22echo $gpu->gpu_vram_total();23$gpu = new phodevi_gpu();24echo $gpu->gpu_vram_used_percent();

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1$gpu = new phodevi_gpu();2echo $gpu->gpu_model();3$gpu = new phodevi_gpu();4echo $gpu->gpu_model();5$gpu = new phodevi_gpu();6echo $gpu->gpu_model();7$gpu = new phodevi_gpu();8echo $gpu->gpu_model();9$gpu = new phodevi_gpu();10echo $gpu->gpu_model();11$gpu = new phodevi_gpu();12echo $gpu->gpu_model();13$gpu = new phodevi_gpu();14echo $gpu->gpu_model();15$gpu = new phodevi_gpu();16echo $gpu->gpu_model();17$gpu = new phodevi_gpu();18echo $gpu->gpu_model();19$gpu = new phodevi_gpu();20echo $gpu->gpu_model();21$gpu = new phodevi_gpu();22echo $gpu->gpu_model();23$gpu = new phodevi_gpu();24echo $gpu->gpu_model();25$gpu = new phodevi_gpu();26echo $gpu->gpu_model();27$gpu = new phodevi_gpu();28echo $gpu->gpu_model();

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1echo phodevi_gpu::gpu_model();2echo phodevi_gpu::gpu_model();3echo phodevi_gpu::gpu_model();4echo phodevi_gpu::gpu_model();5echo phodevi_gpu::gpu_model();6echo phodevi_gpu::gpu_model();7echo phodevi_gpu::gpu_model();8echo phodevi_gpu::gpu_model();9echo phodevi_gpu::gpu_model();10echo phodevi_gpu::gpu_model();11echo phodevi_gpu::gpu_model();12echo phodevi_gpu::gpu_model();13echo phodevi_gpu::gpu_model();14echo phodevi_gpu::gpu_model();15echo phodevi_gpu::gpu_model();16echo phodevi_gpu::gpu_model();17echo phodevi_gpu::gpu_model();

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2$gpu = new phodevi_gpu();3echo $gpu->gpu_model();4require_once('phodevi.php');5$gpu = new phodevi_gpu();6echo $gpu->gpu_model();7require_once('phodevi.php');8$gpu = new phodevi_gpu();9echo $gpu->gpu_model();10require_once('phodevi.php');11$gpu = new phodevi_gpu();12echo $gpu->gpu_model();13require_once('phodevi.php');14$gpu = new phodevi_gpu();15echo $gpu->gpu_model();16require_once('phodevi.php');17$gpu = new phodevi_gpu();18echo $gpu->gpu_model();19require_once('phodevi.php');20$gpu = new phodevi_gpu();21echo $gpu->gpu_model();22require_once('phodevi.php');23$gpu = new phodevi_gpu();24echo $gpu->gpu_model();25require_once('phodevi.php');26$gpu = new phodevi_gpu();27echo $gpu->gpu_model();28require_once('phodevi.php');29$gpu = new phodevi_gpu();30echo $gpu->gpu_model();31require_once('phodevi.php');32$gpu = new phodevi_gpu();33echo $gpu->gpu_model();34require_once('

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1require_once 'phodevi.php';2$gpu = new phodevi_gpu();3echo $gpu->gpu_model();4require_once 'phodevi.php';5$gpu = new phodevi_gpu();6echo $gpu->gpu_model();7require_once 'phodevi.php';8$gpu = new phodevi_gpu();9echo $gpu->gpu_model();10require_once 'phodevi.php';11$gpu = new phodevi_gpu();12echo $gpu->gpu_model();13require_once 'phodevi.php';14$gpu = new phodevi_gpu();15echo $gpu->gpu_model();16require_once 'phodevi.php';17$gpu = new phodevi_gpu();18echo $gpu->gpu_model();19require_once 'phodevi.php';20$gpu = new phodevi_gpu();21echo $gpu->gpu_model();22require_once 'phodevi.php';23$gpu = new phodevi_gpu();24echo $gpu->gpu_model();25require_once 'phodevi.php';26$gpu = new phodevi_gpu();27echo $gpu->gpu_model();28require_once 'phodevi.php';29$gpu = new phodevi_gpu();30echo $gpu->gpu_model();31require_once 'phodevi.php';32$gpu = new phodevi_gpu();33echo $gpu->gpu_model();

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1$gpu_model = phodevi_gpu::gpu_model();2";3$gpu_vendor = phodevi_gpu::gpu_vendor();4";5$gpu_driver = phodevi_gpu::gpu_driver();6";7$gpu_driver_version = phodevi_gpu::gpu_driver_version();8";9$gpu_driver_date = phodevi_gpu::gpu_driver_date();10";11$gpu_driver_url = phodevi_gpu::gpu_driver_url();12";13$gpu_driver_version_current = phodevi_gpu::gpu_driver_version_current();14";15$gpu_driver_date_current = phodevi_gpu::gpu_driver_date_current();16";17$gpu_driver_url_current = phodevi_gpu::gpu_driver_url_current();18";19$gpu_driver_date_current = phodevi_gpu::gpu_driver_date_current();20";

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1$gpu = new phodevi_gpu();2$gpu_model = $gpu->gpu_model();3";4$gpu = new phodevi_gpu();5$gpu_vendor = $gpu->gpu_vendor();6";7$gpu = new phodevi_gpu();8$gpu_driver = $gpu->gpu_driver();9";10$gpu = new phodevi_gpu();11$gpu_driver_version = $gpu->gpu_driver_version();12";13$gpu = new phodevi_gpu();14$gpu_bus = $gpu->gpu_bus();15";16$gpu = new phodevi_gpu();17$gpu_memory = $gpu->gpu_memory();18";19$gpu = new phodevi_gpu();20$gpu_memory_used = $gpu->gpu_memory_used();21";22$gpu = new phodevi_gpu();23$gpu_memory_free = $gpu->gpu_memory_free();24";25$gpu = new phodevi_gpu();26$gpu_memory_total = $gpu->gpu_memory_total();27";28$gpu = new phodevi_gpu();29$gpu_usage = $gpu->gpu_usage();30";31$gpu = new phodevi_gpu();

Full Screen

Full Screen

gpu_model

Using AI Code Generation

copy

Full Screen

1$gpu = new phodevi_gpu();2echo $gpu->gpu_model();3$gpu = new phodevi_gpu();4echo $gpu->gpu_temp();5$gpu = new phodevi_gpu();6echo $gpu->gpu_usage();7$gpu = new phodevi_gpu();8echo $gpu->gpu_mem_usage();9$gpu = new phodevi_gpu();10echo $gpu->gpu_driver_version();11$gpu = new phodevi_gpu();12echo $gpu->gpu_mem_total();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger gpu_model code on LambdaTest Cloud Grid

Execute automation tests with gpu_model on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful