-
Notifications
You must be signed in to change notification settings - Fork 26
Add --includes and --include-dir to dpnp CLI
#2916
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
base: master
Are you sure you want to change the base?
Changes from all commits
820528b
d4da430
8d4adfc
fd4f6ba
f39cec6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -215,6 +215,23 @@ devices at the same time: | |||||||||
| python scripts/build_locally.py --target-cuda --target-hip=gfx90a | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Command-Line Interface | ||||||||||
| ====================== | ||||||||||
|
|
||||||||||
| The ``python -m dpnp`` command provides options to query include paths | ||||||||||
| needed for building C++ extensions against dpnp: | ||||||||||
|
Comment on lines
+221
to
+222
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| .. code-block:: bash | ||||||||||
|
|
||||||||||
| python -m dpnp --includes # print -I flag for dpnp include directory | ||||||||||
| python -m dpnp --include-dir # print path to dpnp include directory | ||||||||||
| python -m dpnp --tensor-includes # print -I flag for libtensor include directory | ||||||||||
| python -m dpnp --tensor-include-dir # print path to libtensor include directory | ||||||||||
|
|
||||||||||
| These options are useful when building pybind11 extensions that use | ||||||||||
| ``dpnp4pybind11.hpp`` or libtensor kernel headers. | ||||||||||
|
|
||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be helpful to add an examples: For example, to compile a C++ extension using dpnp header using the Intel(R) oneAPI DPC++ compiler:
.. code-block:: bash
icpx -fsycl myextension.cpp $(python -m dpnp --includes) -o myextension.soNot sure if that works this way, based on |
||||||||||
|
|
||||||||||
| Testing | ||||||||||
| ======= | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,10 +39,19 @@ def _dpnp_dir() -> str: | |||||
| return abs_dpnp_dir | ||||||
|
|
||||||
|
|
||||||
| def get_include_dir() -> str: | ||||||
| """Returns path to dpnp include directory containing dpnp4pybind11.hpp""" | ||||||
| return os.path.join(_dpnp_dir(), "backend", "include") | ||||||
|
|
||||||
|
|
||||||
| def print_include_flags() -> None: | ||||||
| """Prints include flags for dpnp headers""" | ||||||
| print("-I " + get_include_dir()) | ||||||
|
|
||||||
|
|
||||||
| def get_tensor_include_dir() -> str: | ||||||
| """Prints path to dpnp libtensor include directory""" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| dpnp_dir = _dpnp_dir() | ||||||
| libtensor_dir = os.path.join(dpnp_dir, "tensor", "libtensor", "include") | ||||||
| libtensor_dir = os.path.join(_dpnp_dir(), "tensor", "libtensor", "include") | ||||||
| return libtensor_dir | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -55,6 +64,16 @@ def print_tensor_include_flags() -> None: | |||||
| def main() -> None: | ||||||
| """Main entry-point.""" | ||||||
| parser = argparse.ArgumentParser() | ||||||
| parser.add_argument( | ||||||
| "--includes", | ||||||
|
vlad-perevezentsev marked this conversation as resolved.
|
||||||
| action="store_true", | ||||||
| help="Include flags for dpnp headers.", | ||||||
| ) | ||||||
| parser.add_argument( | ||||||
| "--include-dir", | ||||||
| action="store_true", | ||||||
| help="Path to dpnp include directory.", | ||||||
| ) | ||||||
| parser.add_argument( | ||||||
| "--tensor-includes", | ||||||
| action="store_true", | ||||||
|
|
@@ -68,6 +87,10 @@ def main() -> None: | |||||
| args = parser.parse_args() | ||||||
| if not sys.argv[1:]: | ||||||
| parser.print_help() | ||||||
| if args.includes: | ||||||
| print_include_flags() | ||||||
| if args.include_dir: | ||||||
| print(get_include_dir()) | ||||||
| if args.tensor_includes: | ||||||
| print_tensor_include_flags() | ||||||
| if args.tensor_include_dir: | ||||||
|
|
||||||
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.
extra blank line