fortran - How to correctly use mkl_domatcopy from MKL? -
i need find faster way transpose matrix using mkl. , tried mkl_domatcopy mkl never right.
here test code(fortran):
program main integer, parameter:: nrow = 3 !rows integer, parameter:: ncol = 3 !cols real*8, allocatable:: m(:,:) real*8, allocatable:: mt(:,:) integer:: i,j allocate(m(nrow,ncol)) allocate(mt(nrow,ncol)) = 1, nrow j = 1, ncol m(i,j)=i end end call mkl_domatcopy("c","t",3,3,9,m,3,mt,3) print *,m print *,"************************" print *,mt end
and output is:
1.00000000000000 2.00000000000000 3.00000000000000 1.00000000000000 2.00000000000000 3.00000000000000 1.00000000000000 2.00000000000000 3.00000000000000 ************************ 0
why mt 0?is beacause use wrong or something?
documents function: https://software.intel.com/en-us/node/520863
ps:i still don't 'alpha' means.
as user roygvib suggests in comments, including mkl.fi
file give additional details.
this code
program main include 'mkl.fi' integer, parameter:: nrow = 3 !rows integer, parameter:: ncol = 3 !cols real*8, allocatable:: m(:,:) real*8, allocatable:: mt(:,:) integer:: i,j allocate(m(nrow,ncol)) allocate(mt(nrow,ncol)) = 1, nrow j = 1, ncol m(i,j)=i end end call mkl_domatcopy("c","t",3,3,9,m,3,mt,3) print *,m print *,"************************" print *,mt end
raises following error
test.f90(23): error #6633: type of actual argument differs type of dummy argument. [9] call mkl_domatcopy("c","t",3,3,9,m,3,mt,3) -----------------------------------------------^ compilation aborted test.f90 (code 1)
interestingly, if turn 9
double precision value (or variable) -- note here appended d0
suffix floating point value.
program main include 'mkl.fi' integer, parameter:: nrow = 3 !rows integer, parameter:: ncol = 3 !cols real*8, allocatable:: m(:,:) real*8, allocatable:: mt(:,:) integer:: i,j allocate(m(nrow,ncol)) allocate(mt(nrow,ncol)) = 1, nrow j = 1, ncol m(i,j)=i end end call mkl_domatcopy("c","t",3,3,9d0,m,3,mt,3) print *,m print *,"************************" print *,mt end
then application returns
$ ./test 1.00000000000000 2.00000000000000 3.00000000000000 1.00000000000000 2.00000000000000 3.00000000000000 1.00000000000000 2.00000000000000 3.00000000000000 ************************ 9.00000000000000 9.00000000000000 9.00000000000000 18.0000000000000 18.0000000000000 18.0000000000000 27.0000000000000 27.0000000000000 27.0000000000000
finally, respect alpha
means, manual says
alpha parameter scales input matrix alpha.
and notice output tranposed , each element multiplied 9.
Comments
Post a Comment