-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][COMPAT] Fix error on headers, add helloworld test #18401
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: sycl
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a build error in the SYCL compat headers and adds an end-to-end test for the basic hello world example while updating the corresponding documentation.
- Fixes header issues causing build failures in SYCLcompat.
- Adds an e2e test (helloworld.cpp) to verify the hello world example.
- Updates the documentation to reflect the changes in header includes and error checking.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
sycl/test-e2e/Compat/helloworld.cpp | Adds an e2e test for the hello world example |
sycl/include/syclcompat/traits.hpp | Updates type alias to use correct item instantiation |
sycl/doc/syclcompat/README.md | Updates header include path and error checking logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this direction. It's just going to diverge very shortly. If you want tests to test examples in documentation, then the correct way to do this is with a tool that parses the documentation and then builds that code, or conversely preprocesses a documentation template to include an external source file.
As it stands this doesn't test the documentation. It tests another piece of code somewhere else in the repository.
Worse: There's no note in the actual test file to say that it needs to be kept in sync with the README so we're pretty much guaranteed divergence unless someone's very careful with the git log...
Which brings up the second point: this PR does not do what the description says. It's described as fixing a header error, but it's actually about testing example code in documentation
Please reconsider this patch.
#!/usr/bin/env python
import sys
import tempfile
import re
import subprocess
ASCIIDOC_HEADER_PATTERN = re.compile(
r'^==+ example (?P<example_name>[0-9]+)\s*$',
re.IGNORECASE | re.UNICODE
)
def parse_example_sections(lines):
sections = {}
i = -1
while i < len(lines) - 1:
i += 1
if not (match := ASCIIDOC_HEADER_PATTERN.match(lines[i])):
continue
if lines[i + 1].strip() != '[source,c++]':
continue
if lines[i + 2].strip() != '----':
continue
start = i + 3
i = start
while i < len(lines) and lines[i].strip() != '----':
i += 1
end = i
sections[match.groupdict()['example_name']] = lines[start:end]
return sections
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'infile', nargs='?',
type=argparse.FileType('r'),
default=sys.stdin
)
known_args, extra_args = parser.parse_known_args()
examples = parse_example_sections(known_args.infile.readlines())
for example, source in examples.items():
source = ''.join(source)
print(f"compiling example {example}:")
print(source)
print("-------------------------------------------")
with tempfile.NamedTemporaryFile(suffix='.cpp', delete=False) as f:
f.write(source.encode('utf-8'))
f.flush()
subprocess.check_call(['clang++', '-fsycl',
'-fsycl-targets=amdgcn-amd-amdhsa',
'-Xsycl-target-backend=amdgcn-amd-amdhsa', '--offload-arch=gfx1032',
'--rocm-path=/home/luke/h/hip/install'] + extra_args + [f.name])
subprocess.check_call(['./a.out'])
print(f"{example} passed") Here's one I wrote for local testing of example code in a sycl extension doc I worked on. Should be simple to adapt the idea to markdown |
Thanks for the script. For this particular PR, I am just going to remove the actual sample code from the README and change it as a link to the test. |
@ldrumm , just to clarify, the patch fixes the error, see the traits.hpp file. It also adds a test to make sure the error does not get re-introduced. I could split the two things in two patches, but I rather have the bug and the test to prevent it together. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
364ab7f
to
449ef83
Compare
This PR fixes an error on the SYCL compat headers that caused build to fail.
The error manifests when building the basic hello world from the documentation.
To prevent the basic hello world from failing again, this PR adds an e2e for the basic hello world
and updates the documentation to match the updated hello world source code.