Skip to content

[NFC][SYCL] Re-format python files using "black" #12240

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
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions sycl/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,68 @@

now = datetime.datetime.now()

project = 'oneAPI DPC++ Compiler'
copyright = str(now.year) + ', Intel Corporation'
author = 'Intel Corporation'
project = "oneAPI DPC++ Compiler"
copyright = str(now.year) + ", Intel Corporation"
author = "Intel Corporation"

# -- General configuration ---------------------------------------------------

master_doc = 'index'
master_doc = "index"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'myst_parser'
]
extensions = ["myst_parser"]

# Implicit targets for cross reference
myst_heading_anchors = 5

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'friendly'
pygments_style = "friendly"

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'haiku'
html_theme = "haiku"

# The suffix of source filenames.
source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

exclude_patterns = [
# Extensions are mostly in asciidoc which has poor support in Sphinx.
'extensions/*',
'design/opencl-extensions/*',
'design/spirv-extensions/*',

"extensions/*",
"design/opencl-extensions/*",
"design/spirv-extensions/*",
# Sphinx complains about syntax errors in these files.
'design/DeviceLibExtensions.rst',
'design/SYCLPipesLoweringToSPIRV.rst',
'design/fpga_io_pipes_design.rst',
'design/Reduction_status.md'
"design/DeviceLibExtensions.rst",
"design/SYCLPipesLoweringToSPIRV.rst",
"design/fpga_io_pipes_design.rst",
"design/Reduction_status.md",
]

suppress_warnings = [ 'misc.highlighting_failure' ]
suppress_warnings = ["misc.highlighting_failure"]


def on_missing_reference(app, env, node, contnode):
# Get the directory that contains the *source* file of the link. These
# files are always relative to the directory containing "conf.py"
# (<top>/sycl/doc). For example, the file "sycl/doc/design/foo.md" will
# have a directory "design".
refdoc_components = node['refdoc'].split('/')
dirs = '/'.join(refdoc_components[:-1])
if dirs: dirs += '/'
refdoc_components = node["refdoc"].split("/")
dirs = "/".join(refdoc_components[:-1])
if dirs:
dirs += "/"

# A missing reference usually occurs when the target file of the link is
# not processed by Sphinx. Compensate by creating a link that goes to the
# file's location in the GitHub repo.
new_target = "https://github.com/intel/llvm/tree/sycl/sycl/doc/" + dirs + \
node['reftarget']
new_target = (
"https://github.com/intel/llvm/tree/sycl/sycl/doc/" + dirs + node["reftarget"]
)

newnode = nodes.reference('', '', internal=False, refuri=new_target)
newnode = nodes.reference("", "", internal=False, refuri=new_target)
newnode.append(contnode)
return newnode


def setup(app):
app.connect('missing-reference', on_missing_reference)
app.connect("missing-reference", on_missing_reference)
1 change: 0 additions & 1 deletion sycl/gdb/libsycl.so-gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ def __next__(self):
return ("[%d]" % count, elt)

def __init__(self, value):

self.value = value
if self.value.type.code == gdb.TYPE_CODE_REF:
self.type = value.referenced_value().type.unqualified().strip_typedefs()
Expand Down
28 changes: 18 additions & 10 deletions sycl/plugins/level_zero/ze_api_generator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import re
import sys


def camel_to_snake(src):
return re.sub(r'(?<!^)(?=[A-Z])', '_', src).lower()
return re.sub(r"(?<!^)(?=[A-Z])", "_", src).lower()


def snake_to_camel(src):
temp = src.split('_')
return ''.join(x.title() for x in temp)
temp = src.split("_")
return "".join(x.title() for x in temp)


def extract_ze_apis(header):
Expand All @@ -16,25 +18,31 @@ def extract_ze_apis(header):
"""
api = open("ze_api.def", "w")

matches = re.finditer(r'typedef struct _ze_([_a-z]+)_callbacks_t\n\{\n([a-zA-Z_;\s\n]+)\n\} ze_([_a-z]+)_callbacks_t;', header)
matches = re.finditer(
r"typedef struct _ze_([_a-z]+)_callbacks_t\n\{\n([a-zA-Z_;\s\n]+)\n\} ze_([_a-z]+)_callbacks_t;",
header,
)

for match in matches:
api_domain = snake_to_camel(match.group(1))
for l in match.group(2).splitlines():
parts = l.split()
api_match = re.match(r'ze_pfn([a-zA-Z]+)Cb_t', parts[0])
api_match = re.match(r"ze_pfn([a-zA-Z]+)Cb_t", parts[0])
api_name_tail = api_match.group(1)
api_name = 'ze' + api_name_tail
api_name = "ze" + api_name_tail

param_type = 'ze_' + camel_to_snake(api_name_tail) + '_params_t'
param_type = "ze_" + camel_to_snake(api_name_tail) + "_params_t"

cb = 'pfn' + api_name_tail.replace(api_domain, '') + 'Cb'
cb = "pfn" + api_name_tail.replace(api_domain, "") + "Cb"

api.write("_ZE_API({}, {}, {}, {})\n".format(api_name, api_domain, cb, param_type))
api.write(
"_ZE_API({}, {}, {}, {})\n".format(api_name, api_domain, cb, param_type)
)

api.close()


if __name__ == "__main__":
with open(sys.argv[1], 'r') as f:
with open(sys.argv[1], "r") as f:
header = f.read()
extract_ze_apis(header)
Loading