Hi,
We don’t normally recommend developers use F90 pointers in device code. They can have very high overheads, though in your case, a pointer to a scalar type is pretty efficient. Linked lists are not good parallel data structures, and in your case here, the allocations in device code also have high overhead.
The bug though is we don’t properly support device functions which return pointers, which is what you have used. I can get the code to compile and run by changing the function to a subroutine:
ATTRIBUTES(DEVICE) SUBROUTINE InsertList(head, elem)
IMPLICIT NONE
type( ListElem ), pointer :: head, elem
elem%next => head
END SUBROUTINE InsertList
END MODULE
MODULE Test
CONTAINS
ATTRIBUTES(GLOBAL) SUBROUTINE KERNEL()
USE ListModule
IMPLICIT NONE
type( ListElem ), pointer :: head
type( ListElem ), pointer :: newElem, h
integer :: i,N = 4
INTEGER(KIND=4),ALLOCATABLE::ND(:)
allocate( newElem )
allocate( head )
newElem%value=1
head%value=2
PRINT*,newElem%value
call InsertList(head, newElem)
PRINT*,newElem%next%value
Unless you really need every CUDA thread to have its own linked list, I would recommend looking at other ways to build your data structures.