Skip to content

Commit e598714

Browse files
authored
[SYCLomatic] Update test case for verifying no dpct helper function (#586)
Signed-off-by: Wang, Hao3 <hao3.wang@intel.com>
1 parent 2703099 commit e598714

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed

behavior_tests/behavior_tests.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
<test testName="bt-gen-helper-function" configFile="config/TEMPLATE_behavior_tests_win.xml" />
165165
<test testName="bt-language-warning" configFile="config/TEMPLATE_behavior_tests.xml" />
166166
<test testName="bt-check-unexpected-message" configFile="config/TEMPLATE_behavior_tests.xml" />
167+
<test testName="bt-no-dpct-helper-function" configFile="config/TEMPLATE_behavior_tests.xml" />
167168
<test testName="cmp-cmds-linker-entry-src-files" configFile="config/TEMPLATE_behavior_tests_lin.xml" />
168169
<test testName="cmake_dpct_helper_compile_sycl_code" configFile="config/TEMPLATE_behavior_tests.xml" />
169170
</tests>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
def setup_test():
17+
change_dir(test_config.current_test)
18+
return True
19+
20+
def migrate_test():
21+
call_subprocess(test_config.CT_TOOL + " --out-root=./sycl test.cu --cuda-include-path=" + test_config.include_path)
22+
return True
23+
def build_test():
24+
with open("./sycl/test.dp.cpp", "r") as f:
25+
# check migrated code content
26+
content = f.read()
27+
if "dpct::" in content:
28+
print("the migrated code should not contain 'dpct::':")
29+
print(content)
30+
print("case fail")
31+
return False
32+
else:
33+
print("case pass")
34+
return True
35+
36+
def run_test():
37+
return True
38+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
#include <cuda_runtime.h>
11+
12+
__global__ void VectorAddKernel(float* A, float* B, float* C)
13+
{
14+
A[threadIdx.x] = threadIdx.x + 1.0f;
15+
B[threadIdx.x] = threadIdx.x + 1.0f;
16+
C[threadIdx.x] = A[threadIdx.x] + B[threadIdx.x];
17+
}
18+
19+
void foo() {
20+
float *d_A, *d_B, *d_C;
21+
int vector_size = 100;
22+
cudaMalloc(&d_A, vector_size*sizeof(float));
23+
cudaMalloc(&d_B, vector_size*sizeof(float));
24+
cudaMalloc(&d_C, vector_size*sizeof(float));
25+
26+
VectorAddKernel<<<1, vector_size>>>(d_A, d_B, d_C);
27+
}

user_guide_samples/src/vector_add/vector_add.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@
4747

4848
print("Build done!!")
4949
if subprocess.check_output(out_exe, shell=run_shell).decode().replace("\r\n", "\n")==result.decode():
50-
with open(default_out_root + "/vector_add.dp.cpp", "r") as f:
51-
# check migrated code content
52-
content = f.read()
53-
if "dpct::" in content:
54-
print("the migrated code should not contain 'dpct::':")
55-
print(content)
56-
print("case fail")
57-
else:
58-
print("case pass")
50+
print("case pass")
5951
else:
6052
print("case fail")

0 commit comments

Comments
 (0)