簡體   English   中英

OpenCL:查詢移動 GPU 的最大時鍾頻率總是返回較小的值

[英]OpenCL : Querying max clock frequency of a mobile GPU always returns a lesser value

為了了解 Mali T760 GPU 的最大時鍾頻率,我使用了以下代碼片段:

// 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

查詢結果顯示CL_DEVICE_MAX_CLOCK_FREQUENCY: 99 MHz而規范中報告的時鍾頻率為 600MHz (src: https://www.notebookcheck.net/ARM-Mali-T760-MP4.148383.0.html )

為什么 OpenCL 查詢的規范和時鍾頻率中報告的實際時鍾頻率之間存在差異?

編輯1:

這是用於查詢支持 OpenCl 的 GPU 設備的最大時鍾頻率的代碼的最小版本。

#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 上執行后我得到的輸出是

[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

摘自 OpenCL 文檔: CL_DEVICE_MAX_CLOCK_FREQUENCY - cl_uint - 設備的最大配置時鍾頻率(以 MHz 為單位)。

但是,在 PC GPU 上運行相同的代碼(在 NVIDIA 和 Intel GPU 上測試)會根據規范返回預期的時鍾頻率。

CPU/GPU 時鍾速度通常會出於電源/熱量管理目的而受到限制。 您的 GPU 可能處於低功耗模式。 但是,如果您以編程方式更改電源模式,請注意不要超出電路板配置的規格。 有時,這些開發板沒有配備足夠的散熱器來實現最大時鍾速率。

我也遇到了同樣的問題。 該設備是帶有 Adreno640 GPU 的 Snapdragon 855,其最大頻率為 585MHz。 我首先達到了最大時鍾頻率。 然后使用代碼獲得最大時鍾速率。 但結果是 1 MHz!

cl_uint clockFreq = targetDevice.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>();
std::cout << "Max freq: " << clockFreq << " MHz" << std::endl;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM