From 3f0d8c44c8536e408e0b7ef468a87aaa557689c6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 25 Oct 2024 20:37:40 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 3 +- lib/binary.browser.js | 2 +- src/Makefile | 21 ++++- src/exports.json | 4 + src/main.wasm | Bin 542 -> 536 bytes src/main.wat | 214 +++++++++++++++++++----------------------- 6 files changed, 121 insertions(+), 123 deletions(-) create mode 100644 src/exports.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b8ebcc..57ffc8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-10-22) +## Unreleased (2024-10-25)
@@ -22,6 +22,7 @@
+- [`85a6c6a`](https://github.com/stdlib-js/stdlib/commit/85a6c6a051660cab231134b7043796cff7ca1f2c) - **build:** update compiler flags and export resolution _(by Athan Reines)_ - [`243f857`](https://github.com/stdlib-js/stdlib/commit/243f85723b0b899c6cedcac0271f707bebdad918) - **feat:** add `blas/base/snrm2-wasm` [(#3029)](https://github.com/stdlib-js/stdlib/pull/3029) _(by Aman Bhansali, Athan Reines)_
diff --git a/lib/binary.browser.js b/lib/binary.browser.js index 82c08ad..dbff4b6 100644 --- a/lib/binary.browser.js +++ b/lib/binary.browser.js @@ -25,7 +25,7 @@ var base64ToUint8Array = require( '@stdlib/string-base-base64-to-uint8array' ); // MAIN // -var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGADf39/AX1gBH9/f38BfQIPAQNlbnYGbWVtb3J5AgAAAwQDAAECB0wEEV9fd2FzbV9jYWxsX2N0b3JzAAAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAHY19zbnJtMgABD2Nfc25ybTJfbmRhcnJheQACCogDAwMAAQshAQF+IAAgASACIAKsIgNCASAArH1+QgAgA0IAVxunEAIL3wICBX0Df0EBIQkgAEEASgR9A0ACQCABIANBAnRqKgIAiyIH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V0iABsgBSAEIAAbIgSVIgUgBZS7RAAAAAAAAPA/oCAEIASUu6K2IQQLIAYgBJGUBUMAAAAACws=' ); // EXPORTS // diff --git a/src/Makefile b/src/Makefile index 7362640..eb51121 100644 --- a/src/Makefile +++ b/src/Makefile @@ -80,26 +80,37 @@ else NODEJS := node endif +# Define the integer size: +ifdef CBLAS_INT + INT_TYPE := $(CBLAS_INT) +else + INT_TYPE := int32_t +endif + # Define the command-line options when compiling C files: CFLAGS ?= \ -std=c99 \ -O3 \ + -flto \ -Wall \ -pedantic \ - -D CBLAS_INT=int32_t + -D CBLAS_INT=$(INT_TYPE) # Define the command-line options when compiling C files to WebAssembly and asm.js: EMCCFLAGS ?= $(CFLAGS) # Define shared `emcc` flags: EMCC_SHARED_FLAGS := \ + -Oz \ + -fwasm-exceptions \ + -s SUPPORT_LONGJMP=1 \ -s SIDE_MODULE=2 \ - -s WASM_BIGINT=0 \ - -s EXPORTED_FUNCTIONS="['_c_snrm2','_c_snrm2_ndarray']" + -s EXPORTED_FUNCTIONS="$(shell cat exports.json | tr -d ' \t\n' | sed s/\"/\'/g)" # Define WebAssembly `emcc` flags: EMCC_WASM_FLAGS := $(EMCC_SHARED_FLAGS) \ - -s WASM=1 + -s WASM=1 \ + -s WASM_BIGINT=0 # List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): INCLUDE ?= @@ -217,7 +228,7 @@ $(browser_js_targets): $(wasm_targets) # make clean-wasm #/ clean-wasm: - $(QUIET) -rm -f *.wasm *.wat *.wasm.js + $(QUIET) -rm -f *.wasm *.wat *.wasm.js $(browser_js_targets) .PHONY: clean-wasm diff --git a/src/exports.json b/src/exports.json new file mode 100644 index 0000000..8a4ec64 --- /dev/null +++ b/src/exports.json @@ -0,0 +1,4 @@ +[ + "_c_snrm2", + "_c_snrm2_ndarray" +] diff --git a/src/main.wasm b/src/main.wasm index a8b93c3dd4844594bc40451a49dace3e7ed7c094..aa80e28fbef26cb274cbc238e4556bc4a50451fc 100644 GIT binary patch delta 245 zcmW-aJx&8L6oj9jpTn}Iph9A|VC<5P6R;LP1p*sz4j9#0gkpBr1eB1WoRO zI082a&zWj8`ex=s-sL6VJX>qY_=Z3*;ABAe;DAKx#|I6%_c1R}df)ZWH(sl~h zmlx7;rzM;CsXu0l)%bI=;}a?9R|n?kutJqzgLu@*^q~gB_QCEMzq&QkM+jsFIV074 zp=PrghWSEg;leg5osgO3?Qf7&fs1Tx|NllZ( zAa1}75__lmGk@OvdDkC$8y7DkLTnxL1_XwJ+Iy)Ov~M;QK`MGEzb};iRmwEd26ktl zKnvZ-T+I_9K|R$oMcv<3F$$FI(Qd+*Wq~5TI&ITQshz+EuDu1_jcK>!`{x8}=+&5@ zZz$Dcua3vI&C0lbI(36{wlG~@nMQA*JD)I^wWreO3^&Xzs6_FWt$4W2=ZOBVKQTOf O{p248iHoMsvGxS%ODm-S diff --git a/src/main.wat b/src/main.wat index a64cea6..9a69189 100644 --- a/src/main.wat +++ b/src/main.wat @@ -1,19 +1,3 @@ -;; @license Apache-2.0 -;; -;; Copyright (c) 2024 The Stdlib Authors. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. - (module (type (;0;) (func)) (type (;1;) (func (param i32 i32 i32) (result f32))) @@ -22,24 +6,19 @@ (func (;0;) (type 0) nop) (func (;1;) (type 1) (param i32 i32 i32) (result f32) - (local i64) local.get 0 local.get 1 local.get 2 - local.get 2 - i64.extend_i32_s - local.tee 3 - i64.const 1 + i32.const 1 local.get 0 - i64.extend_i32_s - i64.sub - i64.mul - i64.const 0 - local.get 3 - i64.const 0 - i64.le_s + i32.sub + local.get 2 + i32.mul + i32.const 0 + local.get 2 + i32.const 0 + i32.le_s select - i32.wrap_i64 call 2) (func (;2;) (type 2) (param i32 i32 i32 i32) (result f32) (local f32 f32 f32 f32 f32 i32 i32 i32) @@ -50,73 +29,78 @@ i32.gt_s if (result f32) ;; label = @1 loop ;; label = @2 - block ;; label = @3 - local.get 1 - local.get 3 - i32.const 2 - i32.shl - i32.add - f32.load - f32.abs - local.tee 7 - f32.const 0x1p+52 (;=4.5036e+15;) - f32.gt - if ;; label = @4 - local.get 6 - local.get 7 - f32.const 0x1p-76 (;=1.32349e-23;) - f32.mul - local.tee 6 - local.get 6 - f32.mul - f32.add - local.set 6 - i32.const 0 - local.set 9 - br 1 (;@3;) - end - local.get 7 - f32.const 0x1p-63 (;=1.0842e-19;) - f32.lt - if ;; label = @4 - local.get 9 - local.set 10 - i32.const 0 - local.set 9 - local.get 10 - i32.eqz - br_if 1 (;@3;) - local.get 5 + local.get 0 + local.get 10 + i32.eq + i32.eqz + if ;; label = @3 + block ;; label = @4 + local.get 1 + local.get 3 + i32.const 2 + i32.shl + i32.add + f32.load + local.tee 8 + f32.abs + local.tee 7 + f32.const 0x1p+52 (;=4.5036e+15;) + f32.gt + if ;; label = @5 + local.get 6 + local.get 7 + f32.const 0x1p-76 (;=1.32349e-23;) + f32.mul + local.tee 6 + local.get 6 + f32.mul + f32.add + local.set 6 + i32.const 0 + local.set 9 + br 1 (;@4;) + end local.get 7 - f32.const 0x1p+75 (;=3.77789e+22;) - f32.mul - local.tee 5 - local.get 5 + f32.const 0x1p-63 (;=1.0842e-19;) + f32.lt + if ;; label = @5 + local.get 9 + local.set 11 + i32.const 0 + local.set 9 + local.get 11 + i32.eqz + br_if 1 (;@4;) + local.get 5 + local.get 7 + f32.const 0x1p+75 (;=3.77789e+22;) + f32.mul + local.tee 5 + local.get 5 + f32.mul + f32.add + local.set 5 + i32.const 1 + local.set 9 + br 1 (;@4;) + end + local.get 4 + local.get 8 + local.get 8 f32.mul f32.add - local.set 5 - i32.const 1 - local.set 9 - br 1 (;@3;) + local.set 4 end - local.get 4 - local.get 7 - local.get 7 - f32.mul - f32.add - local.set 4 + local.get 10 + i32.const 1 + i32.add + local.set 10 + local.get 2 + local.get 3 + i32.add + local.set 3 + br 1 (;@2;) end - local.get 2 - local.get 3 - i32.add - local.set 3 - local.get 11 - i32.const 1 - i32.add - local.tee 11 - local.get 0 - i32.ne - br_if 0 (;@2;) end block ;; label = @2 local.get 6 @@ -153,55 +137,53 @@ f32.gt i32.eqz br_if 0 (;@2;) - block ;; label = @3 - local.get 4 - local.get 4 - f32.ne - br_if 0 (;@3;) - local.get 4 - f32.const 0x0p+0 (;=0;) - f32.gt - br_if 0 (;@3;) - local.get 4 - f32.const 0x1.fffffep+127 (;=3.40282e+38;) - f32.gt - br_if 0 (;@3;) + local.get 4 + local.get 4 + f32.ne + local.get 4 + f32.const 0x0p+0 (;=0;) + f32.gt + i32.or + local.get 4 + f32.const 0x1.fffffep+127 (;=3.40282e+38;) + f32.gt + i32.or + i32.eqz + if ;; label = @3 local.get 5 local.set 4 f32.const 0x1p-75 (;=2.64698e-23;) local.set 6 br 1 (;@2;) end + local.get 4 + f32.sqrt + local.tee 4 local.get 5 f32.sqrt f32.const 0x1p-75 (;=2.64698e-23;) f32.mul local.tee 5 local.get 4 - f32.sqrt - local.tee 4 - local.get 4 local.get 5 f32.lt local.tee 0 select - local.tee 7 - local.get 7 - f32.mul - local.set 8 - local.get 4 local.get 5 + local.get 4 local.get 0 select - local.get 7 - f32.div local.tee 4 - local.get 4 + f32.div + local.tee 5 + local.get 5 f32.mul f64.promote_f32 f64.const 0x1p+0 (;=1;) f64.add - local.get 8 + local.get 4 + local.get 4 + f32.mul f64.promote_f32 f64.mul f32.demote_f64