From c76adb8b3561c2d62eaea6c7bf42993554324224 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 2 Apr 2023 15:08:59 +0300 Subject: [PATCH] =?UTF-8?q?default=20to=20=E2=80=A2internal.EEqual=20compa?= =?UTF-8?q?ring=200=20and=20=C2=AF0=20as=20equal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/src/build.bqn | 2 +- docs/system.md | 2 +- makefile | 2 +- src/core/stuff.c | 8 ++++---- test/README.md | 4 ++-- test/bitcpy.bqn | 2 +- test/squeezeValid.bqn | 1 - test/utils.bqn | 2 +- test/various.bqn | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/build/src/build.bqn b/build/src/build.bqn index 556eaa79..ded572e8 100755 --- a/build/src/build.bqn +++ b/build/src/build.bqn @@ -275,7 +275,7 @@ po ← { # parsed options args∾↩ ( o3) / ⟨"-O3"⟩ args∾↩ ( native) / ⟨"-march=native"⟩ args∾↩ ( debug) / ⟨"-DDEBUG"⟩ - args∾↩ ( rtverify) / ⟨"-DRT_VERIFY", "-DEEQUAL_NEGZERO"⟩ + args∾↩ ( rtverify) / ⟨"-DRT_VERIFY"⟩ args∾↩ ( heapverify) / ⟨"-DHEAP_VERIFY"⟩ args∾↩ ( exportSymbols) / ⟨"-DCBQN_EXPORT"⟩ args∾↩ ( ¬pie) / ⟨"-fno-pie"⟩ diff --git a/docs/system.md b/docs/system.md index d6bdf6d3..f9516f9f 100644 --- a/docs/system.md +++ b/docs/system.md @@ -113,7 +113,7 @@ Namespace of various internal functions. May change at any time. | `•internal.Variation` | Convert `𝕩` to the variation specified in `𝕨` | | `•internal.ClearRefs` | Clear references `•internal.Variation` made for `*Inc` variations | | `•internal.Unshare` | Get a unique, reference count 1 version of the argument; recursively unshares array items, doesn't touch namespaces | -| `•internal.EEqual` | exactly equal (NaN equals NaN); 0 and ¯0 aren't equal, but can be made so with the C compile-time flag `-DEEQUAL_NEGZERO` | +| `•internal.EEqual` | exactly equal (NaN equals NaN, 0 equals ¯0) | | `•internal.Temp` | place to test new features or temporarily expose some internal function | # FFI diff --git a/makefile b/makefile index 704962b1..9b992474 100644 --- a/makefile +++ b/makefile @@ -16,7 +16,7 @@ debug1: rtperf: @"${MAKE}" i_singeli=0 i_t=rtperf i_f="-O3 -DRT_PERF" run_incremental_0 rtverify: - @"${MAKE}" i_singeli=0 i_t=rtverify i_f="-DDEBUG -O3 -DRT_VERIFY -DEEQUAL_NEGZERO" run_incremental_0 + @"${MAKE}" i_singeli=0 i_t=rtverify i_f="-DDEBUG -O3 -DRT_VERIFY" run_incremental_0 heapverify: @"${MAKE}" i_singeli=0 i_t=heapverify i_f="-DDEBUG -g -DHEAP_VERIFY" run_incremental_0 wasi-o3: diff --git a/src/core/stuff.c b/src/core/stuff.c index dc757fa5..013b818b 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -513,7 +513,7 @@ bool equalSlow(B w, B x, usz ia) { bool atomEEqual(B w, B x) { // doesn't consume (not that that matters really currently) if (w.u==x.u) return true; - #if EEQUAL_NEGZERO + #if !NEEQUAL_NEGZERO if (isF64(w)&isF64(x)) return w.f==x.f; #endif if(isF64(w)|isF64(x)) return false; @@ -550,10 +550,10 @@ bool eequal(B w, B x) { // doesn't consume f64* xp = f64any_ptr(x); u64 r = 1; for (usz i = 0; i < ia; i++) { - #if EEQUAL_NEGZERO - r&= (wp[i]==xp[i]) | (wp[i]!=wp[i] & xp[i]!=xp[i]); - #else + #if NEEQUAL_NEGZERO r&= ((u64*)wp)[i] == ((u64*)xp)[i]; + #else + r&= (wp[i]==xp[i]) | (wp[i]!=wp[i] & xp[i]!=xp[i]); #endif } return r; diff --git a/test/README.md b/test/README.md index 498fbfe9..186e67f1 100644 --- a/test/README.md +++ b/test/README.md @@ -13,8 +13,8 @@ test/moreCfgs.sh path/to/mlochbaum/BQN // run "2+2" in a bunch of configurations ./BQN test/bit.bqn // fuzz-test •bit functions ./BQN test/mut.bqn // fuzz-test mut.h (currently just bitarr fill); requires -DTEST_MUT ./BQN test/hash.bqn // fuzz-test hashing -./BQN test/squeezeValid.bqn // fuzz-test squeezing giving a correct result; requires -DEEQUAL_NEGZERO -./BQN test/squeezeExact.bqn // fuzz-test squeezing giving the exact smallest result; requires -DEEQUAL_NEGZERO +./BQN test/squeezeValid.bqn // fuzz-test squeezing giving a correct result +./BQN test/squeezeExact.bqn // fuzz-test squeezing giving the exact smallest result ./BQN test/various.bqn // tests for various small things ./BQN test/random.bqn // test (•MakeRand n).Range ./BQN test/joinReuse.bqn // test in-place join; requires -DPRINT_JOIN_REUSE diff --git a/test/bitcpy.bqn b/test/bitcpy.bqn index a1342d0a..3933b9ea 100644 --- a/test/bitcpy.bqn +++ b/test/bitcpy.bqn @@ -1,4 +1,4 @@ -# make f='-O3 -march=native -DTEST_BITCPY' singeli=1 c && ./BQN test/bitcpy.bqn +# make o3-singeli f=-DTEST_BITCPY && ./BQN test/bitcpy.bqn ⟨Temp, Type, Unshare, Squeeze, Info, Variation⟩ ← •internal u ← ⌊100×(•UnixTime+1|100וMonoTime)@ # u ↩ 123 diff --git a/test/squeezeValid.bqn b/test/squeezeValid.bqn index 93099c84..b7a83a50 100644 --- a/test/squeezeValid.bqn +++ b/test/squeezeValid.bqn @@ -1,4 +1,3 @@ -# make f='-march=native -O3 -DEEQUAL_NEGZERO' singeli=1 c && ./BQN test/squeeze.bqn ⟨EEqual, ListVariations, ClearRefs, Variation, Squeeze, Info⟩ ← •internal u ← ⌊100×(•UnixTime+1|100וMonoTime)@ # u ↩ 123 diff --git a/test/utils.bqn b/test/utils.bqn index d3ab0f63..c9cd75fd 100644 --- a/test/utils.bqn +++ b/test/utils.bqn @@ -8,7 +8,7 @@ min ← 0∾(-2⋆7‿15‿31)∾¯0.5∾0‿0‿0 max ← 2∾( 2⋆7‿15‿31)∾ 0.5∾(2⋆8‿16)∾1114112 szs ← max-min chr ← 0‿0‿0‿0‿0‿1‿1‿1 -specF64 ⇐ (∾⟜- π‿2∾ 1÷0) ∾ (0÷0) ∾ -0÷0 +specF64 ⇐ (∾⟜- π‿2‿∞) ∾ (0÷0) ∾ -0÷0 specI32 ⇐ "Ai32" •internal.Variation ∧ (<⟜(2⋆31)∧≥⟜(-2⋆31))⊸/ ∾⟜- ≥⟜0⊸/ ∧⥊(¯4+↕8) +⌜ 2⋆↕32 vars ⇐ "Ab"‿"Ai8"‿"Ai16"‿"Ai32"‿"Af64"‿"Ac8"‿"Ac16"‿"Ac32" casts ⇐ 1‿8‿16‿32‿64‿8‿16‿32⋈¨"uiiifccc" diff --git a/test/various.bqn b/test/various.bqn index 6d5c45ae..376f565e 100644 --- a/test/various.bqn +++ b/test/various.bqn @@ -86,6 +86,6 @@ Mod ← {𝕊: # •Show "heap corruption test of bit/i32" ⋄ "Ai32"‿1‿50 BitSlash 1000000 { - ¬0 EEQ -0? •Out "Skipping tests requiring EEQUAL_NEGZERO"; + ¬0 EEQ -0? •Out "Skipping tests requiring !NEEQUAL_NEGZERO"; •Show "⊔ consistency" ⋄ Group 10000 }