Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

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

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
Highlighted
Black Belt
1 View

Unless you are providing

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
Highlighted
Beginner
1 View

 

 

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
Highlighted
Black Belt
1 View

You've asked the compiler to

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos