I’m using allocate(..., source = ...)
to allocate and initialize device memory. Is this supported in CUDA Fortran? Asking because compute-sanitizer is complaining about uninitialized memory access, although the data on the device seems correct. No error from the sanitizer if I first allocate then memcpy.
Test code:
program test
type dummy
integer, device, allocatable :: a_d(:)
integer, allocatable :: a(:)
end type
type(dummy) :: b
allocate(b%a(10))
b%a = 1.d0
allocate(b%a_d, source=b%a)
deallocate(b%a)
deallocate(b%a_d)
end program
$ nvfortran -gpu=cc70 -cuda -o test.x test.f90
$ compute-sanitizer --tool initcheck ./test.x
========= Host API memory access error at host access to 0x2aab0f800000 of size 40 bytes
========= Uninitialized access at 0x2aab0f800000 on access by cudaMemcpy source
...
I’m using NVIDIA HPC SDK 21.3, CUDA 11.2.
Thanks!