Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28443 Discussions

will an intrinsic type conversion in a function call trigger a temproray array??

may_ka
Beginner
379 Views

Hi,

I am wondering whether the code blow will trigger a temporary array allocation and data copying for array "ima". I compiled with "-check arg_tmp_created"  and "-warn all" but did not get any message.

Program Test
  use blas95 !!mkl blas
  real(kind=8), allocatable :: rmb(:,:), rmc(:,:)
  integer(kind=2), allocatable :: ima(:,:)
  call gemm(A=real(imA,kind=8),B=RMB,C=RMc)
End Program Test

Since the array passed can be of substantial size a temporary array may cause a massive overhead.

Any suggestions appreciated.

0 Kudos
3 Replies
TimP
Honored Contributor III
379 Views

Unless you are providing source code for inlining gemm, it looks like not even a slim possibility to avoid generating a full array copy. 

0 Kudos
gn164
Beginner
379 Views

 

Hi,

I think that in this case the temporary comes from the call to the intrinsic function real.

I do not think that the  -check_arg_tmp_created can detect the temporaries created in these cases.

The flag seems to capture only the temporaries created as a result of passing a non-contiguous array to a procedure.

https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/798195

 

0 Kudos
Steve_Lionel
Honored Contributor III
379 Views

You've asked the compiler to create a copy of ima with the integers converted to reals. By what mechanism do you think it could avoid a copy? If there was a version of gemm that accepted integer for the type of the first array, then you wouldn't use the conversion.

The compiler knows how to do multiplication of reals by smallish integer constants in an efficient manner, but that doesn't work for variables.

0 Kudos
Reply