-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
feat: add C ndarray
implementation for blas/base/dscal
#2915
base: develop
Are you sure you want to change the base?
Conversation
x[ i ] *= alpha; | ||
} | ||
return x; | ||
return ndarray( N, alpha, x, stride, 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.
@aman-095 I believe we want to support negative strides here. That means using stride2offset
to compute the offset before calling into the ndarray
API.
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.
But, native dscal
implementation from lapack
doesn't allow for negative stride.
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.
That was my point about converting from negative to positive. But here, our ndarray.js
file should support negative strides. In C, we should convert the stride before calling CBLAS. Meaning, we are free to support negative strides, but we need to ensure that if and when we call a library following LAPACK that we only pass along positive strides. In short, for all our Level 1 routines, we should be consistent in supporting negative strides. The current situation of some supporting and others not supporting is just confusing.
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 means that for our Js implementation, we should allow negative strides for all BLAS Level 1 and only for CBLAS
, or other hardware-optimized libraries we use the same convention of stride conversion.
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.
Correct. We need to update our JS implementations to support negative strides.
X[ i ] *= alpha; | ||
} | ||
return; | ||
API_SUFFIX(c_dscal_ndarray)( N, alpha, X, stride, 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.
@aman-095 Similarly, we should go ahead and support negative strides here.
* @param offset starting index | ||
*/ | ||
void API_SUFFIX(c_dscal_ndarray)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT stride, const CBLAS_INT offset ) { | ||
X += stdlib_strided_min_view_buffer_index( N, stride, offset ); // adjust array pointer |
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.
@aman-095 Before L47, we should convert stride
to a positive stride before calling into CBLAS, which may or may not support negative strides. By always passing in a positive stride, we avoid backward compat breaks.
@@ -31,3 +32,17 @@ | |||
void API_SUFFIX(c_dscal)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT stride ) { | |||
API_SUFFIX(cblas_dscal)( N, alpha, X, stride ); |
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.
@aman-095 We should also support negative strides here.
@@ -31,3 +32,21 @@ | |||
void API_SUFFIX(c_dscal)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT stride ) { | |||
dscal( &N, &alpha, X, &stride ); |
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.
@aman-095 We should also support negative strides here.
*/ | ||
void API_SUFFIX(c_dscal_ndarray)( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT stride, const CBLAS_INT offset ) { | ||
CBLAS_INT sx = stride; | ||
if( sx < 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.
if( sx < 0 ) { | |
if ( sx < 0 ) { |
Progresses #2039.
Description
This pull request:
ndarray
API forblas/base/dscal
.Related Issues
This pull request:
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers