OpenCL列举平台列表以及平台属性信息
生活随笔
收集整理的這篇文章主要介紹了
OpenCL列举平台列表以及平台属性信息
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
摘自《OpenCL異構并行計算原理、機制與優化實踐》
// Platform.cpp : Defines the entry point for the console application. //#include "stdafx.h"#include <CL/cl.h> #include <stdio.h> #include <string.h> #include <malloc.h>int main() {cl_platform_id *platform;cl_uint num_platform;cl_int err;err = clGetPlatformIDs(0, NULL, &num_platform);platform = (cl_platform_id *)malloc(sizeof(cl_platform_id) * num_platform);err = clGetPlatformIDs(num_platform, platform, NULL);for (int i = 0; i < num_platform; i++){size_t size;// get nameerr = clGetPlatformInfo(platform[i], CL_PLATFORM_NAME, 0, NULL, &size);char *name = (char *)malloc(size);err = clGetPlatformInfo(platform[i], CL_PLATFORM_NAME, size, name, NULL);printf("CL_PLATFORM_NAME:%s\n", name);// vendorerr = clGetPlatformInfo(platform[i], CL_PLATFORM_VENDOR, 0, NULL, &size);char *vendor = (char *)malloc(size);err = clGetPlatformInfo(platform[i], CL_PLATFORM_VENDOR, size, vendor, NULL);printf("CL_PLATFORM_VENDOR:%s\n", vendor);// versionerr = clGetPlatformInfo(platform[i], CL_PLATFORM_VERSION, 0, NULL, &size);char *version = (char *)malloc(size);err = clGetPlatformInfo(platform[i], CL_PLATFORM_VERSION, size, version, NULL);printf("CL_PLATFORM_VERSION:%s\n", version);// profileerr = clGetPlatformInfo(platform[i], CL_PLATFORM_PROFILE, 0, NULL, &size);char *profile = (char *)malloc(size);err = clGetPlatformInfo(platform[i], CL_PLATFORM_PROFILE, size, profile, NULL);printf("CL_PLATFORM_PROFILE:%s\n", profile);// extensionserr = clGetPlatformInfo(platform[i], CL_PLATFORM_EXTENSIONS, 0, NULL, &size);char *extensions = (char *)malloc(size);err = clGetPlatformInfo(platform[i], CL_PLATFORM_EXTENSIONS, size, extensions, NULL);printf("CL_PLATFORM_EXTENSIONS:%s\n", extensions);//printf("\n\n");// cleanfree(name);free(vendor);free(version);free(profile);free(extensions);}return 0; }總結
以上是生活随笔為你收集整理的OpenCL列举平台列表以及平台属性信息的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基金lof型是什么意思
- 下一篇: 菜鸟做设计必看!有关如何做设计的整体思路