Skip to content

Commit d53253c

Browse files
[SYCLomatic][Doc] Add CMake script migration section in Velocity-Bench/cudaSift/README.md (#679)
Signed-off-by: chenwei.sun <[email protected]> Co-authored-by: Wang, Zhiming <[email protected]>
1 parent aba7e10 commit d53253c

File tree

1 file changed

+68
-2
lines changed
  • third-party-programs/Velocity-Bench/cudaSift

1 file changed

+68
-2
lines changed

third-party-programs/Velocity-Bench/cudaSift/README.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This file lists the detail steps to migrate CUDA version of [cudaSift](https://g
2020
$ export cudaSift_HOME=/path/to/Velocity-Bench/cudaSift
2121
$ sudo apt-get install libopencv-dev # make sure ```OpenCV*``` is installed on the machine.
2222
$ cd ${cudaSift_HOME}/CUDA && mkdir build
23-
$ cd build && cmake .. # make sure all dependency library are installed.
23+
$ cd build && cmake -DUSE_SM=80 .. # make sure all dependency library are installed.
2424
```
2525
Summary of cudaSift project source code: 12 files in CUDA folder
2626

@@ -70,6 +70,8 @@ $ ls compile_commands.json # make sure compile_commands.json is generated
7070
compile_commands.json
7171
```
7272
### 3 Migrate the source code and build script
73+
**Follow section 3.1 or section 3.2 to migrate the source code and corresponding build scripts.**
74+
## 3.1 Migrate the source code and generate build script `Makefile.dpct`
7375
```sh
7476
# From the CUDA directory as root directory:
7577
$ cd ${cudaSift_HOME}/CUDA
@@ -100,6 +102,70 @@ Now you can see the migrated files in the `out` folder as follow:
100102
└── matching.dp.cpp
101103
102104
```
105+
106+
## 3.2 Migrate the source code and CMake build script
107+
### 3.2.1 Migrate the source code
108+
Run the migration command below to generate SYCL version cudaSift code:
109+
```sh
110+
$ dpct --in-root=. -p=./build/compile_commands.json --out-root=out --gen-build-script --cuda-include-path=/usr/local/cuda/include
111+
```
112+
### 3.2.2 Migrated the CMake build script
113+
Apply option "--migrate-build-script-only" to the migration command as follows to migrate the CMake build script:
114+
```
115+
$ dpct --in-root=. -p=./build/compile_commands.json --out-root=out --gen-build-script --cuda-include-path=/usr/local/cuda/include --migrate-build-script-only
116+
```
117+
Or, CMake script can be migrated together with cudaSift source code with the option "--migrate-build-script=CMake" as follows:
118+
```sh
119+
$ dpct --in-root=. -p=./build/compile_commands.json --out-root=out --gen-build-script --cuda-include-path=/usr/local/cuda/include --migrate-build-script=CMake
120+
```
121+
### 3.2.3 Apply necessary manual fix to SYCL version CMake build script
122+
Do the following changes to the migrated CMake script in the `out` directory:
123+
```
124+
diff --git /path/to/cuda/CMakeLists.txt /path/to/SYCL/CMakeLists.txt
125+
index d1e4b6d..ba85f53 100644
126+
--- a/CMakeLists.txt
127+
+++ b/CMakeLists.txt
128+
@@ -56,13 +56,13 @@ set(cuda_sources
129+
)
130+
131+
set(sources
132+
- ${CMAKE_SOURCE_DIR}/../common/Utility.cpp
133+
+ ${CMAKE_SOURCE_DIR}/common/Utility.cpp
134+
geomFuncs.cpp
135+
mainSift.cpp.dp.cpp
136+
)
137+
138+
include_directories(
139+
- ${CMAKE_SOURCE_DIR}/../common/
140+
+ ${CMAKE_SOURCE_DIR}/common/
141+
${CMAKE_CURRENT_SOURCE_DIR}
142+
)
143+
144+
```
145+
Also copy the `common` directory to the `out` directory, using the following commands:
146+
```sh
147+
$cd ${cudaSift_HOME}/CUDA/out
148+
$cp ../../common/ ./ -r
149+
```
150+
### 3.2.4 Build the SYCL version cudaSift code with CMake build script
151+
In the `out` directory, use the following commands to build the SYCL version cudaSift:
152+
```sh
153+
$mkdir -p build
154+
$cd build
155+
$cmake -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DUSE_SM=80 -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
156+
$make
157+
```
158+
After build, the binary `cudasift` is generated in the directory `${cudaSift_HOME}/CUDA/out/build`
159+
### 3.2.5 Run the SYCL version cudaSift
160+
As the path of test data is relative to the path of CUDA version binary, the SYCL version binary should be moved to the same level directory where the CUDA version binary lies.
161+
Run the following commands to run the SYCL version binary.
162+
```
163+
$cp cudasift ../../build/cudasift_sycl.run
164+
$cd ../../build
165+
$./cudasift_sycl.run
166+
```
167+
168+
103169
### 4 Review the migrated source code and fix all `DPCT` warnings
104170

105171
SYCLomatic and [Intel® DPC++ Compatibility Tool](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compatibility-tool.html) define a list of `DPCT` warnings and embed the warning in migrated source code if need manual effort to check. All the warnings in the migrated code should be reviewed and fixed. For detail of `DPCT` warnings and corresponding fix examples, refer to [Intel® DPC++ Compatibility Tool Developer Guide and Reference](https://www.intel.com/content/www/us/en/develop/documentation/intel-dpcpp-compatibility-tool-user-guide/top/diagnostics-reference.html) or [SYCLomatic doc page](https://oneapi-src.github.io/SYCLomatic/dev_guide/diagnostics-reference.html).
@@ -153,7 +219,7 @@ If an error occurs during runtime, refer to [Diagnostics Utility for Intel® one
153219
* Command Line Options of [SYCLomatic](https://oneapi-src.github.io/SYCLomatic/dev_guide/command-line-options-reference.html) or [Intel® DPC++ Compatibility Tool](https://software.intel.com/content/www/us/en/develop/documentation/intel-dpcpp-compatibility-tool-user-guide/top/command-line-options-reference.html)
154220
* [oneAPI GPU Optimization Guide](https://www.intel.com/content/www/us/en/docs/oneapi/optimization-guide-gpu/)
155221
* [SYCLomatic project](https://github.com/oneapi-src/SYCLomatic/)
156-
222+
* [Migrate a CMake Build Script](https://github.com/oneapi-src/SYCLomatic/blob/SYCLomatic/docs/dev_guide/migration/migrate-cmake-build.rst)
157223

158224
## Trademarks information
159225
Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries.<br>

0 commit comments

Comments
 (0)