-
-
Notifications
You must be signed in to change notification settings - Fork 866
feat: add blas/base/wasm/zscal
#6810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
/stdlib update-copyright-years |
Coverage Report
The above coverage report was generated for the changes in this PR. |
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
@kgryte, I have changed the variable names |
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
Signed-off-by: Athan <[email protected]>
mod.realloc( ((N*2)*nb)+nb ); | ||
|
||
// Define a pointer (i.e., byte offset) to the first vector element: | ||
xptr = 0; | ||
|
||
// Define a pointer to a complex number: | ||
zptr = (N*2) * nb; | ||
|
||
// Write random values to module memory: | ||
mod.write( xptr, uniform( (N*2), -100.0, 100.0, options ) ); | ||
mod.write( zptr, new Float64Array( [ 1.0, 0.0 ] ) ); | ||
|
||
// Retrieve a DataView of module memory: | ||
view = mod.view; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
mod.main( (N*2), zptr, xptr, 1 ); | ||
byteOffset = xptr + ( (i%(N*2))*nb ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to be a bit confused regarding bytes offsets and the mixing of real and complex.
mod.realloc( ((N*2)*nb)+nb ); | |
// Define a pointer (i.e., byte offset) to the first vector element: | |
xptr = 0; | |
// Define a pointer to a complex number: | |
zptr = (N*2) * nb; | |
// Write random values to module memory: | |
mod.write( xptr, uniform( (N*2), -100.0, 100.0, options ) ); | |
mod.write( zptr, new Float64Array( [ 1.0, 0.0 ] ) ); | |
// Retrieve a DataView of module memory: | |
view = mod.view; | |
b.tic(); | |
for ( i = 0; i < b.iterations; i++ ) { | |
mod.main( (N*2), zptr, xptr, 1 ); | |
byteOffset = xptr + ( (i%(N*2))*nb ); | |
mod.realloc( (N*nb)+nb ); | |
// Define a pointer (i.e., byte offset) to the first vector element: | |
xptr = 0; | |
// Define a pointer to a complex number: | |
zptr = N * nb; | |
// Write random values to module memory: | |
mod.write( xptr, uniform( (N*2), -100.0, 100.0, options ) ); | |
mod.write( zptr, new Float64Array( [ 1.0, 0.0 ] ) ); | |
// Retrieve a DataView of module memory: | |
view = mod.view; | |
b.tic(); | |
for ( i = 0; i < b.iterations; i++ ) { | |
mod.main( N, zptr, xptr, 1 ); | |
byteOffset = xptr + ( (i%N)*nb ); |
|
||
// Reallocate the underlying memory to allow storing one vector and a complex number: | ||
nb = bytesPerElement( 'complex128' ); | ||
mod.realloc( ((N*2)*nb)+nb ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same changes here. You are over-allocating by 2x. nb
is the number of bytes per element for complex128
, not float64
.
> {{alias}}.main( 2, alpha, x, 1 ) | ||
<Complex128Array>[ -3.0, 4.0, -5.0, 10.0 ] | ||
|
||
// Advanced indexing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Advanced indexing: | |
// Using `N` and stride parameters: |
// Using typed array views: | ||
> var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); | ||
> var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); | ||
> var alpha = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> var alpha = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 ); | |
> alpha = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 ); |
alpha
has already been declared above.
Number of indexed elements. | ||
|
||
alpha: Complex128 | ||
Complex constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complex constant. | |
Scalar constant. |
Number of indexed elements. | ||
|
||
alpha: Complex128 | ||
Complex constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complex constant. | |
Scalar constant. |
Number of indexed elements. | ||
|
||
ap: integer | ||
Pointer (i.e., byte offset) to a scalar complex constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointer (i.e., byte offset) to a scalar complex constant. | |
Pointer (i.e., byte offset) to a scalar constant. |
Number of indexed elements. | ||
|
||
ap: integer | ||
Pointer (i.e., byte offset) to a scalar complex constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointer (i.e., byte offset) to a scalar complex constant. | |
Pointer (i.e., byte offset) to a scalar constant. |
mod.write( xp, new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5 ] ) ); | ||
mod.write( ap, new Float64Array( [ 0.4, -0.7 ] ) ); | ||
|
||
out = mod.main( 0, ap, xp, 1 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is incorrect. You need to actually confirm that the original array is unchanged. This test does nothing of the sort. For an idea of what is expected, see blas/base/wasm/daxpy/test/test.module.main.js
.
t.end(); | ||
}); | ||
|
||
tape( 'a module instance has a `main` method which returns a reference to the input array', function test( t ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't return a reference
. It returns a pointer
. See the Wasm implementation for daxpy
.
t.end(); | ||
}); | ||
|
||
tape( 'a module instance has an `ndarray` method which returns a reference to the input array', function test( t ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't return a reference
. It returns a pointer
. See the Wasm implementation for daxpy
.
mod.write( ap, new Float64Array( [ 0.4, -0.7 ] ) ); | ||
|
||
out = mod.ndarray( 0, ap, xp, 1, 0 ); | ||
t.strictEqual( out, xp, 'returns expected value' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. You are not testing that the array is left unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left initial comments. This PR is mostly in good shape. The most glaring defect is in the tests.
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Progresses #2039
Description
This pull request:
blas/base/wasm/zscal
Related Issues
This pull request:
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers