Skip to content

Commit da552e1

Browse files
dunnoconnormodularbot
authored andcommitted
[Edu] Update p32 bank conflict
MODULAR_ORIG_COMMIT_REV_ID: 4accc83c26355880dd699038243e2a5600e2d0a8
1 parent da00388 commit da552e1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

problems/p32/p32.mojo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ def two_way_conflict_kernel(
7272
Each bank serves 2 threads, doubling access time.
7373
"""
7474

75-
# Shared memory buffer - stride-2 access pattern creates conflicts
75+
# Sized to 2*TPB so stride-2 writes don't alias (threads i and i+TPB/2).
7676
var shared_buf = stack_allocation[
7777
dtype=dtype, address_space=AddressSpace.SHARED
78-
](row_major[TPB]())
78+
](row_major[2 * TPB]())
7979

8080
var global_i = block_dim.x * block_idx.x + thread_idx.x
8181
var local_i = thread_idx.x
8282

8383
# CONFLICT: stride-2 access creates 2-way bank conflicts
84-
var conflict_index = (local_i * 2) % TPB
84+
var conflict_index = local_i * 2
8585

8686
# Load with bank conflicts
8787
if global_i < size:

0 commit comments

Comments
 (0)