Use Make/CMake* to Migrate a Complete Project
If your project uses Make or CMake, you can utilize compilation database support
to provide compilation options, settings, macro definitions, and include paths
to the Intel® DPC++ Compatibility Tool.
The compilations database is a JSON* file containing the commands required to
build a particular project. A compilation database can be generated by running
script, which is provided as part of the
Intel® DPC++ Compatibility Tool.
supports the capture of compilation
command lines for files with the following extensions:
The Intel® DPC++ Compatibility Tool parses the compilation database and applies the necessary
options when migrating the input sources.
This example uses the Rodinia NW DPCT sample to demonstrate the use of a
Step 1: Create the Compilation Database
Open the Rodinia NW DPCT sample in one of the following ways:
When using CMake: Before running
, configure and generate
your Makefile out of
. An example of a typical command is
Invoke the build command, prepending it with
script runs your project’s build command without building
the original program. It records all the compiler invocations and stores the
names of the input files and the compiler options in the compilation database file:
This example assumes the CUDA headers are available at
Replace this path according to where they reside on your system.
is run, review the output in the
file. The content of this file should look like
"command" : "nvcc -c -o needle -I/usr/local/cuda/include -D__CUDA_ARCH__=400 "
"directory" : "/home/user/projects/DPCPP_CT/rodinia_3.1/cuda/nw",
"file" : "/home/user/projects/DPCPP_CT/rodinia_3.1/cuda/nw/needle.cu"
Step 2: Use the Compilation Database with the Intel® DPC++ Compatibility Tool
By default, the Intel® DPC++ Compatibility Tool looks for the
in the current directory and uses the compiler options from it for each input file.
The location of the compilation database file can be changed using the
For example, the following command will migrate
information about it can be found in
, located at
dpct -p=some_path --in-root=../.. --out-root=dpct_output some_file.cu
To migrate all relevant files recorded inside the compilation database, use
a command similar to:
dpct -p compile_commands.json --in-root=. --out-root=migration
If you run the command above with the Rodinia NW DPCT sample, you
should see the following files in the
Step 3: Verify the Source for Correctness and Fix Anything the Intel® DPC++
Compatibility Tool was Unable to Migrate
Verify the migration of the source code that uses variables declared
using preprocessor directives. Inspect the migrated source code, address any
generated DPCT warnings, and verify correctness of the new program.
Review Emitted Warnings
for additional information about inserted warnings
For the most accurate and detailed instructions on addressing warnings, see the
Addressing Warnings in the Migrated Code
section of the samples README files.