Skip to content

Extend build_locally.py with --target-cuda and --target-hip arguments #2109

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
35 changes: 26 additions & 9 deletions docs/doc_sources/beginners_guides/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,27 @@ A full list of available SYCL alias targets is available in the
CUDA build
~~~~~~~~~~

``dpctl`` can be built for CUDA devices using the ``DPCTL_TARGET_CUDA`` CMake option,
which accepts a specific compute architecture string:
``dpctl`` can be built for CUDA devices using the ``--target-cuda`` argument.

To target a specific architecture (e.g., ``sm_80``):

.. code-block:: bash

python scripts/build_locally.py --verbose --target-cuda=sm_80

To use the default architecture (``sm_50``), omit the value:

.. code-block:: bash

python scripts/build_locally.py --verbose --target-cuda

Alternatively, you can use the ``DPCTL_TARGET_CUDA`` CMake option:

.. code-block:: bash

python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_CUDA=sm_80"

To use the default architecture (``sm_50``),
To use the default architecture (``sm_50``) with CMake options,
set ``DPCTL_TARGET_CUDA`` to a value such as ``ON``, ``TRUE``, ``YES``, ``Y``, or ``1``:

.. code-block:: bash
Expand All @@ -192,12 +205,11 @@ Compute Capabilities can be found in the official
AMD build
~~~~~~~~~

``dpctl`` can be built for AMD devices using the ``DPCTL_TARGET_HIP`` CMake option,
which requires specifying a compute architecture string:
``dpctl`` can be built for AMD devices using the ``--target-hip`` argument.

.. code-block:: bash

python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=<arch>"
python scripts/build_locally.py --verbose --target-hip=<arch>

Note that the `oneAPI for AMD GPUs` plugin requires the architecture be specified and only
one architecture can be specified at a time.
Expand All @@ -208,11 +220,17 @@ To determine the architecture code (``<arch>``) for your AMD GPU, run:
rocminfo | grep 'Name: *gfx.*'

This will print names like ``gfx90a``, ``gfx1030``, etc.
You can then use one of them as the argument to ``-DDPCTL_TARGET_HIP``.
You can then use one of them as the argument to ``--target-hip``.

For example:

.. code-block:: bash
python scripts/build_locally.py --verbose --target-hip=gfx1030

Alternatively, you can use the ``DPCTL_TARGET_HIP`` CMake option:

.. code-block:: bash

python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030"

Multi-target build
Expand All @@ -225,8 +243,7 @@ devices at the same time:

.. code-block:: bash

python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_CUDA=ON \
-DDPCTL_TARGET_HIP=gfx1030"
python scripts/build_locally.py --verbose --target-cuda --target-hip=gfx1030

Running Examples and Tests
==========================
Expand Down
37 changes: 37 additions & 0 deletions scripts/build_locally.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def run(
use_glog=False,
verbose=False,
cmake_opts="",
target_cuda=None,
target_hip=None,
):
build_system = None

Expand Down Expand Up @@ -65,6 +67,23 @@ def run(
]
if cmake_opts:
cmake_args += cmake_opts.split()
if target_cuda is not None:
if not target_cuda.strip():
raise ValueError(
"--target-cuda can not be an empty string. "
"Use --target-cuda=<arch> or --target-cuda"
)
cmake_args += [
f"-DDPCTL_TARGET_CUDA={target_cuda}",
]
if target_hip is not None:
if not target_hip.strip():
raise ValueError(
"--target-hip requires an architecture (e.g., gfx90a)"
)
cmake_args += [
f"-DDPCTL_TARGET_HIP={target_hip}",
]
subprocess.check_call(
cmake_args, shell=False, cwd=setup_dir, env=os.environ
)
Expand Down Expand Up @@ -131,6 +150,22 @@ def run(
default="",
type=str,
)
driver.add_argument(
"--target-cuda",
nargs="?",
const="ON",
help="Enable CUDA target for build; "
"optionally specify architecture (e.g., --target-cuda=sm_80)",
default=None,
type=str,
)
driver.add_argument(
"--target-hip",
required=False,
help="Enable HIP target for build. "
"Must specify HIP architecture (e.g., --target-hip=gfx90a)",
type=str,
)
args = parser.parse_args()

args_to_validate = [
Expand Down Expand Up @@ -186,4 +221,6 @@ def run(
use_glog=args.glog,
verbose=args.verbose,
cmake_opts=args.cmake_opts,
target_cuda=args.target_cuda,
target_hip=args.target_hip,
)
Loading