From 6c33b408da20bb22754d9aaf07030fb1be64c087 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 20 Jun 2025 03:52:12 -0700 Subject: [PATCH 1/5] Extend build_locally.py with --target-cuda to simplify passing CUDA target --- scripts/build_locally.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/build_locally.py b/scripts/build_locally.py index 6488ca2d3c..8e7ebc7dca 100644 --- a/scripts/build_locally.py +++ b/scripts/build_locally.py @@ -30,6 +30,7 @@ def run( use_glog=False, verbose=False, cmake_opts="", + target_cuda=None, ): build_system = None @@ -65,6 +66,15 @@ 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= or --target-cuda" + ) + cmake_args += [ + f"-DDPCTL_TARGET_CUDA={target_cuda}", + ] subprocess.check_call( cmake_args, shell=False, cwd=setup_dir, env=os.environ ) @@ -131,6 +141,15 @@ 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, + ) args = parser.parse_args() args_to_validate = [ @@ -186,4 +205,5 @@ def run( use_glog=args.glog, verbose=args.verbose, cmake_opts=args.cmake_opts, + target_cuda=args.target_cuda, ) From cfa26fb0a6a4ed08fa1539fe8419aca1b4c474da Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 20 Jun 2025 04:10:44 -0700 Subject: [PATCH 2/5] Update docs to reflect new --target-cuda option --- .../doc_sources/beginners_guides/installation.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/doc_sources/beginners_guides/installation.rst b/docs/doc_sources/beginners_guides/installation.rst index 6592554094..399977b74c 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -166,19 +166,19 @@ 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 --cmake-opts="-DDPCTL_TARGET_CUDA=sm_80" + python scripts/build_locally.py --verbose --target-cuda=sm_80 -To use the default architecture (``sm_50``), -set ``DPCTL_TARGET_CUDA`` to a value such as ``ON``, ``TRUE``, ``YES``, ``Y``, or ``1``: +To use the default architecture (``sm_50``), omit the value: .. code-block:: bash - python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_CUDA=ON" + python scripts/build_locally.py --verbose --target-cuda Note that kernels are built for the default architecture (``sm_50``), allowing them to work on a wider range of architectures, but limiting the usage of more recent CUDA features. @@ -225,8 +225,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 --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030" Running Examples and Tests ========================== From ef6025ee246d25c9253e7796df1aa318cd23b3a3 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 20 Jun 2025 04:39:48 -0700 Subject: [PATCH 3/5] Extend build_locally.py with --target-hip to simplify passing HIP target --- scripts/build_locally.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/build_locally.py b/scripts/build_locally.py index 8e7ebc7dca..b7a34ba037 100644 --- a/scripts/build_locally.py +++ b/scripts/build_locally.py @@ -31,6 +31,7 @@ def run( verbose=False, cmake_opts="", target_cuda=None, + target_hip=None, ): build_system = None @@ -75,6 +76,14 @@ def run( 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 ) @@ -150,6 +159,13 @@ def run( 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 = [ @@ -206,4 +222,5 @@ def run( verbose=args.verbose, cmake_opts=args.cmake_opts, target_cuda=args.target_cuda, + target_hip=args.target_hip, ) From 3bf2bbce97191c03516b6f43a2a26ad3de464bd4 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 20 Jun 2025 04:46:41 -0700 Subject: [PATCH 4/5] Update docs to reflect new --target-hip option --- docs/doc_sources/beginners_guides/installation.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/doc_sources/beginners_guides/installation.rst b/docs/doc_sources/beginners_guides/installation.rst index 399977b74c..ee4913813a 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -192,12 +192,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=" + python scripts/build_locally.py --verbose --target-hip= Note that the `oneAPI for AMD GPUs` plugin requires the architecture be specified and only one architecture can be specified at a time. @@ -208,12 +207,12 @@ To determine the architecture code (````) 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 --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030" + python scripts/build_locally.py --verbose --target-hip=gfx1030 Multi-target build ~~~~~~~~~~~~~~~~~~ @@ -225,7 +224,7 @@ devices at the same time: .. code-block:: bash - python scripts/build_locally.py --verbose --target-cuda --cmake-opts="-DDPCTL_TARGET_HIP=gfx1030" + python scripts/build_locally.py --verbose --target-cuda --target-hip=gfx1030 Running Examples and Tests ========================== From 4e250d6cc33407fafab159ea9a8fe35f026d680e Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 25 Jun 2025 02:57:41 -0700 Subject: [PATCH 5/5] Document CMake option usage as alternative to --target-cuda/--target-hip --- .../beginners_guides/installation.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/doc_sources/beginners_guides/installation.rst b/docs/doc_sources/beginners_guides/installation.rst index ee4913813a..75fab31e02 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -180,6 +180,19 @@ To use the default architecture (``sm_50``), omit the value: 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``) with CMake options, +set ``DPCTL_TARGET_CUDA`` to a value such as ``ON``, ``TRUE``, ``YES``, ``Y``, or ``1``: + +.. code-block:: bash + + python scripts/build_locally.py --verbose --cmake-opts="-DDPCTL_TARGET_CUDA=ON" + Note that kernels are built for the default architecture (``sm_50``), allowing them to work on a wider range of architectures, but limiting the usage of more recent CUDA features. @@ -214,6 +227,12 @@ 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 ~~~~~~~~~~~~~~~~~~