@@ -70,3 +70,29 @@ TEST(MemoryCUFTest, CUFDataTransferDescDesc) {
7070 EXPECT_EQ (*host->ZeroBasedIndexedElement <std::int32_t >(i), (std::int32_t )i);
7171 }
7272}
73+
74+ TEST (MemoryCUFTest, CUFDataTransferDescDescDstNotAllocated) {
75+ using Fortran::common::TypeCategory;
76+ RTNAME (CUFRegisterAllocator)();
77+ // INTEGER(4), DEVICE, ALLOCATABLE :: a(:)
78+ auto dev{createAllocatable (TypeCategory::Integer, 4 )};
79+ dev->SetAllocIdx (kDeviceAllocatorPos );
80+ EXPECT_EQ ((int )kDeviceAllocatorPos , dev->GetAllocIdx ());
81+ EXPECT_FALSE (dev->IsAllocated ());
82+
83+ // Create temp array to transfer to device.
84+ auto x{MakeArray<TypeCategory::Integer, 4 >(std::vector<int >{10 },
85+ std::vector<int32_t >{0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 })};
86+ RTNAME (CUFDataTransferDescDesc)
87+ (dev.get (), x.get (), kHostToDevice , __FILE__, __LINE__);
88+
89+ // Retrieve data from device.
90+ auto host{MakeArray<TypeCategory::Integer, 4 >(std::vector<int >{10 },
91+ std::vector<int32_t >{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 })};
92+ RTNAME (CUFDataTransferDescDesc)
93+ (host.get (), dev.get (), kDeviceToHost , __FILE__, __LINE__);
94+
95+ for (unsigned i = 0 ; i < 10 ; ++i) {
96+ EXPECT_EQ (*host->ZeroBasedIndexedElement <std::int32_t >(i), (std::int32_t )i);
97+ }
98+ }
0 commit comments