Skip to content

Commit 35156ca

Browse files
dunnoconnormodularbot
authored andcommitted
[Docs] Fully qualify standard library imports with std. prefix
Summary As of Mojo 1.0.0b2, implicit standard-library imports are a hard error — stdlib modules must be fully qualified with a std. prefix (e.g. from std.gpu.host import DeviceContext instead of from gpu.host import DeviceContext). This was previously a deprecation warning in b1. Several doc/tutorial code examples still used the old syntax, so readers copying them now hit an unhelpful unable to locate module 'gpu' error. This PR migrates the remaining stale examples across the docs to the std.-qualified form. Reported in [forum #3237](https://forum.modular.com/t/standard-library-import-warning-error-between-b1-and-b2/3237). MODULAR_ORIG_COMMIT_REV_ID: 8ddba94a5b0a5b29b29f2baa89bf340227b01a79
1 parent f4b65bf commit 35156ca

8 files changed

Lines changed: 22 additions & 22 deletions

File tree

book/i18n/ko/src/puzzle_23/benchmarking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Benchmarks completed!
103103
벤치마킹 시스템은 Mojo의 내장 `benchmark` 모듈을 사용합니다:
104104

105105
```mojo
106-
from benchmark import Bench, BenchConfig, Bencher, BenchId, keep
106+
from std.benchmark import Bench, BenchConfig, Bencher, BenchId, keep
107107
bench_config = BenchConfig(max_iters=10, num_warmup_iters=1)
108108
```
109109

book/i18n/ko/src/puzzle_24/warp_extra.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252

5353
```mojo
5454
# 리덕션 연산
55-
from gpu.primitives.warp import sum, max
55+
from std.gpu.primitives.warp import sum, max
5656
var total = sum(partial_values)
5757
var maximum = max(partial_values)
5858
5959
# 통신 패턴
60-
from gpu.primitives.warp import shuffle_idx, prefix_sum
60+
from std.gpu.primitives.warp import shuffle_idx, prefix_sum
6161
var broadcast = shuffle_idx(my_value, 0)
6262
var running_sum = prefix_sum(my_value)
6363
```

book/i18n/ko/src/puzzle_24/warp_simt.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
**간단한 예시:**
1414

1515
```mojo
16-
from gpu.primitives.warp import sum
16+
from std.gpu.primitives.warp import sum
1717
# 워프 내 32개 스레드가 동시에 실행:
1818
var my_value = input[my_thread_id] # 각 스레드가 서로 다른 데이터를 가져옴
1919
var warp_total = sum(my_value) # 모든 스레드가 하나의 합계에 기여
@@ -56,7 +56,7 @@ var result = a + b # 8쌍을 동시에 덧셈
5656

5757
```mojo
5858
# 스레드 기반 코드가 벡터 연산으로 변환됩니다
59-
from gpu.primitives.warp import sum
59+
from std.gpu.primitives.warp import sum
6060
6161
var my_data = input[thread_id] # 각 스레드가 자기 요소를 가져옴
6262
var partial = my_data * coefficient # 모든 스레드가 동시에 계산
@@ -169,8 +169,8 @@ GPU는 지연 시간이 아닌 **처리량**에 최적화되어 있습니다. SI
169169
워프 내 각 스레드는 0부터 `WARP_SIZE-1`까지의 **레인 ID**를 갖습니다:
170170

171171
```mojo
172-
from gpu import lane_id
173-
from gpu.primitives.warp import WARP_SIZE
172+
from std.gpu import lane_id
173+
from std.gpu.primitives.warp import WARP_SIZE
174174
175175
# 커널 함수 내에서:
176176
my_lane = lane_id() # 0-31 (NVIDIA/RDNA) 또는 0-63 (CDNA) 반환
@@ -192,7 +192,7 @@ barrier() # 명시적 동기화 필요
192192
var total = shared[0] + shared[1] + ... + shared[WARP_SIZE] # 합산 리덕션
193193
194194
# 2. 워프 방식:
195-
from gpu.primitives.warp import sum
195+
from std.gpu.primitives.warp import sum
196196
197197
var total = sum(partial_result) # 암시적 동기화!
198198
```
@@ -306,7 +306,7 @@ else:
306306
### NVIDIA vs AMD 워프 크기
307307

308308
```mojo
309-
from gpu.primitives.warp import WARP_SIZE
309+
from std.gpu.primitives.warp import WARP_SIZE
310310
311311
# NVIDIA GPUs: WARP_SIZE = 32
312312
# AMD RDNA GPUs: WARP_SIZE = 32 (wavefront32 모드)

book/i18n/ko/src/puzzle_24/warp_sum.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ if lane_id() == 0:
324324
### 4. **import에서 사용 가능한 함수들**
325325

326326
```mojo
327-
from gpu import lane_id
328-
from gpu.primitives.warp import sum as warp_sum, WARP_SIZE
327+
from std.gpu import lane_id
328+
from std.gpu.primitives.warp import sum as warp_sum, WARP_SIZE
329329
330330
# 함수 내에서:
331331
my_lane = lane_id() # 0 ~ WARP_SIZE-1

book/src/puzzle_23/benchmarking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Benchmarks completed!
102102
The benchmarking system uses Mojo's built-in `benchmark` module:
103103

104104
```mojo
105-
from benchmark import Bench, BenchConfig, Bencher, BenchId, keep
105+
from std.benchmark import Bench, BenchConfig, Bencher, BenchId, keep
106106
bench_config = BenchConfig(max_iters=10, num_warmup_iters=1)
107107
```
108108

book/src/puzzle_24/warp_extra.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@
5050

5151
```mojo
5252
# Reduction operations
53-
from gpu.primitives.warp import sum, max
53+
from std.gpu.primitives.warp import sum, max
5454
var total = sum(partial_values)
5555
var maximum = max(partial_values)
5656
5757
# Communication patterns
58-
from gpu.primitives.warp import shuffle_idx, prefix_sum
58+
from std.gpu.primitives.warp import shuffle_idx, prefix_sum
5959
var broadcast = shuffle_idx(my_value, 0)
6060
var running_sum = prefix_sum(my_value)
6161
```

book/src/puzzle_24/warp_simt.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ processor.
1212
**Simple example:**
1313

1414
```mojo
15-
from gpu.primitives.warp import sum
15+
from std.gpu.primitives.warp import sum
1616
# All 32 threads in the warp execute this simultaneously:
1717
var my_value = input[my_thread_id] # Each gets different data
1818
var warp_total = sum(my_value) # All contribute to one sum
@@ -55,7 +55,7 @@ var result = a + b # Add 8 pairs simultaneously
5555

5656
```mojo
5757
# Thread-based code that becomes vector operations
58-
from gpu.primitives.warp import sum
58+
from std.gpu.primitives.warp import sum
5959
6060
var my_data = input[thread_id] # Each thread gets its element
6161
var partial = my_data * coefficient # All threads compute simultaneously
@@ -168,8 +168,8 @@ GPUs are optimized for **throughput**, not latency. SIMT enables:
168168
Each thread within a warp has a **lane ID** from 0 to `WARP_SIZE-1`:
169169

170170
```mojo
171-
from gpu import lane_id
172-
from gpu.primitives.warp import WARP_SIZE
171+
from std.gpu import lane_id
172+
from std.gpu.primitives.warp import WARP_SIZE
173173
174174
# Within a kernel function:
175175
my_lane = lane_id() # Returns 0-31 (NVIDIA/RDNA) or 0-63 (CDNA)
@@ -191,7 +191,7 @@ barrier() # Explicit synchronization required
191191
var total = shared[0] + shared[1] + ... + shared[WARP_SIZE] # Sum reduction
192192
193193
# 2. Warp approach:
194-
from gpu.primitives.warp import sum
194+
from std.gpu.primitives.warp import sum
195195
196196
var total = sum(partial_result) # Implicit synchronization!
197197
```
@@ -307,7 +307,7 @@ else:
307307
### NVIDIA vs AMD warp sizes
308308

309309
```mojo
310-
from gpu.primitives.warp import WARP_SIZE
310+
from std.gpu.primitives.warp import WARP_SIZE
311311
312312
# NVIDIA GPUs: WARP_SIZE = 32
313313
# AMD RDNA GPUs: WARP_SIZE = 32 (wavefront32 mode)

book/src/puzzle_24/warp_sum.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ functional approach.
328328
### 4. **Available functions from imports**
329329

330330
```mojo
331-
from gpu import lane_id
332-
from gpu.primitives.warp import sum as warp_sum, WARP_SIZE
331+
from std.gpu import lane_id
332+
from std.gpu.primitives.warp import sum as warp_sum, WARP_SIZE
333333
334334
# Inside your function:
335335
my_lane = lane_id() # 0 to WARP_SIZE-1

0 commit comments

Comments
 (0)