How To Fix Build Errors From The Helper Header File ‘memory.hpp’ of Intel® DPC++ Compatibility Tool Caused By The Removal of ‘vector_class’ Class in SYCL* Version 2020

ID 690277
Updated 11/1/2021
Version Latest
Public

author-image

By

Contributor: Lin, Jie jie.lin@intel.com

Intel® DPC++ Compatibility Tool (the Compatibility Tool) could help users to migrate original CUDA* projects to DPC++ projects. Now the Intel® oneAPI DPC++/C++ Compiler released in oneAPI product series is gradually adding the new contents from SYCL* 2020 specification while removing the contents in SYCL* 1.2.1 specification that are in conflict with SYCL* 2020. The Compatibility Tool with version 2021.4 or older uses SYCL* 1.2.1 ‘vector_class’ which is removed in SYCL* 2020. Building the migrated DPC++ program with open source DPC++ Compiler will result in a compilation error “error: no template named 'vector_class' in namespace 'sycl' ”. This error manifest because the open source DPC++ Compiler is ahead in the game to drop the ‘vector_class’ support (as recommended by SYCL* 2020) but the Compatibility Tool is yet to drop ‘vector_class’ usage in its headers.
This compilation error will not appear in projects migrated by the Compatibility Tool in the next major release and later releases.

Issue Description

Let’s review a simple CUDA code ‘device-count.cu’:

int main( )
{
    int dev_count;
    cudaGetDeviceCount(&dev_count);
    return dev_count;
}
  • Migrate this code to DPC++ with ‘dpct’ of the Compatibility Tool

~/test$ dpct --version

Intel(R) DPC++ Compatibility Tool version 2021.4.0. Codebase:(a6feb2f754c7de6a069c84affee3f363aa953627)

~/test$ dpct device-count.cu

Now in the ‘dpct_output’ directory, the DPC++ code ‘device-count.dp.cpp’ is generated:

~/test/dpct_output$ ls

device-count.dp.cpp MainSourceFiles.yaml

  • Compilation works with oneAPI 2021.4

The output DPC++ code should work with ‘dpcpp’ in oneAPI 2021.4 release:

~/test/dpct_output$ dpcpp device-count.dp.cpp -o device-count.exe

~/test/dpct_output$ ls

device-count.dp.cpp device-count.exe MainSourceFiles.yaml

When build with the open source DPC++ compiler, you may get errors like :

In file included from /opt/intel/oneapi/dpcpp-ct/2021.4.0/include/dpct/dpct.hpp:23: /opt/intel/oneapi/dpcpp-ct/2021.4.0/include/dpct/memory.hpp:276:25: error: no member named 'vector_class' in namespace 'sycl'
cl::sycl::vector_class<cl::sycl::event>

Solution

As you see, the error comes from ‘/opt/intel/oneapi/dpcpp-ct/2021.4.0/include/dpct/memory.hpp’ file. The path may appear different as you choose a different installation location of oneAPI. Just open the memory.hpp file in administrative mode and replace all “cl::sycl::vector_class” with “std::vector”.

After that, you can build the DPC++ code output from the Compatibility Tool without these ‘vector_class’ errors.

You may see other warning messages when you created your DPC++ project with the older versions of the Compatibility Tool and build it with either ‘dpcpp’ from newer versions of oneAPI or with the open source DPC++ compiler. These warning messages manifest the deprecation of some types or APIs in SYCL* 2020 specification. For example,

warning: 'global_buffer' is deprecated: use 'target::device' instead [-Wdeprecated-declarations]

: cl::sycl::access::target::global_buffer);

For such warning messages, to avoid future compilation errors, we suggest you replace the related code fragments in the way described in the warning message.