blob: 94b058c4c4d27f76714b2f29e41fdf85c12b64e4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
namespace;
include rt;
// f32 packed arrays and rounding inside an o3 region
fn put_f(x) { asm { x @ #1220 } return 0; }
o3 float dot(f32* p, int n) {
float s = 0;
f32 acc = 0;
for (int i = 0; i < n; i++) { s += p[i] * p[i]; acc = acc + p[i]; p[i] = p[i] + 0.1; }
return s + acc;
}
fn main() {
f32* p = rt.new(f32, 50);
for (int i = 0; i < 50; i++) p[i] = i * 0.5;
put_f(dot(p, 50)); rt.put_c(' '); put_f(p[3]); rt.put_c(' '); rt.put_n(p[3] == 1.6); rt.put_c(10);
rt.free(d*p);
}
|