Skip to content

Commit f73f4e5

Browse files
committed
Refactor to N-API and clean-up
1 parent 68dab95 commit f73f4e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+439
-8347
lines changed

lib/node_modules/@stdlib/blas/base/dasum/README.md

Lines changed: 0 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -134,205 +134,6 @@ sum = dasum.ndarray( 3, x, -1, x.length-1 );
134134
// returns 15.0
135135
```
136136

137-
#### dasum.wasm( \[options] )
138-
139-
Returns a memory managed function to compute the sum of [absolute values][@stdlib/math/base/special/abs].
140-
141-
```javascript
142-
var Float64Array = require( '@stdlib/array/float64' );
143-
144-
var wasm = dasum.wasm();
145-
146-
// Number of data elements:
147-
var N = 5;
148-
149-
// Allocate space on the heap:
150-
var bytes = wasm.malloc( N * 8 ); // 8 bytes per double
151-
152-
// Create a Float64Array view:
153-
var view = new Float64Array( bytes.buffer, bytes.byteOffset, N );
154-
155-
// Copy data to the heap:
156-
view.set( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] );
157-
158-
// Compute the sum:
159-
var s = wasm( N, bytes, 1 );
160-
// returns 15.0
161-
162-
// Free the memory:
163-
wasm.free( bytes );
164-
```
165-
166-
For externally defined [typed arrays][mdn-typed-array], data must be copied to the heap.
167-
168-
```javascript
169-
var Uint8Array = require( '@stdlib/array/uint8' );
170-
var Float64Array = require( '@stdlib/array/float64' );
171-
172-
var wasm = dasum.wasm();
173-
174-
// Externally defined data array:
175-
var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] );
176-
177-
// Allocate space on the heap:
178-
var bytes = wasm.malloc( x.length * x.BYTES_PER_ELEMENT );
179-
180-
// Copy data to the heap:
181-
bytes.set( new Uint8Array( x.buffer ) );
182-
183-
// Compute the sum:
184-
var s = wasm( x.length, bytes, 1 );
185-
// returns 15.0
186-
187-
// Free the memory:
188-
wasm.free( bytes );
189-
```
190-
191-
The method accepts the following `options`:
192-
193-
- **memory**: total memory. If not provided a `buffer`, setting the `memory` option instructs the returned function to allocate an internal memory store of the specified size.
194-
- **stack**: total stack size. Must be less than the `memory` option and large enough for a program's needs. Default: `1024` bytes.
195-
- **buffer**: `ArrayBuffer` serving as the underlying memory store. If not provided, each returned function will allocate and manage its own memory. If provided a `memory` option, the buffer `byteLength` must equal the specified total memory.
196-
197-
To create a function using an externally defined memory buffer, set the `buffer` option.
198-
199-
<!-- FIXME: glue code seems to require more than just setting a `buffer` property: https://github.com/kripken/emscripten/blob/655cec1975e784985d25bc80c5438d715ac5ec13/src/preamble.js#L2155 and https://github.com/kripken/emscripten/blob/655cec1975e784985d25bc80c5438d715ac5ec13/src/preamble.js#L1141 -->
200-
201-
<!-- run-disable -->
202-
203-
```javascript
204-
var ArrayBuffer = require( '@stdlib/array/buffer' );
205-
var buffer = new ArrayBuffer( 16777216 ); // ~16MB
206-
207-
var wasm = dasum.wasm({
208-
'buffer': buffer
209-
});
210-
```
211-
212-
Providing external memory can be advantageous when wanting to a) centrally manage memory allocation, b) share memory between multiple memory managed functions, and/or c) limit the total amount of allocated memory within an application or library.
213-
214-
##### wasm.malloc( nbytes )
215-
216-
Allocates space on the heap and returns a bytes-wise [`typed array`][mdn-typed-array] view ([`Uint8Array`][mdn-uint8array]).
217-
218-
```javascript
219-
var wasm = dasum.wasm();
220-
221-
// Allocate 64 bytes:
222-
var bytes = wasm.malloc( 64 );
223-
```
224-
225-
##### bytes.getValue( ptr\[, type] )
226-
227-
Returns a value at a specific memory address (represented by a byte index). By default, the function returns a `double`. Possible types include: `'i8'`, `'i16'`, `'i32'`, `'i64'`, `'float'`, and `'double'`.
228-
229-
```javascript
230-
var Float64Array = require( '@stdlib/array/float64' );
231-
232-
var wasm = dasum.wasm();
233-
234-
var N = 3;
235-
236-
var bytes = wasm.malloc( N * 8 );
237-
var view = new Float64Array( bytes.buffer, bytes.byteOffset, N );
238-
239-
view.set( [ 1.0, -2.0, 3.0 ] );
240-
241-
var ptr = 1 * 8; // 8 bytes per double
242-
var y = bytes.getValue( ptr );
243-
// returns -2.0
244-
245-
wasm.free( bytes );
246-
```
247-
248-
While this method may be convenient when interacting with the bytes view directly, using a [`typed array`][mdn-typed-array] view is likely to be more performant.
249-
250-
```javascript
251-
var Float64Array = require( '@stdlib/array/float64' );
252-
253-
var wasm = dasum.wasm();
254-
255-
var N = 3;
256-
257-
var bytes = wasm.malloc( N * 8 );
258-
var view = new Float64Array( bytes.buffer, bytes.byteOffset, N );
259-
260-
view.set( [ 1.0, -2.0, 3.0 ] );
261-
262-
var y = view[ 1 ];
263-
// returns -2.0
264-
265-
wasm.free( bytes );
266-
```
267-
268-
##### bytes.setValue( ptr, value\[, type] )
269-
270-
Sets a value at a specific memory address (represented by a byte index). By default, the function sets a `double`. Possible types include: `'i8'`, `'i16'`, `'i32'`, `'i64'`, `'float'`, and `'double'`.
271-
272-
```javascript
273-
var Float64Array = require( '@stdlib/array/float64' );
274-
275-
var wasm = dasum.wasm();
276-
277-
var N = 3;
278-
279-
var bytes = wasm.malloc( N * 8 );
280-
var view = new Float64Array( bytes.buffer, bytes.byteOffset, N );
281-
282-
view.set( [ 1.0, -2.0, 3.0 ] );
283-
284-
var ptr = 1 * 8; // 8 bytes per double
285-
var y = bytes.getValue( ptr );
286-
// returns -2.0
287-
288-
bytes.setValue( ptr, -10.0 );
289-
290-
y = bytes.getValue( ptr );
291-
// returns -10.0
292-
293-
wasm.free( bytes );
294-
```
295-
296-
While this method may be convenient when interacting with the bytes view directly, using a [`typed array`][mdn-typed-array] view is likely to be more performant.
297-
298-
```javascript
299-
var Float64Array = require( '@stdlib/array/float64' );
300-
301-
var wasm = dasum.wasm();
302-
303-
var N = 3;
304-
305-
var bytes = wasm.malloc( N * 8 );
306-
var view = new Float64Array( bytes.buffer, bytes.byteOffset, N );
307-
308-
view.set( [ 1.0, -2.0, 3.0 ] );
309-
310-
var y = view[ 1 ];
311-
// returns -2.0
312-
313-
view[ 1 ] = -10.0;
314-
315-
y = view[ 1 ];
316-
// returns -10.0
317-
318-
wasm.free( bytes );
319-
```
320-
321-
##### wasm.free( heap )
322-
323-
Frees allocated space.
324-
325-
```javascript
326-
var wasm = dasum.wasm();
327-
328-
var bytes = wasm.malloc( 64 );
329-
330-
// ...
331-
332-
// Free the space and allow reallocation:
333-
wasm.free( bytes );
334-
```
335-
336137
</section>
337138

338139
<!-- /.usage -->
@@ -393,8 +194,6 @@ console.log( dasum( x.length, x, 1 ) );
393194

394195
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
395196

396-
[mdn-uint8array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
397-
398197
[l1norm]: http://en.wikipedia.org/wiki/Norm_%28mathematics%29
399198

400199
[@stdlib/math/base/special/abs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/abs

lib/node_modules/@stdlib/blas/base/dasum/benchmark/benchmark.asm.js

Lines changed: 0 additions & 109 deletions
This file was deleted.

lib/node_modules/@stdlib/blas/base/dasum/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
2727
var Float64Array = require( '@stdlib/array/float64' );
2828
var pkg = require( './../package.json' ).name;
29-
var dasum = require( './../lib/main.js' );
29+
var dasum = require( './../lib/dasum.js' );
3030

3131

3232
// FUNCTIONS //

0 commit comments

Comments
 (0)