OpenCL:查询移动GPU的最大时钟频率总是返回较小的值 [英] OpenCL : Querying max clock frequency of a mobile GPU always returns a lesser value

查看:304
本文介绍了OpenCL:查询移动GPU的最大时钟频率总是返回较小的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了知道Mali T760 GPU的最大时钟频率,我使用了以下代码片段:

In order to know the max clock frequency of a Mali T760 GPU, I used the code snippet below:

// Get device max clock frequency
cl_uint max_clock_freq;
err_num = clGetDeviceInfo(cl_devices[device_idx], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(max_clock_freq), &max_clock_freq, NULL);
check_cl_error(err_num, "clGetDeviceInfo: Getting device max clock frequency");
printf("CL_DEVICE_MAX_CLOCK_FREQUENCY: %d MHz\n", max_clock_freq);

此处提供完整的源代码: https://github.com/sivagnanamn/opencl-device -info

Full source code available here: https://github.com/sivagnanamn/opencl-device-info

查询结果显示为CL_DEVICE_MAX_CLOCK_FREQUENCY: 99 MHz,而规范中报告的时钟频率为600MHz(src: https://www.notebookcheck.net/ARM-Mali-T760-MP4.148383.0.html )

The query result shows CL_DEVICE_MAX_CLOCK_FREQUENCY: 99 MHz whereas the clock freq reported in the specs is 600MHz (src: https://www.notebookcheck.net/ARM-Mali-T760-MP4.148383.0.html )

为什么规格和报告的实际时钟频率之间存在差异OpenCL查询的时钟频率?

Why there's a difference between the actual clock freq reported in specs & clock freq from OpenCL query?

这是用于查询支持OpenCl的GPU设备的最大时钟频率的代码的极小的版本.

Here's a very minimal version of the code for querying the max clock frequency of the OpenCl capable GPU device.

#include <stdio.h>
#include <stdlib.h>

#ifdef __APPLE__
  #include <OpenCL/opencl.h>
#else
  #include <CL/cl.h>
#endif

void check_cl_error(cl_int err_num, char* msg) {
  if(err_num != CL_SUCCESS) {
    printf("[Error] OpenCL error code: %d in %s \n", err_num, msg);
    exit(EXIT_FAILURE);
  }
}

int main(void) {

  cl_int err_num;
  char str_buffer[1024];
  cl_uint num_platforms_available;

  // Get the number of OpenCL capable platforms available
  err_num = clGetPlatformIDs(0, NULL, &num_platforms_available);

  // Exit if no OpenCL capable platform found
  if(num_platforms_available == 0){
    printf("No OpenCL capable platforms found ! \n");
    return EXIT_FAILURE;
  }

  // Create a list for storing the platform id's
  cl_platform_id cl_platforms[num_platforms_available];

  err_num = clGetPlatformIDs(num_platforms_available, cl_platforms, NULL);
  check_cl_error(err_num, "clGetPlatformIDs: Getting available platform id's");

  // Get attributes of each platform available
  for(int platform_idx = 0; platform_idx < num_platforms_available; platform_idx++) {

    // Get the number of OpenCL supported device available in this platform
    cl_uint num_devices_available;
    err_num = clGetDeviceIDs(cl_platforms[platform_idx], CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices_available);
    check_cl_error(err_num, "clGetDeviceIDs: Get number of OpenCL supported devices available");

    cl_device_id cl_devices[num_devices_available];
    err_num = clGetDeviceIDs(cl_platforms[platform_idx], CL_DEVICE_TYPE_ALL, num_devices_available, cl_devices, NULL);
    check_cl_error(err_num, "clGetDeviceIDs: Getting available OpenCL capable device id's");

    // Get attributes of each device
    for(int device_idx = 0; device_idx < num_devices_available; device_idx++) {

      // Get device max clock frequency
      cl_uint max_clock_freq;
      err_num = clGetDeviceInfo(cl_devices[device_idx], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(max_clock_freq), &max_clock_freq, NULL);
      check_cl_error(err_num, "clGetDeviceInfo: Getting device max clock frequency");
      printf("[Platform %d] [Device %d] CL_DEVICE_MAX_CLOCK_FREQUENCY: %d MHz\n", platform_idx, device_idx, max_clock_freq);
    }
  }

  return 0;
}

在具有Mali T760 GPU的ASUS TinkerBoard上执行后,我得到的输出是

The output I get after executing on ASUS TinkerBoard with Mali T760 GPU is

[Platform 0] [Device 0] CL_DEVICE_MAX_CLOCK_FREQUENCY: 99 MHz

根据OpenCL文档,没有缩放因子.查询应返回以MHz为单位的频率( https ://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/clGetDeviceInfo.html )

According to the OpenCL docs, there's no scaling factor. The query should return the frequency in MHz (https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/clGetDeviceInfo.html)

OpenCL文档摘录: CL_DEVICE_MAX_CLOCK_FREQUENCY-cl_uint-设备的最大已配置时钟频率,单位为MHz.

Excerpt from the OpenCL docs: CL_DEVICE_MAX_CLOCK_FREQUENCY - cl_uint - Maximum configured clock frequency of the device in MHz.

但是,在PC GPU上运行相同的代码(已在NVIDIA和Intel GPU上进行测试)会根据规格返回预期的时钟频率.

However running the same code on an PC GPU(tested on NVIDIA & Intel GPU's) returns the expected clock frequency as per the specs.

推荐答案

出于电源/热量管理目的,通常会限制CPU/GPU时钟速度.您的GPU可能处于低功耗模式.但是,如果您以编程方式更改电源模式,请注意不要超出电路板配置的规格.有时,这些开发板没有足够的散热器来提供最大的时钟速率.

CPU/GPU clock speeds are often throttled for power/heat management purposes. Your GPU might be in a low power mode. If you programatically change the power mode however, be careful not to exceed the specs for your board configuration. Sometimes these development boards don't come with adequate heat sinks for max clock rates.

这篇关于OpenCL:查询移动GPU的最大时钟频率总是返回较小的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆