Commit 6e49fb9a
6e49fb9acb0bMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 6 files · +1 added · ~5 modified
Description
Add FloatArray type (sp_FloatArray) for float-valued arrays
New type SPINEL_TYPE_FLOAT_ARRAY with full runtime support: sp_FloatArray_new, push, get, set, length, dup. Array.new(n, 0.0) and float array literals auto-detect as FloatArray.
matmul benchmark (150x150): Spinel <0.01s vs CRuby 0.32s (>32x) 74/74 tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 6e49fb9acb0b
- Parent
- d1ce6031ff7e
examples/bm_matmul.rbaddedView file
1+
def matgen(n)2+
a = Array.new(n * n, 0.0)3+
i = 04+
while i < n5+
j = 06+
while j < n7+
a[i * n + j] = (1.0 / n / n) * (i - j) * (i + j)8+
j = j + 19+
end10+
i = i + 111+
end12+
a13+
end14+
15+
def matmul(a, b, n)16+
c = Array.new(n * n, 0.0)17+
i = 018+
while i < n19+
k = 020+
while k < n21+
aik = a[i * n + k]22+
j = 023+
while j < n24+
c[i * n + j] = c[i * n + j] + aik * b[k * n + j]25+
j = j + 126+
end27+
k = k + 128+
end29+
i = i + 130+
end31+
c32+
end33+
34+
n = 15035+
a = matgen(n)36+
b = matgen(n)37+
c = matmul(a, b, n)38+
39+
# Print checksum (integer part of first and last elements)40+
puts (c[0] * 1000000).to_i41+
puts (c[n * n - 1] * 1000000).to_i42+
puts "done"src/codegen.cmodifiedView file
Loading diff…
src/codegen.hmodifiedView file
Loading diff…
src/emit.cmodifiedView file
Loading diff…
src/expr.cmodifiedView file
Loading diff…
src/type.cmodifiedView file
Loading diff…