2012-02-28 53 views
1

我正在嘗試使用設備分裂擴展來編寫opencl程序。設備分裂Intel CPU

我使用的是英特爾酷睿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. 

任何想法?

回答

1

有你嘗試任何的Khronos的例子從http://www.khronos.org/registry/cl/extensions/ext/cl_ext_device_fission.txt

喜歡:

實施例:向一個四個計算單元設備分成兩個子設備, 各含有兩個計算單元,通過:

  { CL_DEVICE_PARTITION_BY_COUNTS_EXT, 
       2, 2, CL_PARTITION_BY_COUNTS_LIST_END_EXT, 
       CL_PROPERTIES_LIST_END_EXT } 
+0

謝謝,這個鏈接很有用。不過,我也嘗試了上面的分區。它可能是硬件相關的? – rdoubleui 2012-02-28 21:00:54

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的未來版本將不那麼挑剔,在你擁有的那個中,它更像是一個預覽功能。

+0

你說得對,因爲它是英特爾特有的,它屬於那裏。我也在那裏發佈了它。對於在這裏跟隨線程的人:我用C來測試它,但我經常得到'[appname]:symbol lookup error:[appname]:undefined symbol:clCreateSubDevicesEXT'。 – rdoubleui 2012-03-01 14:05:21

+0

[鏈接到主題](http://software.intel.com/zh-cn/forums/showthread.php?t=103443) – rdoubleui 2012-03-01 14:13:40