About memory allocation and memory copy

It is a about the memory allocation and memory copy between CPU and GPU. In high dimension cases could the memory copy by done by
For example d_A is a 5 dimensional array
d_A(:,:,:,:,:) = A(:,:,:,:,:)


Hi soniccrazy,

Sure, but you could simplify it further with just “dA = A”.

  • Mat

This issue is (well, was) discussed fairly regularly in the comp.lang.fortran newsgroup.

Be aware that

d_A(:,:,:,:,:) = A(:,:,:,:,:)

is not the same as

d_A = A

as the former is using array slices. For assignment I doubt it’s a big deal. In other situations 99.9% of the time it probably won’t matter. For GPU’s I can’t say (no experience).

The most common argument for using this type of assignment is that it provides a visual reminder to the reader of the code that d_A and A are arrays, not scalars. I don’t subscribe to it.

FWIW, when I see code that contains assignment statements using array slices like your example, it’s an indication the code was written by someone new to Fortran90+ (or following coding guidelines written back in the 1990’s when Fortran90 was sliced bread and Fortran77 coders were mildly confused :o)