FYI tested on macOS Sonoma 14.6.1 + gfortran 14.2.0 and the stdlib
interface:
program sblas
use stdlib_linalg_blas
! test some single-precision blas results.
implicit none(type,external)
real :: x(2)=[3.,4.], y(2)=[1.,1.]
complex :: w(2)=[(4.,3.),(3.,4.)], z(2)=[(5.,6.),(7.,8.)]
character(*), parameter :: cfmt='(*(g0.4,1x))'
write(*,cfmt) 'sdot=', dot(2,x,1,y,1), 'should be 7.000'
write(*,cfmt) 'sdsdot=', stdlib_sdsdot(2,0.0,x,1,y,1), 'should be 7.000'
write(*,cfmt) 'snrm2=', nrm2(2,x,1), 'should be 5.000'
write(*,cfmt) 'scnrm2=', nrm2(2,w,1), 'should be 7.071'
write(*,cfmt) 'sasum=', asum(2,x,1), 'should be 7.000'
write(*,cfmt) 'scasum=', asum(2,w,1), 'should be 14.00'
write(*,cfmt) 'cdotu=', dotu(2,w,1,z,1), 'should be -9.000 91.00'
write(*,cfmt) 'cdotc=', dotc(2,w,1,z,1), 'should be 91.00 5.000'
end program sblas
- Using our internal implementation everything works OK:
[dependencies]
stdlib ="*"
fpm run
sdot= 7.000 should be 7.000
sdsdot= 7.000 should be 7.000
snrm2= 5.000 should be 5.000
scnrm2= 7.071 should be 7.071
sasum= 7.000 should be 7.000
scasum= 14.00 should be 14.00
cdotu= -9.000 91.00 should be -9.000 91.00
cdotc= 91.00 5.000 should be 91.00 5.000
- With the Accelerate backend, it returns wrong results and crashes on
dotu
:
[dependencies]
stdlib = { git="https://github.com/fortran-lang/stdlib", branch="stdlib-fpm", preprocess.cpp.macros=["STDLIB_EXTERNAL_BLAS", "STDLIB_EXTERNAL_LAPACK"] }
fpm run --flag " -framework Accelerate"
sdot= 0.000 should be 7.000
sdsdot= 7.000 should be 7.000
snrm2= 0.000 should be 5.000
scnrm2= 0.000 should be 7.071
sasum= 0.000 should be 7.000
scasum= 0.000 should be 14.00
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x1050bad2f
#1 0x1050b9d83
#2 0x198e22583
#3 0x104a71d8b
#4 0x104a71e0f
<ERROR> Execution for object " sblas_test " returned exit code 11
<ERROR> *cmd_run*:stopping due to failed executions
STOP 11