Skip to content

Add --target-cuda argument for selecting CUDA architecture #2478

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 10 commits into
base: master
Choose a base branch
from

Conversation

vlad-perevezentsev
Copy link
Collaborator

This PR suggests adding --target-cuda argument to scripts/build_locally.py allowing to enable CUDA support and optionally specify the target architecture (e.g. sm_80).
If no architecture is specified, sm_50 is used by default.

$ python scripts/build_locally.py --target-cuda
# or
$ python scripts/build_locally.py --target-cuda=<arch>

The specified architecture is used to construct a SYCL alias target (e.g. nvidia_gpu_sm_80) and passed via -fsycl-targets option, following OneAPI for NVIDIA GPUs

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

Copy link
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2478/index.html

@@ -87,8 +91,18 @@ set(_dpnp_sycl_target_compile_options)
set(_dpnp_sycl_target_link_options)

if ("x${DPNP_SYCL_TARGETS}" STREQUAL "x")
if(DPNP_TARGET_CUDA)
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
if (DPNP_TARGET_CUDA)
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not OFF by default now. Should this be updated?

Suggested change
if (DPNP_TARGET_CUDA)
if (NOT "x${DPNP_TARGET_CUDA}" STREQUAL "x")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The empty string is False for this check if (DPNP_TARGET_CUDA)
I added this check in case when DPNP_TARGET_CUDA is passed as 0, OFF, NO, FALSE, N via cmake-opts argument

Copy link
Contributor

Choose a reason for hiding this comment

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

in case when DPNP_TARGET_CUDA is passed as 0, OFF, NO, FALSE, N via cmake-opts argument

That is not the case when DPNP_TARGET_CUDA passed as an empty string. So it's still unclear for me.
Per my understanding the string can't be empty due to the check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right that --target-cuda= is checked in build_locally.py.
But if someone bypasses it via --cmake-opts="-DDPNP_TARGET_CUDA=" the empty string is still evaluated as FALSE in if(DPNP_TARGET_CUDA). Thus this condition safely handles both cases.
Using if (NOT "x${DPNP_TARGET_CUDA}" STREQUAL "x") would only check for non-empty strings but still treat values like OFF or 0 as TRUE

@antonwolfy antonwolfy added this to the 0.19.0 release milestone Jun 10, 2025
Copy link
Contributor

github-actions bot commented Jun 10, 2025

Array API standard conformance tests for dpnp=0.19.0dev0=py312h509198e_18 ran successfully.
Passed: 1231
Failed: 0
Skipped: 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants