簡體   English   中英

OpenCL示例程序在CPU上的執行速度比在GPU上快10倍

[英]OpenCL sample program executes 10 times faster on CPU than on GPU

我是OpenCL編程的新手,因此決定運行一些來自已下載的AMD SDK的示例。 我的首選是還原樣品 每次我在CPU上執行程序時,執行時間都比在GPU上低大約10倍。 在計算方面,GPU是否會比CPU更好?

我的硬件:

  • CPU i5-2430M 2.40 GHz
  • GPU AMD Radeon 6630M

在平台0(GPU)上執行:

$ Reduction.exe -x 33554432 -i 5 -q -t -p 0
Platform 0 : Advanced Micro Devices, Inc.
Platform 1 : Intel(R) Corporation

Selected Platform Vendor : Advanced Micro Devices, Inc.
Device 0 :        Intel(R) Core(TM) i5-2430M CPU @ 2.40GHz Device ID is 009E83A0

Executing kernel for 5 iterations
-------------------------------------------
Exec: 1.64225

| Elements | Time(sec) | (DataTransfer + Kernel)Time(sec) |
|----------|-----------|----------------------------------|
| 33554432 | 1.83705   | 1.64225                          |

在平台1(CPU)上執行:

$ Reduction.exe -x 33554432 -i 5 -q -t -p 1
Platform 0 : Advanced Micro Devices, Inc.
Platform 1 : Intel(R) Corporation
GPU not found. Falling back to CPU device

Selected Platform Vendor : Intel(R) Corporation
Device 0 :        Intel(R) Core(TM) i5-2430M CPU @ 2.40GHz Device ID is 040BEF1C

Executing kernel for 5 iterations
-------------------------------------------
Exec: 0.198049

| Elements | Time(sec) | (DataTransfer + Kernel)Time(sec) |
|----------|-----------|----------------------------------|
| 33554432 | 0.542269  | 0.198049                         |

從您的輸出來看,它們似乎都在您的CPU上運行。

第一個使用AMD平台,第二個使用Intel,但是您的CPU在兩個平台上均顯示為設備0。 嘗試使用標志-d 1 (以使用設備1)或--device gpu

編輯 :查看系統要求頁面,AMD網站上的信息或符合OpenCL的產品列表 ,看起來好像不支持您的GPU。

根據此規格頁面( gpuzoo.com ),6630M設備應支持OpenCL 1.2。 仔細檢查您的驅動程序版本,並確保支持該版本。 如果您仍然遇到問題,請嘗試使用較舊的驅動程序。 driverscollection.com

嘗試在系統上運行CLInfo程序以查看其是否全部正常。 這應該為您提供所支持的所有設備的完整詳細信息。

看來AMD SDK正在選擇Intel作為其計算設備。 難怪為什么會這樣,因為它可能基於設備的優先級。

如何解決

1) Retrieve deviceid's for all GPU/CPU which has OpenCL support for particular platform (In your case ONE AMD GPU + ONE INTEL CPU).
1) After getting all device id's use device info to extract required device (You can use CL_DEVICE_VENDOR flag to extract the required deviceid)
3) and then use this deviceid in all further device id reference.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM