Skip to content
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

Add clang-tidy checks, runtime and compile time information, a C++ kernel test #253

Merged
merged 48 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b6569dc
Update Util; Update doc
chaeyeunpark Mar 10, 2022
1f9590b
Add tests
chaeyeunpark Mar 10, 2022
66ceab5
Add runtime/compile info in binary
chaeyeunpark Mar 10, 2022
d237ceb
Auto update version
chaeyeunpark Mar 10, 2022
386edb6
Fix for non-biary
chaeyeunpark Mar 10, 2022
db00391
Merge branch 'pre_better_kernel_dispatch' of github.com:PennyLaneAI/p…
chaeyeunpark Mar 10, 2022
cd9027f
Format
chaeyeunpark Mar 10, 2022
da3d9ec
Update tidy
chaeyeunpark Mar 10, 2022
6f7d770
Fix for tidy
chaeyeunpark Mar 10, 2022
16df125
Trigger CI
chaeyeunpark Mar 10, 2022
6908f20
Futher update in tests
chaeyeunpark Mar 10, 2022
fd2c3f6
Apply suggestions from code review
chaeyeunpark Mar 14, 2022
de62ece
Update pennylane_lightning/src/bindings/Bindings.cpp
chaeyeunpark Mar 14, 2022
6507b59
Fix PLApprox
chaeyeunpark Mar 14, 2022
1c450d2
Update pennylane_lightning/src/tests/CreateAllWires.cpp
chaeyeunpark Mar 14, 2022
131c626
Fix createAllWires; Add NVCC/NVHPC compiler info
chaeyeunpark Mar 14, 2022
02b5e33
Fix
chaeyeunpark Mar 14, 2022
351841c
Add test for squaredNorm
chaeyeunpark Mar 14, 2022
92f0ee6
Add correct arg
chaeyeunpark Mar 15, 2022
cbe36ac
Slightly refactor static_lookup
chaeyeunpark Mar 15, 2022
26a508d
Rename AMD64 to x86_64
chaeyeunpark Mar 15, 2022
8cbef26
Add docstring
chaeyeunpark Mar 15, 2022
3ea7b49
add docstring
chaeyeunpark Mar 15, 2022
d259198
Merge remote-tracking branch 'origin/master' into pre_better_kernel_d…
chaeyeunpark Mar 15, 2022
cb3256e
Auto update version
chaeyeunpark Mar 15, 2022
4be5ac6
Format
chaeyeunpark Mar 15, 2022
ebbcf68
Small fix
chaeyeunpark Mar 16, 2022
97bc9b9
Auto update version
chaeyeunpark Mar 16, 2022
f9ec2af
Some more fix
chaeyeunpark Mar 16, 2022
34f5754
Merge remote-tracking branch 'origin/master' into pre_better_kernel_d…
chaeyeunpark Mar 16, 2022
865557e
Trigger CI
chaeyeunpark Mar 16, 2022
b5fb3ae
Merge remote-tracking branch 'origin/master' into pre_better_kernel_d…
chaeyeunpark Mar 17, 2022
86531d5
Auto update version
chaeyeunpark Mar 17, 2022
466b8ad
Merge remote-tracking branch 'origin/master' into pre_better_kernel_d…
chaeyeunpark Mar 17, 2022
cf654a7
Auto update version
chaeyeunpark Mar 17, 2022
b341f8c
Trigger CI
chaeyeunpark Mar 17, 2022
ac985c6
Trigger CI
chaeyeunpark Mar 17, 2022
00f4dc7
Trigger CI
chaeyeunpark Mar 18, 2022
a46a41f
Auto update version
chaeyeunpark Mar 18, 2022
7970643
Merge remote-tracking branch 'origin/master' into pre_better_kernel_d…
chaeyeunpark Mar 18, 2022
de3457e
Merge branch 'pre_better_kernel_dispatch' of github.com:PennyLaneAI/p…
chaeyeunpark Mar 18, 2022
b5b043a
Merge remote-tracking branch 'origin/master' into pre_better_kernel_d…
chaeyeunpark Mar 19, 2022
3bcba89
Fix doc
chaeyeunpark Mar 19, 2022
5ebb7b2
Fix for tidy
chaeyeunpark Mar 20, 2022
275c389
Remove some internal keyworks from docs
chaeyeunpark Mar 20, 2022
855e1bc
Fix test squaredNorm
chaeyeunpark Mar 20, 2022
5f2975d
Update CHANGELOG
chaeyeunpark Mar 21, 2022
dcb9a95
Trigger CI
chaeyeunpark Mar 21, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
python-version: 3.7

- name: Install dependencies
run: sudo apt update && sudo apt -y install clang-tidy-12 cmake g++
run: sudo apt update && sudo apt -y install clang-tidy-12 cmake g++ libomp-12-dev
chaeyeunpark marked this conversation as resolved.
Show resolved Hide resolved
env:
DEBIAN_FRONTEND: noninteractive

Expand Down
7 changes: 5 additions & 2 deletions bin/cpp-files
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Output C/C++ files in json list"
)
parser.add_argument(
"--header-only", action='store_true', dest='header_only', help="whether only include header files"
)
parser.add_argument(
"paths", nargs="+", metavar="DIR", help="paths to the root source directories"
)
Expand All @@ -23,9 +26,9 @@ if __name__ == '__main__':

args = parser.parse_args()

files = set(get_cpp_files(args.paths))
files = set(get_cpp_files(args.paths, header_only = args.header_only))
if args.exclude_dirs:
files_excludes = set(get_cpp_files(args.exclude_dirs))
files_excludes = set(get_cpp_files(args.exclude_dirs, header_only = args.header_only))
files -= files_excludes

json.dump(list(files), sys.stdout)
25 changes: 16 additions & 9 deletions bin/utils.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
from pathlib import Path
import re
import fnmatch
from re import compile as re_compile
from fnmatch import fnmatch

SRCFILE_EXT = ("c", "cc", "cpp", "cxx", "h", "hh", "hpp", "hxx", "cu", "cuh")
SRCFILE_EXT = ["c", "cc", "cpp", "cxx", "cu"]
HEADERFILE_EXT = ["h", "hh", "hpp", "hxx", "cuh"]

LIGHTNING_SOURCE_DIR = Path(__file__).resolve().parent.parent

rgx_gitignore_comment = re.compile("#.*$")
rgx_gitignore_comment = re_compile("#.*$")

def get_cpp_files_from_path(path, ignore_patterns = None, use_gitignore = True):
def get_cpp_files_from_path(path, ignore_patterns = None, use_gitignore = True, header_only = False):
"""return set of C++ source files from a path

Args:
chaeyeunpark marked this conversation as resolved.
Show resolved Hide resolved
paths (pathlib.Path or str): a path to process
ignore_patterns: patterns to ignore
use_gitignore: find ignore patterns from .gitignore
header_only: find only header files when true
"""
path = Path(path)
files_rel = set() # file paths relative to path
for ext in SRCFILE_EXT:

exts = HEADERFILE_EXT
if not header_only:
exts += SRCFILE_EXT
for ext in exts:
for file_path in path.rglob(f"*.{ext}"):
files_rel.add(file_path.relative_to(path))

Expand All @@ -39,22 +45,23 @@ def get_cpp_files_from_path(path, ignore_patterns = None, use_gitignore = True):
files_to_remove = set()
for ignore_pattern in ignore_patterns:
for f in files_rel:
if fnmatch.fnmatch(str(f), ignore_pattern):
if fnmatch(str(f), ignore_pattern):
files_to_remove.add(f)

files_rel -= files_to_remove

return set(str(path.joinpath(f)) for f in files_rel)

def get_cpp_files(paths, ignore_patterns = None, use_gitignore = True):
def get_cpp_files(paths, ignore_patterns = None, use_gitignore = True, header_only = False):
"""return list of C++ source files from paths.

Args:
chaeyeunpark marked this conversation as resolved.
Show resolved Hide resolved
paths (list): list of all paths to process
ignore_patterns: patterns to ignore
use_gitignore: find ignore patterns from .gitignore
header_only: find only header files when true
"""
files = set()
for path in paths:
files |= get_cpp_files_from_path(path, ignore_patterns, use_gitignore)
files |= get_cpp_files_from_path(path, ignore_patterns, use_gitignore, header_only)
return list(files)
14 changes: 14 additions & 0 deletions cmake/process_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ else()
message(STATUS "ENABLE_AVX is OFF.")
endif()

if(ENABLE_AVX2)
chaeyeunpark marked this conversation as resolved.
Show resolved Hide resolved
message(STATUS "ENABLE_AVX2 is ON.")
target_compile_options(lightning_compile_options INTERFACE -mavx2)
else()
message(STATUS "ENABLE_AVX2 is OFF")
endif()

if(ENABLE_AVX512)
message(STATUS "ENABLE_AVX512 is ON.")
target_compile_options(lightning_compile_options INTERFACE -mavx512f) # Now we only use avx512f
else()
message(STATUS "ENABLE_AVX512 is OFF")
endif()

if(ENABLE_OPENMP)
message(STATUS "ENABLE_OPENMP is ON.")
find_package(OpenMP)
Expand Down
27 changes: 14 additions & 13 deletions doc/_ext/edit_on_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
import warnings
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is also just formatted with black



__licence__ = 'BSD (3 clause)'
__licence__ = "BSD (3 clause)"


def get_github_url(app, view, path):
return 'https://github.com/{project}/{view}/{branch}/{path}'.format(
return "https://github.com/{project}/{view}/{branch}/{path}".format(
project=app.config.edit_on_github_project,
view=view,
branch=app.config.edit_on_github_branch,
path=path)
path=path,
)


def html_page_context(app, pagename, templatename, context, doctree):
if templatename != 'page.html':
if templatename != "page.html":
return

if not app.config.edit_on_github_project:
Expand All @@ -29,16 +30,16 @@ def html_page_context(app, pagename, templatename, context, doctree):

if not doctree:
return

path = os.path.relpath(doctree.get('source'), app.builder.srcdir)
show_url = get_github_url(app, 'blob', path)
edit_url = get_github_url(app, 'edit', path)

context['show_on_github_url'] = show_url
context['edit_on_github_url'] = edit_url
path = os.path.relpath(doctree.get("source"), app.builder.srcdir)
show_url = get_github_url(app, "blob", path)
edit_url = get_github_url(app, "edit", path)

context["show_on_github_url"] = show_url
context["edit_on_github_url"] = edit_url


def setup(app):
app.add_config_value('edit_on_github_project', '', True)
app.add_config_value('edit_on_github_branch', 'master', True)
app.connect('html-page-context', html_page_context)
app.add_config_value("edit_on_github_project", "", True)
app.add_config_value("edit_on_github_branch", "master", True)
app.connect("html-page-context", html_page_context)
Loading