-
Notifications
You must be signed in to change notification settings - Fork 211
Improve traceability for constant memory placement for static variables #293
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
PMQ9
wants to merge
5
commits into
Rust-GPU:main
Choose a base branch
from
PMQ9:improve_constant_memory_placement
base: main
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.
Conversation
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
…t memory spill warnings
15b1306 to
638b478
Compare
638b478 to
25d8ac1
Compare
LegNeato
requested changes
Oct 22, 2025
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.
Thank you and welcome to the project! Looks pretty good, just some small things
LegNeato
requested changes
Oct 23, 2025
a1c7207 to
d841974
Compare
|
One more change:
Test example to trigger the error:
#![no_std]
#![crate_type = "staticlib"]
use cuda_std::*;
// 35KB per array, 3 arrays = 105KB total (well above 64KB limit)
const ARRAY_SIZE: usize = 35 * 1024 / 4;
static BIG_ARRAY_1: [u32; ARRAY_SIZE] = [111u32; ARRAY_SIZE];
static BIG_ARRAY_2: [u32; ARRAY_SIZE] = [222u32; ARRAY_SIZE];
static BIG_ARRAY_3: [u32; ARRAY_SIZE] = [333u32; ARRAY_SIZE];
pub unsafe fn test_kernel(out: *mut u32) {
*out = BIG_ARRAY_1[0] + BIG_ARRAY_2[0] + BIG_ARRAY_3[0];
}
use std::path::PathBuf;
fn main() {
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
println!("cargo::warning=Building GPU kernels with constant memory ENABLED");
println!("cargo::warning=This should trigger constant memory overspill errors");
cuda_builder::CudaBuilder::new(manifest_dir.join("kernels"))
.copy_to(out_path.join("kernels.ptx"))
// Enable constant memory placement to trigger the overspill error
.use_constant_memory_space(true)
.build()
.unwrap();
}
[workspace]
[package]
name = "const_memory_overflow"
version = "0.1.0"
edition = "2021"
[dependencies]
cust = { path = "../../../crates/cust" }
[build-dependencies]
cuda_builder = { path = "../../../crates/cuda_builder", features = ["rustc_codegen_nvvm"] }
[workspace]
[package]
name = "const_memory_overflow_kernels"
version = "0.1.0"
edition = "2021"
[dependencies]
cuda_std = { path = "../../../../crates/cuda_std" }
[lib]
crate-type = ["cdylib", "rlib"]
use cust::prelude::*;
fn main() {
println!("This example is meant to fail at compile time!");
println!("It demonstrates the improved error messages for constant memory overflow.");
}Expected Failure |
|
Option 1: Move static BIG_ARRAY_1: [u32; ARRAY_SIZE] = [111u32; ARRAY_SIZE];
#[cuda_std::address_space(global)]
static BIG_ARRAY_2: [u32; ARRAY_SIZE] = [222u32; ARRAY_SIZE];Option 2: Disable feature competely .use_constant_memory_space(false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For this issue: #218