# Leetgpu, tensara how to handle shared memory?

**URL:** <https://forum.modular.com/t/leetgpu-tensara-how-to-handle-shared-memory/1693>\
**Category:** GPU Programming\
**Tags:** gpu\
**Created:** [June 20, 2025, 12:47am UTC](https://forum.modular.com/t/leetgpu-tensara-how-to-handle-shared-memory/1693 "2025-06-20T00:47:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dolewhip](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@dolewhip](https://forum.modular.com/u/dolewhip)\
**Post date:** [June 20, 2025, 12:47am UTC](https://forum.modular.com/t/leetgpu-tensara-how-to-handle-shared-memory/1693/1 "2025-06-20T00:47:05Z")

</div>

hey looking at GPU puzzles, LeetGPU and tensara  
These are great

> <https://github.com/modular/mojo-gpu-puzzles/blob/main/solutions/p11/p11.mojo>

> <https://github.com/modular/mojo-gpu-puzzles/blob/main/solutions/p15/op/conv1d.mojo>

think these should be simple

> **[LeetGPU](https://leetgpu.com/challenges/1d-convolution)**
>
> The GPU Programming Platform

> **[1D Convolution | Tensara](https://tensara.org/problems/conv-1d)**
>
> A platform for GPU programming challenges. Write efficient GPU kernels and compare your solutions with other developers.

but spinning a bit on how to handle the shared memory

doing  
var shared\_kernel = tbdtype.row\_majorkernel\_size.shared().alloc()  
var shared\_input = tbdtype.row\_majorinput\_size.shared().alloc()

but missing something on how to handle the parameterized functions

solve gives us input\_size: Int32, kernel\_size: Int32

seems simple but I am missing something. seems like I need to convert to Int? or how do we handle the tb shared alloc?

I did a brute force which passed the initial tests but fails submit so hoping to fix up like the GPU puzzles shared memory approach

---

<div class="post-metadata">

**Author:** ![dolewhip](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@dolewhip](https://forum.modular.com/u/dolewhip)\
**Post date:** [June 26, 2025, 11:40pm UTC](https://forum.modular.com/t/leetgpu-tensara-how-to-handle-shared-memory/1693/2 "2025-06-26T23:40:55Z")

</div>

on leetgpu brute force passed for me today and got a shared memory version working.

> <https://gist.github.com/quinnavila/592f3ac1d97d2b790b7e8bff2cbf106f>

Keeping it basic with just stack allocation shared memory worked fine. I did create an alias for the kernel size and curious how we can improve more.
