我有下面的Fortran代码(在堆栈溢出的许多答案之上修改)
Program blas
integer, parameter :: dp = selected_real_kind(15, 307)
Real( dp ), Dimension( :, : ), Allocatable :: a
Real( dp ), Dimension( :, :, : ), Allocatable :: b
Real( dp ), Dimension( :, :, : ), Allocatable :: c1, c2
Integer :: na, nb, nc, nd, ne
Integer :: la, lb, lc, ld
Write( *, * ) 'na, nb, nc, nd ?'
Read( *, * ) na, nb, nc, nd
ne = nc * nd
Allocate( a ( 1:na, 1:nb ) )
Allocate( b ( 1:nb, 1:nc, 1:nd ) )
Allocate( c1( 1:na, 1:nc, 1:nd ) )
Allocate( c2( 1:na, 1:nc, 1:nd ) )
Call Random_number( a )
Call Random_number( b )
c1 = 0.0_dp
c2 = 0.0_dp
do ld = 1, nd
do lc = 1, nc
do lb = 1, nb
do la = 1, na
c1(la,lc,ld) = c1(la,lc,ld) + a(la,lb) * b(lb, lc, ld)
end do
end do
end do
end do
Call dgemm( 'N', 'N', na, ne, nb, 1.0_dp, a , Size( a , Dim = 1 ), &
b , Size( b , Dim = 1 ), &
0.0_dp, c2, Size( c2, Dim = 1 ) )
do la = 1, na
do lc = 1, nc
do ld = 1, nd
if ( dabs(c2(la,lc,ld) - c1(la,lc,ld)) > 1.e-6 ) then
write (*,*) '!!! c2', la,lc,ld, c2(la,lc,ld) - c1(la,lc,ld)
endif
enddo
enddo
enddo
End
(叫test.f90
)。
它由gfortran -O3 test.f90 -L/opt/OpenBLAS/lib -lopenblas
工作。然后,我尝试将gfortran链接到mkl
,这是由https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html建议的。
gfortran -O3 test.f90 -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_gf_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ld
。我得到了Intel MKL ERROR: Parameter 10 was incorrect on entry to DGEMM .
我的问题是,参数10有什么问题?以及如何修复它?如果我将ifort
与-mkl
结合使用,似乎不会出现上述问题。
发布于 2021-12-21 07:22:51
您选择了MKL的ilp64版本。这意味着整数、长和指针是64位.但是您没有使用64位整数的gfortran,我知道的所有编译器中的缺省值都是32位整数。您希望使用不同版本的MKL,比如lp64,或者您希望设置gfortran来使用64位默认整数。对于前者,在Link中选择32位整数接口层。
另见https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
https://stackoverflow.com/questions/70429724
复制相似问题