File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
tests/compiletests/ui/lang/consts Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // Test that automatic constant memory placement fails when exceeding the 64KB limit
2+ // This test creates multiple large static arrays that together exceed the limit
3+
4+ // compile-flags: -Cllvm-args=--use-constant-memory-space
5+
6+ #![ no_std]
7+ use cuda_std:: * ;
8+
9+ // 35KB per array, 3 arrays = 105KB total (well above 64KB limit)
10+ const ARRAY_SIZE : usize = 35 * 1024 / 4 ;
11+
12+ // NO explicit address_space - let the automatic placement handle it
13+ // With use_constant_memory_space=true, these should try to go to constant memory
14+ static BIG_ARRAY_1 : [ u32 ; ARRAY_SIZE ] = [ 111u32 ; ARRAY_SIZE ] ;
15+ static BIG_ARRAY_2 : [ u32 ; ARRAY_SIZE ] = [ 222u32 ; ARRAY_SIZE ] ;
16+ static BIG_ARRAY_3 : [ u32 ; ARRAY_SIZE ] = [ 333u32 ; ARRAY_SIZE ] ;
17+
18+ #[ kernel]
19+ pub unsafe fn test_kernel ( out : * mut u32 ) {
20+ * out = BIG_ARRAY_1 [ 0 ] + BIG_ARRAY_2 [ 0 ] + BIG_ARRAY_3 [ 0 ] ;
21+ }
Original file line number Diff line number Diff line change 1+ error: cannot place static `BIG_ARRAY_2` (35840 bytes) in constant memory: cumulative constant memory usage would be 71680 bytes, exceeding the 65536 byte limit
2+ --> $DIR/constant_memory_overflow.rs:15:1
3+ |
4+ LL | static BIG_ARRAY_2: [u32; ARRAY_SIZE] = [222u32; ARRAY_SIZE];
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this static would cause total usage to exceed 65536 bytes
6+ |
7+ = note: current constant memory usage: 35840 bytes
8+ = note: static size: 35840 bytes
9+ = note: would result in: 71680 bytes total
10+ = help: move this or other statics to global memory using `#[cuda_std::address_space(global)]`
11+ = help: reduce the total size of static data
12+ = help: disable automatic constant memory placement by setting `.use_constant_memory_space(false)` on `CudaBuilder` in build.rs
13+
14+ error: aborting due to 1 previous error
15+
You can’t perform that action at this time.
0 commit comments