Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 25, 2024
1 parent f65e84f commit 3f0d8c4
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 123 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-10-22)
## Unreleased (2024-10-25)

<section class="features">

Expand All @@ -22,6 +22,7 @@

<details>

- [`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)_

</details>
Expand Down
2 changes: 1 addition & 1 deletion lib/binary.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var base64ToUint8Array = require( '@stdlib/string-base-base64-to-uint8array' );

// MAIN //

var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGADf39/AX1gBH9/f38BfQIPAQNlbnYGbWVtb3J5AgAAAwQDAAECB0wEEV9fd2FzbV9jYWxsX2N0b3JzAAAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAHY19zbnJtMgABD2Nfc25ybTJfbmRhcnJheQACCogDAwMAAQshAQF+IAAgASACIAKsIgNCASAArH1+QgAgA0IAVxunEAIL3wICBX0Df0EBIQkgAEEASgR9A0ACQCABIANBAnRqKgIAiyIHQwAAgFleBEAgBiAHQwAAgBmUIgYgBpSSIQZBACEJDAELIAdDAAAAIF0EQCAJIQpBACEJIApFDQEgBSAHQwAAAGWUIgUgBZSSIQVBASEJDAELIAQgByAHlJIhBAsgAiADaiEDIAtBAWoiCyAARw0ACwJAIAZDAAAAAF4EQCAEQwAAgBmUQwAAgBmUIAaSIgUgBiAEQ///f39eGyAFIARDAAAAAF8bIQRDAACAZSEGDAELQwAAgD8hBiAFQwAAAABeRQ0AAkAgBCAEXA0AIARDAAAAAF4NACAEQ///f39eDQAgBSEEQwAAABohBgwBCyAFkUMAAAAalCIFIASRIgQgBCAFXSIAGyIHIAeUIQggBCAFIAAbIAeVIgQgBJS7RAAAAAAAAPA/oCAIu6K2IQQLIAYgBJGUBUMAAAAACws=' );
var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGADf39/AX1gBH9/f38BfQIPAQNlbnYGbWVtb3J5AgAAAwQDAAECB0wEEV9fd2FzbV9jYWxsX2N0b3JzAAAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAHY19zbnJtMgABD2Nfc25ybTJfbmRhcnJheQACCoIDAwMAAQsaACAAIAEgAkEBIABrIAJsQQAgAkEATBsQAgvgAgIFfQN/QQEhCSAAQQBKBH0DQCAAIApGRQRAAkAgASADQQJ0aioCACIIiyIHQwAAgFleBEAgBiAHQwAAgBmUIgYgBpSSIQZBACEJDAELIAdDAAAAIF0EQCAJIQtBACEJIAtFDQEgBSAHQwAAAGWUIgUgBZSSIQVBASEJDAELIAQgCCAIlJIhBAsgCkEBaiEKIAIgA2ohAwwBCwsCQCAGQwAAAABeBEAgBEMAAIAZlEMAAIAZlCAGkiIFIAYgBEP//39/XhsgBSAEQwAAAABfGyEEQwAAgGUhBgwBC0MAAIA/IQYgBUMAAAAAXkUNACAEIARcIARDAAAAAF5yIARD//9/f15yRQRAIAUhBEMAAAAaIQYMAQsgBJEiBCAFkUMAAAAalCIFIAQgBV0iABsgBSAEIAAbIgSVIgUgBZS7RAAAAAAAAPA/oCAEIASUu6K2IQQLIAYgBJGUBUMAAAAACws=' );


// EXPORTS //
Expand Down
21 changes: 16 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?=
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/exports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"_c_snrm2",
"_c_snrm2_ndarray"
]
Binary file modified src/main.wasm
Binary file not shown.
214 changes: 98 additions & 116 deletions src/main.wat
Original file line number Diff line number Diff line change
@@ -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)))
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f0d8c4

Please sign in to comment.