|
8 | 8 |
|
9 | 9 | #include "flang/Runtime/CUDA/memory.h"
|
10 | 10 | #include "flang-rt/runtime/assign-impl.h"
|
| 11 | +#include "flang-rt/runtime/descriptor.h" |
11 | 12 | #include "flang-rt/runtime/terminator.h"
|
12 | 13 | #include "flang/Runtime/CUDA/common.h"
|
13 | 14 | #include "flang/Runtime/CUDA/descriptor.h"
|
@@ -98,8 +99,21 @@ void RTDECL(CUFDataTransferDescDesc)(Descriptor *dstDesc, Descriptor *srcDesc,
|
98 | 99 | } else {
|
99 | 100 | terminator.Crash("host to host copy not supported");
|
100 | 101 | }
|
101 |
| - Fortran::runtime::Assign( |
102 |
| - *dstDesc, *srcDesc, terminator, MaybeReallocate, memmoveFct); |
| 102 | + if ((srcDesc->rank() > 0) && (dstDesc->Elements() < srcDesc->Elements())) { |
| 103 | + // Special case when rhs is bigger than lhs and both are contiguous arrays. |
| 104 | + // In this case we do a simple ptr to ptr transfer with the size of lhs. |
| 105 | + // This is be allowed in the reference compiler and it avoids error |
| 106 | + // triggered in the Assign runtime function used for the main case below. |
| 107 | + if (!srcDesc->IsContiguous() || !dstDesc->IsContiguous()) |
| 108 | + terminator.Crash("Unsupported data transfer: mismatching element counts " |
| 109 | + "with non-contiguous arrays"); |
| 110 | + RTNAME(CUFDataTransferPtrPtr)(dstDesc->raw().base_addr, |
| 111 | + srcDesc->raw().base_addr, dstDesc->Elements() * dstDesc->ElementBytes(), |
| 112 | + mode, sourceFile, sourceLine); |
| 113 | + } else { |
| 114 | + Fortran::runtime::Assign( |
| 115 | + *dstDesc, *srcDesc, terminator, MaybeReallocate, memmoveFct); |
| 116 | + } |
103 | 117 | }
|
104 | 118 |
|
105 | 119 | void RTDECL(CUFDataTransferCstDesc)(Descriptor *dstDesc, Descriptor *srcDesc,
|
|
0 commit comments