日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

opencl获取gpu信息_如果在尝试获取OpenCL gpu设备类型时,Char *语句出现问题

發布時間:2025/3/15 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 opencl获取gpu信息_如果在尝试获取OpenCL gpu设备类型时,Char *语句出现问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我一直試圖驗證你的System \ n“,gpus)上的哪個OpenCL平臺和gpu`s are located in, and at the same time count if there are more than one amd gpu on the system. I can get all visible outputs but im having a hard time using if statements to check if the displayed card actually are a advanced micro devices unit, i hope anyone can help me out a little here. Here is the current code:

if (listdevices)

{

int i, j;

char* value;

char* ellesmere = "Ellesmere";

char* valuemodel;

char* amdman1 = "Advanced Micro Devices, Inc.";

char* amdman2 = "Advanced Micro Devices, Inc";

char* amdman3 = "AMD";

char* amdman4 = "Advanced Micro Devices, Inc. ";

char* value2;

size_t valueSize;

cl_uint platformCount;

cl_platform_id* platforms;

cl_device_type device_type;

cl_uint deviceCount;

cl_device_id* devices;

cl_uint maxComputeUnits;

cl_uint globalMemsize;

uint64_t gpus = 0;

bool amdplatformlocated = false;

uint64_t amdplatform;

uint64_t currentplatform;

uint64_t countamd;

// get all platforms

clGetPlatformIDs(0, NULL, &platformCount);

platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id) * platformCount);

clGetPlatformIDs(platformCount, platforms, NULL);

for (i = 0; i < platformCount; i++) {

printf("\n\nPlatform-index: %d: \n\n", i);

currentplatform = i;

// get all devices

clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, 0, NULL, &deviceCount);

devices = (cl_device_id*)malloc(sizeof(cl_device_id) * deviceCount);

clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, deviceCount, devices, NULL);

// for each device print critical attributes

for (j = 0; j < deviceCount; j++) {

gpus++;

// print device info & check if AMD model

clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize);

value = (char*)malloc(valueSize);

clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL);

printf(" %d. Device: %s.\n", j + 1, value);

if (value == ellesmere) {

amdplatformlocated = true;

amdplatform = currentplatform;

printf(" %d.%d Located AMD Device: %s\n", j + 1, 2, amdplatformlocated);

}

free(value);

// print manufacturer info & check if AMD

clGetDeviceInfo(devices[j], CL_DEVICE_VENDOR, 0, NULL, &valueSize);

value = (char*)malloc(valueSize);

clGetDeviceInfo(devices[j], CL_DEVICE_VENDOR, valueSize, value, NULL);

clGetDeviceInfo(devices[j], CL_DEVICE_VENDOR, valueSize, value2, NULL);

printf(" %d.%d Vendor: %s\n", j + 1, 1, value);

if (value2 == amdman1 || value2 == amdman2 || value2 == amdman3 || value2 == amdman4) {

amdplatformlocated = 1;

amdplatform = currentplatform;

printf(" %d.%d Located AMD Device: %s\n", j + 1, 2, amdplatformlocated);

countamd++;

}

free(value);

// print hardware device version

clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, 0, NULL, &valueSize);

value = (char*)malloc(valueSize);

clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, valueSize, value, NULL);

printf(" %d.%d Hardware version: %s\n", j + 1, 2, value);

free(value);

// print software driver version

clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, 0, NULL, &valueSize);

value = (char*)malloc(valueSize);

clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, valueSize, value, NULL);

printf(" %d.%d Software version: %s\n", j + 1, 3, value);

free(value);

// print c version supported by compiler for device

clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, 0, NULL, &valueSize);

value = (char*)malloc(valueSize);

clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, valueSize, value, NULL);

printf(" %d.%d OpenCL C version: %s\n", j + 1, 4, value);

free(value);

// print parallel compute units

clGetDeviceInfo(devices[j], CL_DEVICE_MAX_COMPUTE_UNITS,

sizeof(maxComputeUnits), &maxComputeUnits, NULL);

printf(" %d.%d Parallel compute units: %d\n", j + 1, 5, maxComputeUnits);

}

free(devices);

}

printf("\nWe have registered %d GPU`s;

if(amdplatformlocated == 1){

printf(“看來,平臺%d在你的系統上包含AMD GPU`s., amdplatform);

}

else {

printf("\nDid you find your AMD Card on this list?\n");

}

free(platforms);

win_exit();

return 0;

}Which currently on a AMD RX570 Card gives this output:

> Platform-index: 0:

>

>

>

> Platform-index: 1:

>

> 1. Device: Ellesmere.

> 1.1 Vendor: Advanced Micro Devices, Inc.

> 1.2 Hardware version: OpenCL 2.0 AMD-APP (2442.12)

> 1.3 Software version: 2442.12

> 1.4 OpenCL C version: OpenCL C 2.0

> 1.5 Parallel compute units: 32

> 1.6 Maximum Memory Size:

We have registered 1 GPU`s

你有沒有在這張名單上找到你的AMD卡?

PRE>

如果(value == ellesmere)不起作用,那么在供應商部分也不行。為什么是這樣?兩者都是當前的char *,如果我使用簡單的代碼來比較它們的工作原理,我沒有看到什么?

謝謝

總結

以上是生活随笔為你收集整理的opencl获取gpu信息_如果在尝试获取OpenCL gpu设备类型时,Char *语句出现问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。