簡體   English   中英

OpenCL —在不同的設備上有不同的內核“ printf()”結果嗎?

[英]OpenCL — Different kernel “printf()” results on different devices?

通過運行hello_world內核,我得到了一個奇特的結果,該內核僅打印通過命令隊列傳遞的緩沖區。 我從同一平台上的不同設備得到兩個不同的結果。 請參閱以下控制台輸出的底部:

這是我的內核代碼:

__kernel void hello_world (__global char* message, int messageSize) {
    for (int i =0; i < messageSize; i++) {
        printf("%c", message[i]);
    }
}

這是我的函數調用:

  std::string message = "Hello World!";
  int messageSize = message.length();
  std::cout << "          ---> Creating Buffer... ";
  cl::Buffer buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(char) * messageSize, (char*)message.c_str());

  kernel.setArg(0,buffer);
  kernel.setArg(1,sizeof(int),&messageSize);
  std::cout << "Done!" << std::endl;

  for (cl_uint i = 0; i<m_deviceCount[m_currentPlatform]; i++) {
        std::cout << "          ---> Queuing Kernel Task on Device #"<< m_currentPlatform << "." << i << "... ";
        m_commandQueues[i].enqueueTask(kernel);
        std::cout << "Done!" << std::endl;
        std::cout << "          ---> Executing... Output:\n\n";
        m_commandQueues[i].finish();
        std::cout << "\n\n          ---> Done!" << std::endl;
    }

和我的控制台輸出:

Found 1 Platforms

Platform #0:
  Name:  AMD Accelerated Parallel Processing
  Found  2 Devices
      Device #0.0:
          --> Name:               Juniper
          --> Vendor:             Advanced Micro Devices, Inc.
          --> Max Compute Units:  10
          --> Max Clock Freq:     850
          --> Global Mem Size:    512 MBs
          --> Local Mem Size:     32 KBs
          --> Hardware Version:   OpenCL 1.2 AMD-APP (1800.11)
          --> Software Version:   1800.11
          --> Open CL Version:    OpenCL C 1.2 
          --> Images Supported:   YES
      Device #0.1:
          --> Name:               Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
          --> Vendor:             GenuineIntel
          --> Max Compute Units:  8
          --> Max Clock Freq:     3796
          --> Global Mem Size:    15905 MBs
          --> Local Mem Size:     32 KBs
          --> Hardware Version:   OpenCL 1.2 AMD-APP (1800.11)
          --> Software Version:   1800.11 (sse2,avx)
          --> Open CL Version:    OpenCL C 1.2 
          --> Images Supported:   YES

    Using Platform With Most Available Devices: Platform #0
          ---> Creating Context.... Done!
          ---> Creating Command Queue for Device #0.0.... Done!
          ---> Creating Command Queue for Device #0.1.... Done!
          ---> Loading Program: hello_world.cl...
                  > Compiling... Done!
          ---> Creating Buffer... Done!

          ---> Queuing Kernel Task on Device #0.0... Done!
          ---> Executing... Output:

H(null)e(null)l(null)l(null)o(null) (null)W(null)o(null)r(null)l(null)d(null)!(null)

          ---> Done!
          ---> Queuing Kernel Task on Device #0.1... Done!
          ---> Executing... Output:

Hello World!

          ---> Done!

有誰知道為什么AMD GPU在字符之間插入“(null)”,而Intel CPU沒有? AMD實施OpenCL是否正常?

我還嘗試過在內核中使用printf。 您可以在以下位置參考我的程序:

https://github.com/pradyotsn/opencl_printf

謝謝

暫無
暫無

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

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