-
Notifications
You must be signed in to change notification settings - Fork 182
Improve cuda gencode flags #321
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
agirault
wants to merge
4
commits into
NVIDIA:master
Choose a base branch
from
agirault:ag/cuda_gencode_enh
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,60 +17,57 @@ if [ "$CUDA_VERSION_MAJOR" -lt 8 ]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| # Initialize with Pascal architecture | ||
| COMPUTE_LIST="60 61 62" | ||
| SM_LIST="60 61 62" | ||
|
|
||
| # Add Volta (7.0) if CUDA >= 9.0 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 9 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 70 72" | ||
| SM_LIST="$SM_LIST 70 72" | ||
| fi | ||
| # Get the list of supported SM architectures (sm_XX) from nvcc | ||
| # Filter to only include SM >= 60 (Pascal) | ||
| ARCH_LIST=$("$NVCC" --list-gpu-code 2>/dev/null | sed 's/sm_//' | awk '$1 >= 60') | ||
|
|
||
| # Add Turing (7.5) if CUDA >= 10.0 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 10 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 75" | ||
| SM_LIST="$SM_LIST 75" | ||
| fi | ||
| if [ -z "$ARCH_LIST" ]; then | ||
| echo "Warning: Could not determine supported architectures from nvcc, falling back to version-based detection" >&2 | ||
|
|
||
| # Add Ampere (8.0, 8.6, 8.7) if CUDA >= 11.1 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 11 ] && [ "$CUDA_VERSION_MINOR" -ge 1 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 80 86 87" | ||
| SM_LIST="$SM_LIST 80 86 87" | ||
| fi | ||
| # Initialize with Pascal architecture | ||
| ARCH_LIST="60 61 62" | ||
|
|
||
| # Add Ada Lovelace (8.9) if CUDA >= 11.8 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 11 ] && [ "$CUDA_VERSION_MINOR" -ge 8 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 89" | ||
| SM_LIST="$SM_LIST 89" | ||
| fi | ||
| # Add Volta (7.0) if CUDA >= 9.0 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 9 ]; then | ||
| ARCH_LIST="$ARCH_LIST 70 72" | ||
| fi | ||
|
|
||
| # Add Hopper (9.0) if CUDA >= 12.0 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 12 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 90" | ||
| SM_LIST="$SM_LIST 90" | ||
| fi | ||
| # Add Turing (7.5) if CUDA >= 10.0 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 10 ]; then | ||
| ARCH_LIST="$ARCH_LIST 75" | ||
| fi | ||
|
|
||
| # Add Blackwell (10.0) if CUDA >= 12.6 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 12 ] && [ "$CUDA_VERSION_MINOR" -ge 6 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 100" | ||
| SM_LIST="$SM_LIST 100" | ||
| fi | ||
| # Add Ampere (8.0, 8.6, 8.7) if CUDA >= 11.1 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 11 ] && [ "$CUDA_VERSION_MINOR" -ge 1 ]; then | ||
| ARCH_LIST="$ARCH_LIST 80 86 87" | ||
| fi | ||
|
|
||
| # Add Ada Lovelace (8.9) if CUDA >= 11.8 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 11 ] && [ "$CUDA_VERSION_MINOR" -ge 8 ]; then | ||
| ARCH_LIST="$ARCH_LIST 89" | ||
| fi | ||
|
|
||
| # Add Hopper (9.0) if CUDA >= 12.0 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 12 ]; then | ||
| ARCH_LIST="$ARCH_LIST 90" | ||
| fi | ||
|
|
||
| # Add Blackwell (12.0) if CUDA >= 12.8 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 12 ] && [ "$CUDA_VERSION_MINOR" -ge 8 ]; then | ||
| COMPUTE_LIST="$COMPUTE_LIST 120" | ||
| SM_LIST="$SM_LIST 120" | ||
| # Add Blackwell (10.0, 10.1, 12.0) if CUDA >= 12.8 | ||
| if [ "$CUDA_VERSION_MAJOR" -ge 12 ] && [ "$CUDA_VERSION_MINOR" -ge 8 ]; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this check work for CUDA 13.0?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| ARCH_LIST="$ARCH_LIST 100 101 120" | ||
| fi | ||
| fi | ||
|
|
||
| # Generate NVCC flags | ||
| GENCODE_FLAGS="" | ||
| for compute in $COMPUTE_LIST; do | ||
| GENCODE_FLAGS="$GENCODE_FLAGS -gencode arch=compute_$compute,code=compute_$compute" | ||
| done | ||
|
|
||
| for sm in $SM_LIST; do | ||
| GENCODE_FLAGS="$GENCODE_FLAGS -gencode arch=compute_$sm,code=sm_$sm" | ||
| # Generate SM-specific code for all architectures | ||
| for arch in $ARCH_LIST; do | ||
| GENCODE_FLAGS="$GENCODE_FLAGS -gencode arch=compute_$arch,code=sm_$arch" | ||
| done | ||
|
|
||
| echo "$GENCODE_FLAGS" | ||
| # Generate PTX code only for the latest architecture | ||
| LATEST_ARCH=$(echo "$ARCH_LIST" | tr ' ' '\n' | sort -n | tail -1) | ||
| GENCODE_FLAGS="$GENCODE_FLAGS -gencode arch=compute_$LATEST_ARCH,code=compute_$LATEST_ARCH" | ||
|
|
||
| echo "$GENCODE_FLAGS" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work on CUDA 12.0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it would. wasn't in the scope of this MR but I can edit these checks to check major first