Hi
Just looking for advice/guidance. Does anyone know if the newest release supports non-instrinsic function calls from within device kernels now?
eg
attributes(global) subroutine test(bob,charlie)
implicit none
integer, value :: bob
integer, value :: charlie
if( bob .eq. 4 ) then
charlie = help(bob)
endif
return
function help ( input)
implicit none
integer :: input
if(input.eq.4)then
input=5
endif
return
end function
If it is now allowed, what things should I be aware of, e.g. should the data the function explicitly be declared to be device data?
Thanks
Andrew
Hi Andrew,
You’ve always been able to call device kernels from other device kernels provided that they have the device attribute and have the same module scope as the caller.
For example:
module foo
contains
attributes(global) subroutine test(bob,charlie)
implicit none
integer, value :: bob
integer, value :: charlie
if( bob .eq. 4 ) then
charlie = help(bob)
endif
return
end subroutine test
attributes(device) function help (input)
implicit none
integer :: input, help
if(input.eq.4)then
input=5
endif
return
end function help
end module foo
Note, I don’t think the “value” attribute on charlie makes much sense here. Granted, this is just a toy code, but keep it in mind as you continue.