Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

copy for integer array

Ren_J_
Beginner
886 Views

Hello,

I have a naive question about that why there is only float array copy .

Is the time cost of integer array copy much smaller than float number copy?

 

Best Regards,

Jiajun

0 Kudos
4 Replies
Murat_G_Intel
Employee
886 Views

If we are just copying (no scaling), there is no difference between integer vs. float. We copy bits from one memory location to another and it does not mater what those bits represent (integer/float/string/etc..). memcpy can be used for this operation. If you really want to use MKL, you can typecast your 32bit integer pointers to float* and call scopy. Similarly, you can typecast your 64bit integer pointers to doubles* and call dcopy.

0 Kudos
TimP
Honored Contributor III
886 Views

Intel Fortran and C++ compilers would likely substitute intel_fast_memcpy when optimizing a single isolated loop. MKL ?copy have a potential higher bandwidth when parallelizing internally across multiple CPUs, if the source and destination have suitable NUMA locality.

Either an optimized memcpy or MKL ?copy should look for the case where non-temporal streaming store is preferred.

The short answer is that compilers can usually make as good or better choice when the programmer leaves the details to the compilers.

0 Kudos
Ren_J_
Beginner
886 Views

Murat Efe Guney (Intel) wrote:

If we are just copying (no scaling), there is no difference between integer vs. float. We copy bits from one memory location to another and it does not mater what those bits represent (integer/float/string/etc..). memcpy can be used for this operation. If you really want to use MKL, you can typecast your 32bit integer pointers to float* and call scopy. Similarly, you can typecast your 64bit integer pointers to doubles* and call dcopy.

I use fortran. It seems that Fortran 95 interface do not support integer copy. 

for example 

==============

integer a(10),b(10)

call copy(a,b) 

==============

It doesn't work.

But f77 interface works. 

==============

call scopy(10,a,1,b,1) 

==============

0 Kudos
TimP
Honored Contributor III
886 Views

Yes, you would have to add the corresponding interface block to blas.f90 (and disable warn_interfaces) to persuade the compiler to use the scopy or dcopy for integer types.

0 Kudos
Reply