๐Ÿ”ฅโ€นAct II ยท Diagnostics Bay
โœฆ 0 XP
Chapter 1 / 3

Trace the fault

New here? Read the 60-sec briefing โ†—

A subsystem returns garbage past the first 256 readings. The diagnostic points at the index, it forgot which block each core belongs to, so only the first squad ever runs.

First debugging instinct: check the index math. Inside a kernel thread_idx.x restarts at 0 in every block, so a global index has to add the block's offset โ€” otherwise only the first block ever runs.

YOUR TASK
  1. 1The index only uses thread_idx.x, that's the bug.
  2. 2Fix it to the full global index that includes the block offset.
๐Ÿ’ก Global index = block_dim.x * block_idx.x + thread_idx.x, not thread_idx.x alone.
DEFINITIONS
global index
โ€” The unique number identifying one core across the entire launch, computed as block_dim.x * block_idx.x + thread_idx.x. It is the address each core uses to find its element in the buffer.
thread_idx.x
โ€” A core's position inside its own block. It restarts at 0 in every block, so on its own it cannot tell core 0 of block 1 apart from core 0 of block 0.
block offset
โ€” The term block_dim.x * block_idx.x, which counts every core in the blocks before this one. Adding it to thread_idx.x is what turns a local position into a global index.
core_09_trace.mojo
PUZZLE 9 ยท DEBUG
Clear all 3 chapters to forge๐Ÿ› ๏ธ Diagnostics Core Shard