Skip to content

Propose to improve Puzzles 15, 16, 17 - #273

Open
tolgacangoz wants to merge 6 commits into
modular:mainfrom
tolgacangoz:errata-1
Open

tolgacangoz wants to merge 6 commits into
modular:mainfrom
tolgacangoz:errata-1

Conversation

@tolgacangoz

@tolgacangoz tolgacangoz commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for this implementation based educational site!

Proposing to fix race condition argument, improve documentation, and update examples.

@ehsanmok @dunnoconnor @KenJones-Modular @ansley

Comment on lines -171 to -188
while stride > 0:
var temp_val: Scalar[dtype] = 0
if local_i < stride:
temp_val = cache[local_i + stride] # Read phase
barrier()
if local_i < stride:
cache[local_i] += temp_val # Write phase
barrier()
stride //= 2
```

**Note**: The read and write phases are deliberately separated by a
`barrier()`. The simpler form below reads and writes shared memory in the
same iteration, which races:

```mojo
# Racy - do not use
var stride = TPB // 2

@tolgacangoz tolgacangoz Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't reading and writing independent?

@tolgacangoz tolgacangoz changed the title Propose to improve Puzzles 15, 16, 17 Propose to improve Puzzles 15, 16, 17 Oct 24, 2026
@tolgacangoz
tolgacangoz force-pushed the errata-1 branch 3 times, most recently from 8108b33 to c916007 Compare October 27, 2026 06:38
… revise tutorial references for better guidance.
Use to_tile_tensor for the kernel arguments, pass device to ops.custom, and show mojo precompile in the packaging example.
The puzzle tasks and the skeleton compile script now use the current command name.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant