Skip to content

Commit 19baeb9

Browse files
authored
[SYCLomatic] Add an array size fold warning test case. (#233)
Signed-off-by: Tang, Jiajun [email protected]
1 parent d03ba0a commit 19baeb9

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

behavior_tests/behavior_tests.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<suite>
44
<description> behavior test</description>
55
<tests>
6+
<test testName="array_size_fold" configFile="config/TEMPLATE_behavior_tests.xml" />
67
<test testName="test_soft_link_folder" configFile="config/test_soft_link_folder.xml" />
78
<test testName="execute_from_cuda_path" configFile="config/TEMPLATE_behavior_tests.xml" />
89
<test testName="execute_from_bundle_root" configFile="config/TEMPLATE_behavior_tests.xml" />
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ====------ do_test.py---------- *- Python -* ----===##
2+
#
3+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
# See https://llvm.org/LICENSE.txt for license information.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#
7+
#
8+
# ===----------------------------------------------------------------------===#
9+
import subprocess
10+
import platform
11+
import os
12+
import sys
13+
14+
from test_utils import *
15+
16+
17+
def setup_test():
18+
change_dir(test_config.current_test)
19+
return True
20+
21+
22+
def migrate_test():
23+
call_subprocess(
24+
test_config.CT_TOOL + " test.cu --out-root=out --cuda-include-path=" + test_config.include_path)
25+
26+
with open(os.path.join("out", "test.dp.cpp"), 'r') as f:
27+
ret_str = f.read()
28+
res = True
29+
30+
reference_list = ["'S' expression", "'x' expression", "'sizeof(C) * 3' expression", "'sizeof(x) * 3' expression",
31+
"'sizeof(x * 3) * 3' expression", "'S+1+S' expression"]
32+
for reference in reference_list:
33+
if reference not in ret_str:
34+
res = False
35+
print("there should be a DPCT1101 " + reference + " warning.")
36+
37+
return res
38+
39+
40+
def build_test():
41+
return True
42+
43+
44+
def run_test():
45+
return True
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ====------ test.cu---------- *- CUDA -* ----===////
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//
8+
// ===----------------------------------------------------------------------===//
9+
10+
#define S 3
11+
class C {};
12+
__global__ void f() {
13+
const int x = 2;
14+
__shared__ int fold1[S];
15+
__shared__ int fold2[x];
16+
__shared__ int fold3[sizeof(C) * 3];
17+
__shared__ int fold4[sizeof(x) * 3];
18+
__shared__ int fold5[sizeof(x * 3) * 3];
19+
__shared__ int fold6[S][S+1+S];
20+
__shared__ int unfold1[1 + 1];
21+
__shared__ int unfold2[sizeof(float3) * 3];
22+
}
23+
int main() {
24+
f<<<1, 1>>>();
25+
return 0;
26+
}

0 commit comments

Comments
 (0)