Skip to content

Commit 9dfc681

Browse files
authored
[SYCLomatic] Rename the rules folder for predefined user defined migration rule and add a README file (#2621)
1 parent de3682a commit 9dfc681

27 files changed

+119
-85
lines changed

clang/test/dpct/macro_rule.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: dpct --rule-file=%S/../../tools/dpct/DpctOptRules/macro_checks.yaml --format-range=none -out-root %T/macro_rule %s --cuda-include-path="%cuda-path/include" -- -x cuda --cuda-host-only
1+
// RUN: dpct --rule-file=%S/../../tools/dpct/extensions/opt_rules/macro_checks.yaml --format-range=none -out-root %T/macro_rule %s --cuda-include-path="%cuda-path/include" -- -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/macro_rule/macro_rule.dp.cpp --match-full-lines %s
33
// RUN: %if build_lit %{icpx -c -fsycl %T/macro_rule/macro_rule.dp.cpp -o %T/macro_rule/macro_rule.dp.o %}
44
#include <cuda_runtime.h>

clang/test/dpct/math_specific_UDR_test.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: dpct --rule-file=%S/../../tools/dpct/DpctOptRules/intel_specific_math.yaml --format-range=none -out-root %T/math_specific_UDR_test %s --cuda-include-path="%cuda-path/include" -- -x cuda --cuda-host-only
1+
// RUN: dpct --rule-file=%S/../../tools/dpct/extensions/opt_rules/intel_specific_math.yaml --format-range=none -out-root %T/math_specific_UDR_test %s --cuda-include-path="%cuda-path/include" -- -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/math_specific_UDR_test/math_specific_UDR_test.dp.cpp --match-full-lines %s
33
// RUN: %if build_lit %{icpx -c -fsycl %T/math_specific_UDR_test/math_specific_UDR_test.dp.cpp -o %T/math_specific_UDR_test/math_specific_UDR_test.dp.o %}
44

clang/test/dpct/pytorch/ATen.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: cp -r %S/pytorch_inc %T/pytorch/ATen/
55
// RUN: cd %T/pytorch/ATen
66
// RUN: mkdir dpct_out
7-
// RUN: dpct --out-root dpct_out %T/pytorch/ATen/src/ATen.cu --extra-arg="-I%T/pytorch/ATen/pytorch_inc" --cuda-include-path="%cuda-path/include" --rule-file=%S/../../../tools/dpct/DpctOptRules/pytorch_api.yaml --analysis-scope-path %T/pytorch/ATen/pytorch_inc --analysis-scope-path %T/pytorch/ATen/src --in-root %T/pytorch/ATen/src
7+
// RUN: dpct --out-root dpct_out %T/pytorch/ATen/src/ATen.cu --extra-arg="-I%T/pytorch/ATen/pytorch_inc" --cuda-include-path="%cuda-path/include" --rule-file=%S/../../../tools/dpct/extensions/pytorch_api_rules/pytorch_api.yaml --analysis-scope-path %T/pytorch/ATen/pytorch_inc --analysis-scope-path %T/pytorch/ATen/src --in-root %T/pytorch/ATen/src
88
// RUN: FileCheck --input-file %T/pytorch/ATen/dpct_out/ATen.dp.cpp --match-full-lines %T/pytorch/ATen/src/ATen.cu
99

1010
// CHECK: #include <c10/xpu/XPUStream.h>

clang/test/dpct/pytorch/c10.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: cp -r %S/pytorch_inc %T/pytorch/c10/
55
// RUN: cd %T/pytorch/c10
66
// RUN: mkdir dpct_out
7-
// RUN: dpct -out-root dpct_out %T/pytorch/c10/src/c10.cu --extra-arg="-I%T/pytorch/c10/pytorch_inc" --cuda-include-path="%cuda-path/include" --rule-file=%S/../../../tools/dpct/DpctOptRules/pytorch_api.yaml -- -x cuda --cuda-host-only
7+
// RUN: dpct -out-root dpct_out %T/pytorch/c10/src/c10.cu --extra-arg="-I%T/pytorch/c10/pytorch_inc" --cuda-include-path="%cuda-path/include" --rule-file=%S/../../../tools/dpct/extensions/pytorch_api_rules/pytorch_api.yaml -- -x cuda --cuda-host-only
88
// RUN: FileCheck --input-file %T/pytorch/c10/dpct_out/c10.dp.cpp --match-full-lines %T/pytorch/c10/src/c10.cu
99

1010
#include <iostream>

clang/test/dpct/pytorch/torch.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: cp -r %S/pytorch_inc %T/pytorch/torch/
55
// RUN: cd %T/pytorch/torch
66
// RUN: mkdir dpct_out
7-
// RUN: dpct --out-root dpct_out %T/pytorch/torch/src/torch.cu --extra-arg="-I%T/pytorch/torch/pytorch_inc" --cuda-include-path="%cuda-path/include" --rule-file=%S/../../../tools/dpct/DpctOptRules/pytorch_api.yaml --analysis-scope-path %T/pytorch/torch/pytorch_inc --analysis-scope-path %T/pytorch/torch/src --in-root %T/pytorch/torch/src
7+
// RUN: dpct --out-root dpct_out %T/pytorch/torch/src/torch.cu --extra-arg="-I%T/pytorch/torch/pytorch_inc" --cuda-include-path="%cuda-path/include" --rule-file=%S/../../../tools/dpct/extensions/pytorch_api_rules/pytorch_api.yaml --analysis-scope-path %T/pytorch/torch/pytorch_inc --analysis-scope-path %T/pytorch/torch/src --in-root %T/pytorch/torch/src
88
// RUN: FileCheck --input-file %T/pytorch/torch/dpct_out/torch.dp.cpp --match-full-lines %T/pytorch/torch/src/torch.cu
99

1010
// CHECK: #include <c10/xpu/XPUStream.h>

clang/tools/dpct/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ if (NOT CMAKE_CONFIGURATION_TYPES)
6161
COMPONENT dpct-setvars)
6262
endif()
6363

64-
add_subdirectory(DpctOptRules)
65-
add_subdirectory(RuleTemplates)
64+
add_subdirectory(extensions)
6665

6766
set(dpct_cmake_helper_file
6867
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/cmake/dpct.cmake

clang/tools/dpct/DpctOptRules/CMakeLists.txt

Lines changed: 0 additions & 61 deletions
This file was deleted.

clang/tools/dpct/RuleTemplates/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
set(dpct_opt_rule_files
2+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/opt_rules/forceinline.yaml
3+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/opt_rules/intel_specific_math.yaml
4+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/opt_rules/macro_checks.yaml
5+
)
6+
7+
set(dpct_cmake_rule_files
8+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/cmake_rules/cmake_script_migration_rule.yaml
9+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/cmake_rules/cmake_script_migration_rule_optional.yaml
10+
)
11+
12+
set(dpct_python_rule_files
13+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/python_rules/python_build_script_migration_rule_ipex.yaml
14+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/python_rules/python_build_script_migration_rule_pytorch.yaml
15+
)
16+
17+
set(dpct_pytorch_api_rule_files
18+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/pytorch_api_rules/pytorch_api.yaml
19+
)
20+
21+
set(dpct_rule_template_files
22+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/api_rule.yaml
23+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/class_rule.yaml
24+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/disable_rule.yaml
25+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/enum_rule.yaml
26+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/header_rule.yaml
27+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/macro_rule.yaml
28+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/pattern_rewrite_rule.yaml
29+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/type_rule.yaml
30+
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/rule_templates/helper_function_rule.yaml
31+
)
32+
33+
install(
34+
FILES ${dpct_opt_rule_files}
35+
COMPONENT dpct-rules
36+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
37+
DESTINATION ./extensions/opt_rules)
38+
39+
install(
40+
FILES ${dpct_cmake_rule_files}
41+
COMPONENT dpct-rules
42+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
43+
DESTINATION ./extensions/cmake_rules)
44+
45+
install(
46+
FILES ${dpct_python_rule_files}
47+
COMPONENT dpct-rules
48+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
49+
DESTINATION ./extensions/python_rules)
50+
51+
install(
52+
FILES ${dpct_pytorch_api_rule_files}
53+
COMPONENT dpct-rules
54+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
55+
DESTINATION ./extensions/pytorch_api_rules)
56+
57+
install(
58+
FILES ${dpct_rule_template_files}
59+
COMPONENT dpct-rules
60+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
61+
DESTINATION ./extensions/rule_templates)
62+
63+
install(
64+
FILES ${CMAKE_SOURCE_DIR}/../clang/tools/dpct/extensions/README.md
65+
COMPONENT dpct-rules
66+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
67+
DESTINATION ./extensions)
68+
69+
# Below two install commands are copying those files into some location under
70+
# the build folder, which need be accessed during the LIT.
71+
install(
72+
FILES ${dpct_cmake_rule_files}
73+
COMPONENT dpct-rules
74+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
75+
DESTINATION ${CMAKE_BINARY_DIR}/extensions/cmake_rules)
76+
install(
77+
FILES ${dpct_python_rule_files}
78+
COMPONENT dpct-rules
79+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
80+
DESTINATION ${CMAKE_BINARY_DIR}/extensions/python_rules)
81+
82+
if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
83+
add_llvm_install_targets(install-dpct-rules
84+
COMPONENT dpct-rules)
85+
endif()

clang/tools/dpct/extensions/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Pre-defined rules
2+
This folder provides predefined user-defined migration rules in YAML files, targeted to extend the tool's migration capability. The `rule_templates` folder provides example rules to implement a user migration rule in YAML user can refer to, while other rule folders provide migration rules that can be loaded and applied directly by the tool's option `--rule-files`.
3+
4+
## cmake_rules
5+
This folder provides migration rules for CMake script.
6+
7+
`cmake_script_migration_rule.yaml`: Provides the general migration rules for CMake script migration. This file is loaded by default if the tool is guided to migrate the CMake script (option `--migrate-build-script=CMake` is provided by the user).
8+
9+
`cmake_script_migration_rule_optional.yaml`: Provides extra migration rules for CMake script migration. It is not loaded by default, but please apply it if necessary.
10+
11+
## opt_rules
12+
This folder provides optional migration rules. The migration rules are not loaded by default, but please apply them if necessary.
13+
14+
`forceinline.yaml`: Provides a specific migration rule to migrate `__forceinline__` to `inline` instead of `__dpct_inline__`.
15+
16+
`intel_specific_math.yaml`: Provides migration rules to migrate some math API to Intel(R) hardware-specific API.
17+
18+
`macro_checks.yaml`: Provides a specific migration rule to migrate the error-checking macro `CUDA_CHECK` to `DPCT_CHECK_ERROR.`
19+
20+
## python_rules
21+
This folder provides migration rules for Python script. The migration rules are not loaded by default, but please apply them if necessary.
22+
23+
`python_build_script_migration_rule_ipex.yaml`: provides migration rules to migrate python build script for Pytorch-based projects to work with Intel(R) Extension for PyTorch (IPEX).
24+
25+
`python_build_script_migration_rule_pytorch.yaml`: provides migration rules to migrate Python build script for Pytorch-based projects to work with official PyTorch release with XPU support.
26+
27+
## pytorch_api_rule_rules
28+
`pytorch_api.yaml`: provides migration rules to migrate Pytorch CUDA backend-specific API of Pytorch-based projects to Pytorch backend agnostic API or XPU backend-specific API.

0 commit comments

Comments
 (0)