首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >与MKL的gfortran链接导致“Intel MKL错误:参数10在进入DGEMM时不正确”

与MKL的gfortran链接导致“Intel MKL错误:参数10在进入DGEMM时不正确”
EN

Stack Overflow用户
提问于 2021-12-21 01:24:36
回答 1查看 373关注 0票数 3

我有下面的Fortran代码(在堆栈溢出的许多答案之上修改)

代码语言:javascript
运行
复制
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结合使用,似乎不会出现上述问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70429724

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档