Skip to content

Commit d2cafd5

Browse files
[SYCL][Doc] Add BKMs for writing in-tree tests (#8145)
1 parent 23bf9c1 commit d2cafd5

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

sycl/doc/developer/ContributeToDPCPP.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,42 @@ end-to-end or SYCL-CTS tests.
106106
107107
- [check-sycl](/sycl/test) target contains 2 types of tests: LIT tests and
108108
unit tests. LIT tests make compile-time checks of DPC++ headers, e.g. device
109-
code IR verification, static_assert tests. Unit tests check DPC++ runtime
109+
code IR verification, `static_assert` tests. Unit tests check DPC++ runtime
110110
behavior and do not perform any device code compilation, instead relying on
111111
redefining plugin API with [PiMock](/sycl/unittests/helpers/PiMock.hpp) when
112112
necessary.
113113
114+
When adding new test to `check-sycl`, please consider the following:
115+
116+
- if you only need to check that compilation succeeds, please use
117+
[`-fsyntax-only`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fsyntax-only)
118+
compiler flag for such tests: it instructs the compiler to launch reduced
119+
set of commands and produce no output (no need to add `-o %t.out`).
120+
121+
- if you are only interested in checking device or host compilation, please use
122+
corresponding flags to reduce the scope of test and therefore speed it up.
123+
To launch only device compilation, use `-fsycl-device-only` compiler flag; to
124+
launch only host compilation, use `%fsycl-host-only` substitution.
125+
126+
- tests which want to check generated device code (either in LLVM IR or SPIR-V
127+
form) should be placed under [check_device_code](/sycl/test/check_device_code)
128+
folder.
129+
130+
- if compiler invocation in your LIT test produces an output file, please make
131+
sure to redirect it into a temporary file using `-o` option and
132+
[`%t`](https://llvm.org/docs/CommandGuide/lit.html#substitutions)
133+
substitution. This is needed to avoid possible race conditions when two LIT
134+
tests attempt to write into the same file.
135+
136+
- if you need to check some runtime behavior please add unit test instead of
137+
LIT test. Unit tests are built with regular C++ compiler which is used to
138+
build the project and therefore they are not affected by `clang++` being slow
139+
when the project is built in Debug mode. As another side effect of using
140+
standard C++ compiler, device side compilation is skipped entirely, making
141+
them quicker to compile. And finally, unit tests are written with
142+
[googletest](https://google.github.io/googletest/primer.html) framework,
143+
which allows to use plenty of useful assertions and other helpers.
144+
114145
### DPC++ end-to-end (E2E) tests
115146
116147
These tests are extension to

0 commit comments

Comments
 (0)