Skip to content

Conversation

michal-shalev
Copy link
Contributor

@michal-shalev michal-shalev commented Aug 24, 2025

What?

Replace hardcoded CUDA architecture flags with configurable defaults using meson's built-in cuda_args/cuda_link_args.

Why?

Replaces hardcoded CUDA architecture flags with configurable defaults using meson's built-in CUDA argument handling for better flexibility.

How?

  • Replaced hardcoded nvcc_flags with conditional default_cuda_args
  • Added logic to apply defaults only when user hasn't specified custom args
  • Added comprehensive CUDA configuration documentation

Usage

# Uses defaults (compute_80, compute_90)
meson setup build

# Custom architectures
meson setup build -Dcuda_args="-gencode=arch=compute_75,code=sm_75"

@michal-shalev michal-shalev self-assigned this Aug 24, 2025
@michal-shalev michal-shalev requested a review from a team as a code owner August 24, 2025 08:23
Copy link

copy-pr-bot bot commented Aug 24, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copy link

👋 Hi michal-shalev! Thank you for contributing to ai-dynamo/nixl.

Your PR reviewers will review your contribution then trigger the CI to test your changes.

🚀

meson.build Outdated
nvcc_flags += ['-gencode', 'arch=compute_80,code=sm_80']
nvcc_flags += ['-gencode', 'arch=compute_90,code=sm_90']
nvcc_flags_link = []
if get_option('nvcc_gencode') != ''
Copy link
Contributor

Choose a reason for hiding this comment

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

why need this check? wouldn't the for loop below be empty any way if options not set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because with a string option, ''.split(' ') returns [''], so the loop runs once and adds an empty flag. I changed nvcc_gencode to an array and removed this check and split to avoid empty args.

option('cudapath_inc', type: 'string', value: '', description: 'Include path for CUDA')
option('cudapath_lib', type: 'string', value: '', description: 'Library path for CUDA')
option('cudapath_stub', type: 'string', value: '', description: 'Extra Stub path for CUDA')
option('nvcc_gencode', type: 'string', value: '-gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90',
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like can provide meson cuda build flags like this:

meson setup -Dcuda_args="-gencode=arch=compute_90,code=sm_90" \
            -Dcuda_link_args="-gencode=arch=compute_90,code=sm_90"

Can you pls check it? so maybe no need to add specific option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested -Dcuda_args and -Dcuda_link_args and it's working.
I've updated the PR to use meson's built-in cuda_args and cuda_link_args instead of adding a custom option.

@michal-shalev michal-shalev changed the title BUILD: add nvcc_gencode option for CUDA architectures BUILD: Add configurable CUDA architecture targeting with meson built-in options Sep 17, 2025

# CUDA GPU architecture targeting (example)
$ meson setup <name_of_build_dir> \
-Dcuda_args="-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" \
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comma separated or space separated?

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

Successfully merging this pull request may close these issues.

3 participants