Device Fission Intel CPU

时间:2012-02-28 11:45:48

标签: opencl

我正在尝试使用设备裂变扩展来编写opencl程序。

我使用的是英特尔i3 M350,但我无法创建子设备:

#define USE_CL_DEVICE_FISSION 1

#include <iostream>
#include "CL/cl.hpp"

using namespace std;

int main(int argc, char* argv[]) {
    cl::Context context;
    std::vector<cl::Platform> platforms;
    cl::Platform::get(&platforms);

    cl_context_properties properties[] =
    {
            CL_CONTEXT_PLATFORM,
            (cl_context_properties)(platforms[1])(),
            0
    };

    context = cl::Context(CL_DEVICE_TYPE_CPU, properties);

    std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();

    cout << "Platform:\t" << platforms[1].getInfo<CL_PLATFORM_NAME>() << endl;
    cout << "Version:\t" << platforms[1].getInfo<CL_PLATFORM_VERSION>() << endl;

    cout << "Device:\t\t" << devices[0].getInfo<CL_DEVICE_NAME>() << endl;
    cout << "Profile:\t" << devices[0].getInfo<CL_DEVICE_PROFILE>() << endl;
    cout << "Driver:\t\t" << devices[0].getInfo<CL_DRIVER_VERSION>() << endl;
    cout << "ComputeUnits:\t" << devices[0].getInfo<CL_DEVICE_MAX_COMPUTE_UNITS >() << endl;

    if (devices[0].getInfo<CL_DEVICE_EXTENSIONS>().find("cl_ext_device_fission") == std::string::npos) {
        cout << "No device fission support!" << endl;
        exit(-1);
    }
    else {
        cout << "Device Fission: Available" << endl;
    }

    const cl_device_partition_property_ext subDeviceProperties[] =
    {
        CL_DEVICE_PARTITION_EQUALLY_EXT,
        1,
        CL_PROPERTIES_LIST_END_EXT,
        0
    };

    std::vector<cl::Device> subDevices;
    int err = devices[0].createSubDevices(subDeviceProperties, &subDevices);
    if (err != CL_SUCCESS) {
        cout << "\nError: " << err << endl;
    }
}

输出结果为:

Platform:   Intel(R) OpenCL
Version:    OpenCL 1.1 LINUX
Device:     Intel(R) Core(TM) i3 CPU       M 350  @ 2.27GHz
Profile:    FULL_PROFILE
Driver:     1.1
ComputeUnits:   4
Device Fission: Available

Error: -1057 

此错误代码代表:

  

CL_DEVICE_PARTITION_FAILED_EXT -1057

Returned by clCreateSubDevicesEXT when the total number of compute units
requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute
units for any one sub-device is less than 1.

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

首先,提出有关英特尔OpenCL SDK实施问题的最佳地点是他们(我们的)论坛: http://software.intel.com/en-us/forums/intel-opencl-sdk/

话虽如此,当前版本在clCreateSubdevicesEXT的实现方面存在一些怪癖。您似乎遇到的问题是,它希望C API中的最后一个参数num_devices_ret是一个非NULL指针,指向结果子设备的数量。 C ++包装器显然不熟悉这个问题,因此你得到了失败的返回值。

我对C ++包装器不太熟悉所以我不知道你是否可以强制它在clCreateSubdevicesEXT的底层调用中传递一个非NULL指针。假设你不能,潜在的解决方案是自己修改包装器,或者使用C API。

SDK的未来版本对此类内容不那么挑剔;在你拥有的那个中,它更像是一个预览功能。

答案 1 :(得分:1)

让您尝试过http://www.khronos.org/registry/cl/extensions/ext/cl_ext_device_fission.txt

中的任何Khronos示例

像:

示例:将四个计算单元设备拆分为两个子设备,             每个包含两个计算单元,传递:

            { CL_DEVICE_PARTITION_BY_COUNTS_EXT, 
              2, 2, CL_PARTITION_BY_COUNTS_LIST_END_EXT,
              CL_PROPERTIES_LIST_END_EXT }