OpenCLプログラムをコーディングするためのIvyBridgeプラットフォームをセットアップしました。私のシステムは、開発ツールとしてwin7 64ビット、VS2010です。私のPCにはnVidiaGTX560を搭載したi7-3770kが1つあります。システムのデバイスを照会したところ、HD4000が見つかりません。次のWebページを使用してHD4000のシステムドライバを確認しました:http://www.intel.com/p/en_US/support/detect/graphics。レポートには、「現在インストールされているドライバ8.15.10.2696」と記載されています。OpenCL SDKは、 http://software.intel.com/en-us/articles/vcsource-tools-opencl-sdk/からダウンロードされた最新のIntel SDK for OpenCL Application 2012Windows64ビットです。以下は私のコードと出力です。
また、CPUのデバイス名が非常に奇妙であることに気づきました。ちなみに、CLコンテキストの作成に失敗した問題に誰かが遭遇したのを見つけたので、HD4000デバイスをモニターに接続しました。そして今、モニターをHD4000に接続した後、GPU-ZツールでHD4000を検出できることがわかりました。だから誰かが私がこの問題を解決するのを手伝ってくれる?
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <CL/cl.h>
int _tmain(int argc, _TCHAR* argv[])
{
cl_platform_id *platforms;
cl_uint num_platforms;
cl_device_id *devices_cpu, *devices_gpu;
cl_uint num_devices;
char dev_name[40], dev_vendor[40], dev_version[40], dev_profile[40];
char plt_name[40], plt_vendor[40], plt_version[40], plt_profile[40];
clGetPlatformIDs(1, NULL, &num_platforms);
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * num_platforms);
clGetPlatformIDs(num_platforms, platforms, NULL);
for(int i = num_platforms - 1; i >= 0; i--)
{
clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, sizeof(plt_name),&plt_name,NULL);
clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, sizeof(plt_vendor),&plt_vendor,NULL);
clGetPlatformInfo(platforms[i], CL_PLATFORM_VERSION, sizeof(plt_version),&plt_version,NULL);
clGetPlatformInfo(platforms[i], CL_PLATFORM_PROFILE, sizeof(plt_profile),&plt_profile,NULL);
printf("\n\n\nPlatform #%d Info: \n\n", i);
printf("Platform: %s \n", plt_name);
printf("Vendor: %s \n", plt_vendor);
printf("Version: %s \n", plt_version);
printf("Profile: %s \n", plt_profile);
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_CPU, 1, NULL, &num_devices);
devices_cpu = (cl_device_id *)malloc(sizeof(cl_device_id) * num_devices);
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_CPU, num_devices, devices_cpu, NULL);
for(int j = 0 ; j < num_devices; j++)
{
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_NAME, sizeof(dev_name), &dev_name, NULL);
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_VENDOR, sizeof(dev_vendor), &dev_vendor, NULL);
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_VERSION, sizeof(dev_version), &dev_version, NULL);
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_PROFILE, sizeof(dev_profile), &dev_profile, NULL);
printf("\n\n\nCPU Device Info: \n\n");
printf("Name: %s \n", dev_name);
printf("Vendor: %s \n", dev_vendor);
printf("Version: %s \n", dev_version);
printf("Profile: %s \n", dev_profile);
}
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_GPU, 1, NULL, &num_devices);
devices_gpu = (cl_device_id *)malloc(sizeof(cl_device_id) * num_devices);
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_GPU, num_devices, devices_gpu, NULL);
for(int j = 0; j < num_devices; j++)
{
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_NAME, sizeof(dev_name), &dev_name, NULL);
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_VENDOR, sizeof(dev_vendor), &dev_vendor, NULL);
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_VERSION, sizeof(dev_version), &dev_version, NULL);
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_PROFILE, sizeof(dev_profile), &dev_profile, NULL);
printf("\n\n\nGPU Device Info: \n\n");
printf("Platform: %s \n", dev_name);
printf("Vendor: %s \n", dev_vendor);
printf("Version: %s \n", dev_version);
printf("Profile: %s \n", dev_profile);
}
free((void*)devices_cpu);
free((void*)devices_gpu);
}
return 0;
}
出力:
プラットフォーム#1情報: プラットフォーム:Intel(R)OpenCL ベンダー:Intel(R)Corporation バージョン:OpenCL 1.1 プロファイル:FULL_PROFILE CPUデバイス情報: 名前:ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ベンダー:Intel(R)Corporation バージョン:OpenCL 1.1(ビルド31360.31441) プロファイル:FULL_PROFILE プラットフォーム#0情報: プラットフォーム:NVIDIA CUDA ベンダー:NVIDIA Corporation バージョン:OpenCL 1.1 CUDA 4.2.1 プロファイル:FULL_PROFILE GPUデバイス情報: プラットフォーム:GeForce GTX 560 Ti ベンダー:NVIDIA Corporation バージョン:OpenCL 1.1 CUDA プロファイル:FULL_PROFILE