Skip to content

Commit 77472b1

Browse files
authored
[SYCLomatic] Fix bug that dpct.cmake is copied into out-root directory when both --migrate-build-script=Python and --migrate-build-script-onlyare specified (#2811)
Signed-off-by: chenwei.sun <chenwei.sun@intel.com>
1 parent 4f2e898 commit 77472b1

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

clang/lib/DPCT/DPCT.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ static void loadMainSrcFileInfo(clang::tooling::UnifiedPath OutRoot) {
525525
llvm::errs() << getLoadYamlFailWarning(YamlFilePath);
526526
}
527527

528-
if (MigrateBuildScriptOnly || DpctGlobalInfo::migrateCMakeScripts()) {
528+
if (MigrateBuildScriptOnly && !DpctGlobalInfo::migratePythonScripts() ||
529+
DpctGlobalInfo::migrateCMakeScripts()) {
529530
std::string Major = PreTU->SDKVersionMajor;
530531
std::string Minor = PreTU->SDKVersionMinor;
531532
if (!Major.empty() && !Minor.empty()) {
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
MainSourceFile: '/path/to/MainSrcFiles_placehold'
3+
Replacements:
4+
- FilePath: '/path/to/src/foo.cpp'
5+
Offset: 0
6+
Length: 0
7+
ReplacementText: ''
8+
ConstantFlag: ''
9+
ConstantOffset: 0
10+
InitStr: ''
11+
NewHostVarName: ''
12+
BlockLevelFormatFlag: false
13+
- FilePath: '/path/to/src/baz.cpp'
14+
Offset: 0
15+
Length: 0
16+
ReplacementText: ''
17+
ConstantFlag: ''
18+
ConstantOffset: 0
19+
InitStr: ''
20+
NewHostVarName: ''
21+
BlockLevelFormatFlag: false
22+
23+
MainSourceFilesDigest:
24+
- MainSourceFile: '/path/to/src/foo.cpp'
25+
Digest: e2636fb8d174ac319083b0306294d3bd
26+
HasCUDASyntax: true
27+
- MainSourceFile: '/path/to/src/baz.cpp'
28+
Digest: 991d7e4825fc597205bf68f2eda27acd
29+
HasCUDASyntax: true
30+
- MainSourceFile: '/path/to/src/layer.cudnn.cpp'
31+
Digest: 991d7e4825fc597205bf68f2eda27ace
32+
HasCUDASyntax: true
33+
- MainSourceFile: '/path/to/chash/chash.c'
34+
Digest: 9f681b5a2cafa7dff67d7e4ac13d1302
35+
HasCUDASyntax: true
36+
- MainSourceFile: '/path/to/cchash/cchash.cc'
37+
Digest: 9f681b5a2cafa7dff67d7e4ac13d1303
38+
HasCUDASyntax: true
39+
- MainSourceFile: '/path/to/cxxhash/cxxhash.cxx'
40+
Digest: 9f681b5a2cafa7dff67d7e4ac13d1304
41+
HasCUDASyntax: true
42+
- MainSourceFile: '/path/to/cxxhash/cpphash.cpp'
43+
Digest: 9f681b5a2cafa7dff67d7e4ac13d1305
44+
HasCUDASyntax: true
45+
- MainSourceFile: '/path/to/chash/chash.c'
46+
Digest: 9f681b5a2cafa7dff67d7e4ac13d1302
47+
HasCUDASyntax: false
48+
DpctVersion: 19.0.0
49+
SDKVersionMajor: '12'
50+
SDKVersionMinor: '0'
51+
MainHelperFileName: ''
52+
USMLevel: ''
53+
FeatureMap: {}
54+
CompileTargets: {}
55+
OptionMap:
56+
AnalysisScopePath:
57+
Value: '/path/to//target'
58+
Specified: false
59+
AsyncHandler:
60+
Value: 'false'
61+
Specified: false
62+
BuildScript:
63+
Value: '1'
64+
Specified: true
65+
CodePinEnabled:
66+
Value: 'false'
67+
Specified: false
68+
CommentsEnabled:
69+
Value: 'false'
70+
Specified: false
71+
CompilationsDir:
72+
Value: '/path/to/build'
73+
Specified: true
74+
CtadEnabled:
75+
Value: 'false'
76+
Specified: false
77+
EnablepProfiling:
78+
Value: 'true'
79+
Specified: true
80+
ExperimentalFlag:
81+
Value: '16384'
82+
Specified: true
83+
ExplicitNamespace:
84+
Value: '20'
85+
Specified: false
86+
ExtensionDDFlag:
87+
Value: '0'
88+
Specified: false
89+
ExtensionDEFlag:
90+
Value: '4294967295'
91+
Specified: false
92+
RuleFile:
93+
Value: ''
94+
ValueVec:
95+
- '/path/to/cmake_script_migration_rule.yaml'
96+
Specified: false
97+
SyclNamedLambda:
98+
Value: 'false'
99+
Specified: false
100+
UsmLevel:
101+
Value: '1'
102+
Specified: false
103+
...

clang/test/dpct/python_migration/case_006/case_006_torch_cuda.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@
77

88
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --migrate-build-script=Python --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml
99
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_ipex/input.py >> %T/diff.txt
10+
11+
// RUN: mkdir -p %T/out_pytorch1
12+
// RUN: cp %S/MainSourceFiles.yaml %T/out_pytorch1/MainSourceFiles.yaml
13+
// RUN: dpct -in-root ./ -out-root out_pytorch1 ./input.py --migrate-build-script-only --migrate-build-script=Python --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_pytorch.yaml
14+
// dpct.cmake should not be copied into %T/out_pytorch1 direcotrtory.
15+
// RUN: test ! -f %T/out_pytorch1/dpct.cmake

0 commit comments

Comments
 (0)