Skip to content

[SYCL][NFC] Use -fsyntax-only more extensively in LIT tests #8144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AlexeySachkov
Copy link
Contributor

Adjusted LIT tests to use syntax-only mode for some tests which perform full compilation and linking or only compilation (-c) to speed up those tests.

Also removed -o option from some existing -fsyntax-only mode to shorten RUN lines, because it is anyway ignored by the compiler.

Refactored some tests for predefined macro to make checks at compile-time and not at runtime.

Adjusted LIT tests to use syntax-only mode for some tests which perform
full compilation and linking or only compilation (`-c`) to speed up
those tests.

Also removed `-o` option from some existing `-fsyntax-only` mode to
shorten `RUN` lines, because it is anyway ignored by the compiler.
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: sometimes, the intention can be to test compiler's IR generation as well.
I don't know if any of the tests you updated requires this.

@AlexeySachkov
Copy link
Contributor Author

FYI: sometimes, the intention can be to test compiler's IR generation as well. I don't know if any of the tests you updated requires this.

Yes, I'm aware of such tests and haven't touched any of them in this PR.

@bader
Copy link
Contributor

bader commented Jan 30, 2023

Okay, did you look at extensions/macro_cuda.cpp failure?

@AlexeySachkov
Copy link
Contributor Author

AlexeySachkov commented Jan 30, 2023

Okay, did you look at extensions/macro_cuda.cpp failure?

I think I made a mistake by moving macro check above sycl/sycl.hpp include. I will take a look at macro definition and fix the test.

UPD: should be fixed by 58e43ed

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue I see with this approach is inability to verify all explicit instantiations are in place. Missing ones manifest themselves at link time only with undefined symbols.

// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s -o %t.out
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s -o %t.out
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note -D__SYCL_INTERNAL_API -DSYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this particular file, it's just when I realized it... What if a mistake is done inside the pi.def-related mapping and some symbol/offset is missing, would -fsyntax-only catch that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, it is likely that SYCL RT (or unit-tests) won't be built at all.

For example, if you add something new into pi.def, but not anywhere else, then the following piece of code will try to reference non-existing function:

struct FunctionPointers {
#define _PI_API(api) decltype(::api) *api;
#include <sycl/detail/pi.def>
} PiFunctionTable;

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised to see dynamic asserts in this test (lines 56/57). Unrelated to this PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was added like this in #4458. We should probably be more careful when reviewing tests and perhaps we should do another round of tests review to refactor them, i.e.:

  • move to llvm-test-suite anything which requires actual devices
  • and/or rewrite that to unit-tests
  • remove runtime checks from -fsyntax-only tests to simplify and cleanup them

@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -c %s -o %t.out -Wno-deprecated -fno-operator-names
// RUN: %clangxx -fsycl -fsyntax-only %s -Wno-deprecated -fno-operator-names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 7?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not appear to respect the -fno-operator-names option

What does it mean? Modified test passes.

I suggest we a use of operator name in the test itself and add --verify option with checks that operator names are used in the test, but no detected in the headers.

BTW, I suppose DPC++ extensions, which are not implicitly included by <sycl/sycl.hpp> should be tested as well. Right?

@Pennycook, FYI.

Copy link
Contributor Author

@AlexeySachkov AlexeySachkov Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the comment on line 7 is not correct. From my local experiments:

$ ./bin/clang++ -fsyntax-only t.cpp -fno-operator-names
t.cpp:2:13: error: expected ')'
  if (a > b and b >c ) {
            ^
t.cpp:2:6: note: to match this '('
  if (a > b and b >c ) {
     ^
1 error generated.
$ ./bin/clang++ -fsyntax-only t.cpp -foperator-names
$ echo $?
0

UPD: -fsycl doesn't alter the behavior, -fno-operator-names still works as expected with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the comment in b29ae74

@AlexeySachkov AlexeySachkov temporarily deployed to aws January 30, 2023 17:43 — with GitHub Actions Inactive
@AlexeySachkov AlexeySachkov temporarily deployed to aws January 30, 2023 19:05 — with GitHub Actions Inactive
@AlexeySachkov AlexeySachkov temporarily deployed to aws January 30, 2023 21:07 — with GitHub Actions Inactive
@AlexeySachkov AlexeySachkov temporarily deployed to aws January 30, 2023 21:45 — with GitHub Actions Inactive
@AlexeySachkov AlexeySachkov temporarily deployed to aws January 31, 2023 11:22 — with GitHub Actions Inactive
@AlexeySachkov AlexeySachkov temporarily deployed to aws January 31, 2023 11:53 — with GitHub Actions Inactive
@AlexeySachkov AlexeySachkov merged commit 7f24cac into intel:sycl Jan 31, 2023
@AlexeySachkov AlexeySachkov deleted the private/asachkov/use-fsyntax-only branch March 29, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants