diff --git a/docs/doc_sources/beginners_guides/installation.rst b/docs/doc_sources/beginners_guides/installation.rst index 6592554094..75fab31e02 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -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 @@ -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=" + 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,11 +220,17 @@ 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 --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 @@ -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 ========================== diff --git a/scripts/build_locally.py b/scripts/build_locally.py index 6488ca2d3c..b7a34ba037 100644 --- a/scripts/build_locally.py +++ b/scripts/build_locally.py @@ -30,6 +30,8 @@ def run( use_glog=False, verbose=False, cmake_opts="", + target_cuda=None, + target_hip=None, ): build_system = None @@ -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= 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 ) @@ -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 = [ @@ -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, )