2
votes

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);

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

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 )

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

Edit 1:

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;
}

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

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)

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

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

2
Are you sure you are looking at the correct device (as-in more than one clock)? Also, the fact that a given chip has specification X in no way implies that the board you are running that chip on is configured to run at X. It's quite possible the API is returning the correct value for the board you are running on.jwdonahue
Added minimal reproducible code. I tested this on ASUS tinkerboard with Mali T70 GPU. I'm not querying for the board's operating clock freq. I'm querying for the GPU's max clock freq. As per OpenCL docs, this query should return "Maximum configured clock frequency of the device in MHz.". The "device" in this context is the Mali GPU, not the board.Avis
Is it possible it's running in a low power mode?jwdonahue
You're correct. By default, the GPU governor is set to be running in low power mode. Now I changed the governor to "performance" mode and the query returned "594 MHz". Please make the comment as answer.Avis

2 Answers

4
votes

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.

2
votes

I also met the same problem. The device is Snapdragon 855 with Adreno640 GPU, whose max freq is 585MHz. I have make it to the max clock rates firstly. Then use code to get max clock rate. But the result is 1 MHz!

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