about cblas_sscal function

15 views
Skip to first unread message

Kyou Aoyagi

unread,
Nov 27, 2022, 10:49:05 PM11/27/22
to OpenBLAS-users
Hi.Arithmetic library for vector scalar multiplication for single-precision floating-point numbers. I think that the calculation result for cblas_sscal is strange.
When the following code is executed, it seems that the calculation is not performed from the 32nd as shown below. It seems to operate correctly when n is 63 or less.
If it was cblas_dscal, it could be calculated normally.

#include<numeric> 
#include<vector> 
int main(){
    int n = 64; 
    std::vector<float> v(n); 
    std::iota(v.begin(), v.end(), 0); 
    cblas_sscal(n, 0.005f, v.data(), 1 );
    for(auto& i:v) 
         std::cout << i << ' '; 
    std::cout <<'\n'; 
}
/* result
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05 0.055 0.06 0.065 0.07 0.075 0.08 0.085 0.09 0.095 0.1 0.105 0.11 0.115 0.12 0.125 0.13 0.135 0.14 0.145 0.15 0.155 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
*/

Kyou Aoyagi

unread,
Nov 28, 2022, 2:58:40 PM11/28/22
to OpenBLAS-users
I am sorry. It seems that the condition of my computer or the library is not normal.
I will withdraw the post.

2022年11月28日月曜日 12:49:05 UTC+9 Kyou Aoyagi:

Kyou Aoyagi

unread,
Nov 28, 2022, 3:03:32 PM11/28/22
to OpenBLAS-users
However, I would like to know the cause of why such an event occurred. It's very frustrating to have incorrect results when you don't know it.

2022年11月29日火曜日 4:58:40 UTC+9 Kyou Aoyagi:

Kyou Aoyagi

unread,
Dec 8, 2022, 12:09:04 AM12/8/22
to OpenBLAS-users
I understand the cause.
My current environment is as follows.

In xcode's 'Build settings', setting the 'Dead Code Stripping' option in the 'Linking' option to Yes gave incorrect results and setting it to No gave correct results. This is a problem that did not occur in versions up to xcode 13, but I will let you know for reference.

environment
macos 13.0.1
Xcode 14.1
clang
c++17
openblas 0.3.21
staticlibrary

2022年11月29日火曜日 5:03:32 UTC+9 Kyou Aoyagi:
Reply all
Reply to author
Forward
0 new messages