Developer Guide and Reference

  • 2021.3
  • 06/28/2021
  • Public Content

Frequently Asked Questions

This page contains the most frequently asked questions about the Intel® DPC++ Compatibility Tool.

General Information

How do I migrate source files that are using C++11 or newer C++ standard features on Linux* and Windows*?
On Linux, the default C++ standard for the Intel® DPC++ Compatibility Tool’s parser is C++98, with some C++11 features accepted. If you want to enable other C++11 or newer standard features in the Intel® DPC++ Compatibility Tool, you need to add the
--extra-arg="-std=<value>"
option to the command line. The supported values are:
  • c++11
  • c++14
  • c++17
On Windows, the default C++ standard for the Intel® DPC++ Compatibility Tool’s parser is C++14. If you want to enable C++17 features in the Intel® DPC++ Compatibility Tool, you need to add the option
--extra-arg="-std=c++17"
to the command line.
How do I migrate files on Windows when using a CMake project?
For a CMake project on a Windows OS, you can use CMake to generate Microsoft Visual Studio* project files (
vcxproj
files). Then choose one of the following options:
  • Migrate the source files on the command line by using the
    --vcxprojfile
    option of the Intel® DPC++ Compatibility Tool.
  • Migrate the entire project in Microsoft Visual Studio with an Intel® DPC++ Compatibility Tool Microsoft Visual Studio plugin.
How is the migrated code formatted?
The Intel® DPC++ Compatibility Tool provides two options to control the format of migrated code:
--format-range
and
--format-style
.
If input source code is well formatted, the Intel® DPC++ Compatibility Tool will use default options settings
--format-range
and
--format-style
to format the resulting code.
If input source code is not well formatted (for example, the tool detects mixed use of tabs and spaces or mixed indents) you can do one of the following:
  • The Intel® DPC++ Compatibility Tool will try to detect the indent size of the original code and apply it to the resulting code. You can guide the tool by setting
    TabWidth
    and
    UseTab
    in the
    .clang-format
    file. Because the input source code is not well formatted, the indents in the resulting code may still be inconsistent.
  • Run the Intel® DPC++ Compatibility Tool with the
    --format-range=all
    option to format the entire resulting file. The change between input source code and resulting source code may be large and make it more difficult to compare the code.
  • Format your input source code, then use the Intel® DPC++ Compatibility Tool with the same
    .clang-format
    file for migration.
Why does the compilation database (compile_commands.json) not contain all source file(s) in the project?
In the project build folder, the command
intercept-build make [target]
is used to generate the compilation database. The content of the compilation database depends on the optional [target] parameter. If you need to get the list of files corresponding to default build target, do not specify the [target] parameter.
How do I use the migrated module file in the new project?
.cu
module files are compiled with the
-ptx
or
-cubin
options in the original project and dynamically loaded into other
*.cu
files with
cuModuleLoad()
or
cuModuleLoadData()
.
The Intel® DPC++ Compatibility Tool migrates module file code in the same way as other
*.cu
files. In addition, it adds a wrapper function for each function in the module file that has the
_global_
attribute.
You can compile the migrated module file into a dynamic library and load the library with a dynamic library API appropriate to your platform. For example:
  • In Linux, load a dynamic library (
    .so
    ) using
    dlopen()
  • In Windows, load a dynamic library (
    .dll
    ) using
    LoadLibraryA()

Troubleshooting

How do I fix an error such as “error: unknown type name” when I migrate files with “dpct –in-root=srcdir –out-root=dstdir *.cu”?
The problem may be caused by files in the
*.cu
list, which can be used as header files (included with an
#include
statement) and are not supposed to be parsed as a standalone file. In this case, the Intel® DPC++ Compatibility Tool reports an error if it cannot parse the file because the file depends on the definitions/declarations in other files. Use one of the methods below to migrate your content:
  • Rely on the Intel® DPC++ Compatibility Tool to decide which files to migrate with:
    compile_commands.json: “dpct -p=compile_commands.json --in-root=srcdir --out-root=dstdir”
  • Manually pass specific files to migrate, but do not pass the files that are included in other files and not supposed to be compiled as a standalone file in the original application. The header files are migrated automatically when they are included by the files provided as the input to the tool and are located within the
    in-root
    folder:
    dpct --in-root= srcdir --out-root=dstdir sample.cu
How do I fix a parsing error such as “no member named ‘max’ in namespace ‘std’” or “no member named ‘min’ in namespace ‘std’” when migrating code on Windows?
Use one of the following methods to resolve the error:
  • Add
    #include <algorithm>
    to the source file before using
    std::min
    and
    std::max
  • Define the NOMINMAX macro by inserting
    #define NOMINMAX
    before including
    WinDef.h
How do I fix a compilation error such as “error: dlopen not declared” when I compile code on a Windows machine, that was originally migrated on Linux?
When the Intel® DPC++ Compatibility Tool generates the source code, it uses dynamic loading APIs specific to the OS on which the Intel® DPC++ Compatibility Tool is running.
For example,
dlopen
,
dlclose
, and
dlsym
are used on Linux and
LoadLibraryA
,
FreeLibrary
, and
GetProcAddress
are used on Windows.
If your code was migrated on a OS that is different from the OS you need to compile the generated code on, migrate the project again with the Intel® DPC++ Compatibility Tool on the target OS or fix the code manually.
Why didn’t the “atomic*” APIs get migrated?
The Intel® DPC++ Compatibility Tool may assume that the “atomic*” APIs are user-defined APIs, in which case they are not migrated.
This can occur in the following scenarios:
  • The CUDA include path is specified by both
    --cuda-include-path
    and
    -I*
    , but the paths are different
  • The CUDA include path is specified by
    -I*
    , but there are other CUDA include files located on the default CUDA install path
To make sure “atomic*” APIs are migrated, don’t use
-I*
to specify the CUDA include path with the
dpct
migration command. Instead, use only
--cuda-include-path
to specify the CUDA include path.
Why did my migration fail with “error: restrict requires a pointer or reference”?
The C++ standard does not support the restrict qualifier and the C standard supports the restrict qualifier only on pointers to an object type.
Based on these language standards the Intel® DPC++ Compatibility Tool emits the parsing error.
You may need to adjust the source code.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.