0

我最近安装了 ComputeCpp 1.3 版,并在 Microsoft Visual Studio 2015 上启动了一个 ComputeCpp 项目。它附带以下示例代码。

////////////////////////////////////////////////////////////////////////////////
//
//  SYCL Sample Code
//
//  Author: Codeplay, April 2015
//
////////////////////////////////////////////////////////////////////////////////

/*!
If you encounter an application cannot start because SYCL.dll or SYCL_d.dll is
missing error, then you may have to restart your computer in order to update the
environment variable COMPUTECPPROOT.
*/

#include <CL/sycl.hpp>

#include <iostream>

using namespace cl::sycl;

int main(int argc, char *argv[]) {

  /* Create 1024 element arrays for input data and output. */
  float inputDataA[1024];
  float inputDataB[1024];
  float outputData[1024];

  /* Initialize input data with values and output data with zeroes. */
  for (int i = 0; i < 1024; i++) {
    inputDataA[i] = (float)i;
    inputDataB[i] = (float)(1024 - i);
    outputData[i] = 0.0f;
  }

  /* Wrap all SYCL structures and function calls with a try-catch block to catch
   * SYCL exceptions. */
  try {

    /* Create a default_selector to select a device to execute on. */
    default_selector mySelector;

    /* Create a queue from the default_selector to create an implicit context
     * and queue to execute with. */
    queue myQueue(mySelector);

    /* Create a scope to control data synchronisation of buffer objects. */
    {
      /* Create 1 dimensionsal buffers for the input and output data of size
       * 1024. */
      buffer<float, 1> inputBufferA(inputDataA, range<1>(1024));
      buffer<float, 1> inputBufferB(inputDataB, range<1>(1024));
      buffer<float, 1> outputBuffer(outputData, range<1>(1024));

      /* Submit a command_group to execute from the queue. */
      myQueue.submit([&](handler &cgh) {

        /* Create accessors for accessing the input and output data within the
         * kernel. */
        auto inputPtrA = inputBufferA.get_access<access::mode::read>(cgh);
        auto inputPtrB = inputBufferB.get_access<access::mode::read>(cgh);
        auto outputPtr = outputBuffer.get_access<access::mode::write>(cgh);

        /* Enqueue a kernel called 'vector_add', with a global work size of {
         * 16, 8, 8 } and a local work size of { 4, 2, 2 }. */
        cgh.parallel_for<class vector_add>(
            nd_range<3>(range<3>(16, 8, 8), range<3>(4, 2, 2)),
            [=](nd_item<3> item) {

              /* Retreive the linear global id for the current work item. */
              size_t idx = item.get_global_linear_id();

              /* Use the linear global id to add the respective element of each
               * input accessor together and assign them to the respective
               * element of the output accessor. */
              outputPtr[idx] = inputPtrA[idx] + inputPtrB[idx];
            });
      });
    }

  } catch (exception e) {

    /* In the case of an exception being throw, print theerror message and
     * return 1. */
    std::cout << e.what();
    return 1;
  }

  /* Sum up all the values in the output array. */
  float sum = 0;
  for (int i = 0; i < 1024; i++) {
    sum += outputData[i];
  }

  /* If the sum is the expected result, return 0, else return 1. */
  if (sum == (1024.0f * 1024)) {
    std::cout << "Success!" << std::endl;
    return 0;
  } else {
    std::cout << "Fail: Expected result was 1024.0f, actual result is " << sum
              << std::endl;
    return 1;
  }
}

////////////////////////////////////////////////////////////////////////////////

当我运行它时,出现以下错误。

C:\Program Files\Codeplay\ComputeCpp\include\SYCL/common.h(109,20): error : no type named 'int8_t' in namespace 'std'; did you mean simply 'int8_t'?
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor_args.h(1077,11): error : no type named 'plane_id_t' in namespace 'cl::sycl::detail'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1350,3): error : no type named 'int8_t' in namespace 'std'; did you mean simply 'int8_t'?
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1512,57): error : 'is_image_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1514,24): error : 'is_image_array_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1515,62): error : 'is_host_image_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1516,58): error : 'is_atomic_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1512,57): error : 'is_image_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1514,24): error : 'is_image_array_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1515,62): error : 'is_host_image_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1516,58): error : 'is_atomic_ctr' is a protected member of 'cl::sycl::detail::accessor_common<float, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
main.cpp(75,58): error : type 'const cl::sycl::accessor<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>' does not provide a subscript operator
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1541,9): error : type 'cl::sycl::accessor<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>::accessor_common' (aka 'accessor_common<float, 1, (cl::sycl::access::mode)0U, (cl::sycl::access::target)1U, access::placeholder::false_t>') is not a direct or virtual base of 'cl::sycl::accessor<float, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files\Codeplay\ComputeCpp\include\SYCL/accessor.h(1541,9): error : type 'cl::sycl::accessor<float, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>::accessor_common' (aka 'accessor_common<float, 1, (cl::sycl::access::mode)1U, (cl::sycl::access::target)1U, access::placeholder::false_t>') is not a direct or virtual base of 'cl::sycl::accessor<float, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t>'
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\ComputeCpp.targets(60,9): error MSB3721: The command ""C:\Program Files\Codeplay\ComputeCpp\bin\compute++.exe" -D_SIZE_T_DEFINED -Wno-ignored-attributes -fdiagnostics-format=msvc -sycl -O2 -nobuiltininc -I"c:\program files (x86)\Microsoft Visual Studio 12.0\VC\include" -I"c:\program files (x86)\Microsoft Visual Studio 12.0\atlmfc\include" -I"C:\Program Files\Codeplay\ComputeCpp\include" -I"C:\Program Files\Codeplay\ComputeCpp\include\image_library" -I"C:\vector_sum\\" -o"C:\vector_sum\main.sycl" -c main.cpp " exited with code 1.

正如我们所看到的,它与安装附带的头文件有关,这使我相信这些错误与编译器有关。

在 ComputeCpp 指南中它说:“您的 Visual Studio 安装可能缺少所需的 C++ 工具和配置,您可以通过从添加/删除程序修改您的安装来检查这一点。” 我想知道在安装 Visual Studio 2015 时可能缺少哪些工具和配置。 https://developer.codeplay.com/products/computecpp/ce/guides/platform-support/targeting-windows

编辑:#include <cstdint>按照建议添加后,所有这些错误都已解决。构建成功。但是,执行时,出现以下错误。

'vector_sum.exe' (Win32): Loaded 'C:\vector_sum\x64\Debug\vector_sum.exe'. Symbols loaded.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\apphelp.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Unloaded 'C:\Windows\System32\ucrtbased.dll'
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1d.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Program Files\Codeplay\ComputeCpp\lib\ComputeCpp_vs2015_d.dll'. Module was built without symbols.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\OpenCL.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\IntelOpenCL64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Intel\OpenCL\bin\x64\intelocl64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\opengl32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\glu32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\DXCore.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Intel\OpenCL\bin\x64\task_executor64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\ntmarta.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Intel\OpenCL\bin\x64\cpu_device64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Intel\OpenCL\bin\x64\tbb\tbb.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\igdrcl64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\ResourcePolicyClient.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Unloaded 'C:\Windows\System32\ResourcePolicyClient.dll'
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\igdfcl64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\dbghelp.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\igdbcl64.dll'. Cannot find or open the PDB file.
'vector_sum.exe' (Win32): Loaded 'C:\Windows\System32\igdusc64.dll'. Cannot find or open the PDB file.
Exception thrown at 0x00007FFD9C14A799 in vector_sum.exe: Microsoft C++ exception: cl::sycl::compile_program_error at memory location 0x00000040BA8F7340.
Exception thrown at 0x00007FFD9C14A799 in vector_sum.exe: Microsoft C++ exception: std::runtime_error at memory location 0x00000040BA8F4120.
Exception thrown at 0x00007FFD9C14A799 in vector_sum.exe: Microsoft C++ exception: cl::sycl::compile_program_error at memory location 0x00000040BA8F08C0.
Exception thrown at 0x00007FFD9C14A799 in vector_sum.exe: Microsoft C++ exception: cl::sycl::compile_program_error at memory location 0x00000040BA8F0730.
The thread 0x30dc has exited with code 0 (0x0).
The thread 0x1b98 has exited with code 1 (0x1).
The thread 0x3c18 has exited with code 1 (0x1).
The thread 0x1a74 has exited with code 1 (0x1).
The program '[7532] vector_sum.exe' has exited with code 1 (0x1).

在命令提示符下运行它时,出现以下错误。

Error: [ComputeCpp:RT0100] Failed to build program (<Build log for program 000002179AB4B9D0 device 0 (size 106):
error: unknown metadata record encountered: kernel_arg_addr_space
error: midlevel compiler failed build.

这是我检查硬件支持的内容。

********************************************************************************

ComputeCpp Info (CE 1.3.0)

SYCL 1.2.1 revision 3

********************************************************************************


Device Info:

Discovered 2 devices matching:
  platform    : <any>
  device type : <any>

--------------------------------------------------------------------------------
Device 0:

  Device is supported                     : NO - No bitcode target found
  Bitcode targets                         :
  CL_DEVICE_NAME                          :         Intel(R) Pentium(R) CPU 2127U @ 1.90GHz
  CL_DEVICE_VENDOR                        : Intel(R) Corporation
  CL_DRIVER_VERSION                       : 3.0.1.10891
  CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_CPU
--------------------------------------------------------------------------------
Device 1:

  Device is supported                     : NO - No bitcode target found
  Bitcode targets                         :
  CL_DEVICE_NAME                          : Intel(R) HD Graphics
  CL_DEVICE_VENDOR                        : Intel(R) Corporation
  CL_DRIVER_VERSION                       : 10.18.10.5129
  CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_GPU

If you encounter problems when using any of these OpenCL devices, please consult
this website for known issues:
https://computecpp.codeplay.com/releases/v1.3.0/platform-support-notes

********************************************************************************

我怎样才能解决这个问题?

4

0 回答 0