[BUG]: algorithm.parallelize crashes program
Nobody has claimed this yet.
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Bug description
0.00033999278648190045
12.336449968250383 GFLOP/s
[114667:114667:20231209,143503.671761:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[114667:114667:20231209,143503.671869:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
Stack dump:
0. Program arguments: mojo main.mojo
The program started crashing when I added for loop into the main
Steps to reproduce
from algorithm import parallelize, vectorize
from tensor import Tensor
from utils.index import Index
from sys.info import simdwidthof
from random import rand
import benchmark
alias type = DType.float32
alias nelts = simdwidthof[type]()
alias M = 128
alias N = 128
alias K = 128
@always_inline
fn bench[
func: fn (inout Tensor[type], Tensor[type], Tensor[type]) -> None]():
var A = rand[type](M, K)
var B = rand[type](K, N)
var C = Tensor[type](M, N)
@always_inline
@parameter
fn test_fn():
_ = func(C, A, B)
let secs = benchmark.run[test_fn](max_runtime_secs=1).mean()
let gflops = ((2 * M * N * K) / secs) / 1e9
print(secs)
print(gflops, "GFLOP/s")
fn matmul_parallelized(inout C: Tensor[type], A: Tensor[type], B: Tensor[type]):
@parameter
fn calc_row(m: Int):
for k in range(K):
@parameter
fn func[nelts: Int](n: Int):
C.simd_store[nelts](
m * M + n,
C.simd_load[nelts](m * M + n) + A.simd_load[nelts](m * M + k) * B.simd_load[nelts](k * K + n)
)
vectorize[nelts, func](N)
parallelize[calc_row](M, M)
fn main():
for i in range(5):
bench[matmul_parallelized]()
System information
- What OS did you do install Mojo on ?
* Windows 11
- Provide version information for Mojo by pasting the output of `mojo -v`
* mojo 0.6.0 (d55c0025)
- Provide Modular CLI version by pasting the output of `modular -v`
* modular 0.2.2 (95d42445)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Mojo reproduction with mojo 0.6.0 on Windows 11, focusing on the added loop around benchmatmul_parallelized. Compare the behavior with and without that loop and inspect the crash output. Done means repeated calls no longer crash the program, with coverage for this reproduction if the relevant test location can be found.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100