interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / src / omega_gpu_hostmath.h

39 lines · 2106 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef OMEGA_GPU_HOSTMATH_H
18#define OMEGA_GPU_HOSTMATH_H
19/*
20 * omega_gpu_hostmath: libm-free double-precision host math for the production side of libomega_gpu.a
21 * (OWN-30B, 2026-10-13). The library must link without -lm (omegatool and the Rust FFI crate link it bare),
22 * so the few transcendental values the APIs build on the host (the RoPE cos/sin table, the inverse frequency
23 * powers, the router oracle's exp) come from here. Everything is plain double arithmetic: range reduction plus
24 * short Taylor/atanh series, checked against libm by tests/gpu_decode_attn_test.c --host-only (the test links -lm).
25 *
26 * log(x): x > 0 finite; NaN otherwise. Error a few ulp.
27 * exp(y): 0 below -745, +inf above 709.8. Error a few ulp.
28 * pow(b, e): b > 0 finite; exp(e * log(b)). Relative error about |e * log b| * 2^-52.
29 * sincos(a): valid for |a| < 2^20 * pi/2 (about 1.6e6; the RoPE table needs pos < 131072). Three-part
30 * Cody-Waite reduction with the fdlibm pi/2 pieces, series to r^16. Absolute error about 1e-16.
31 * pow2f(e): 2^e as f32, exact (built from the bit pattern) for -149 <= e <= 127; 0 below, +inf above.
32 * Replaces ldexpf(1.0f, e) (omega-mv#471).
33 */
34double omega_hostmath_log(double x);
35double omega_hostmath_exp(double y);
36double omega_hostmath_pow(double base, double e);
37void omega_hostmath_sincos(double a, double *s, double *c);
38float omega_hostmath_pow2f(int e);
39#endif