Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module thrust
- interface thrustmin
- function min_float(input,N) bind(C,name="min_float_wrapper")
- use iso_c_binding
- real(c_float),device:: input(*)
- integer(c_int),value:: N, min_float
- end function
- function min_double(input,N) bind(C,name="min_double_wrapper")
- use iso_c_binding
- real(c_double),device:: input(*)
- integer(c_int),value:: N, min_double
- end function
- ! subroutine min_double(input,N) bind(C,name="min_double_wrapper")
- ! use iso_c_binding
- ! real(c_double),device:: input(*)
- ! integer(c_int),value:: N
- ! end subroutine
- end interface
- end module thrust
- program GPU
- use cudafor
- use thrust
- implicit none
- real, allocatable, device :: dev_array(:)
- real, allocatable :: host_array(:)
- integer N / 20 /
- integer :: x
- allocate(dev_array(N))
- allocate(host_array(N))
- call random_seed
- call random_number(host_array)
- print *, "host_array:"
- print *, host_array
- print *, "COPY!"
- dev_array = host_array
- print *, "START CUDA!"
- x = thrustmin(dev_array, size(dev_array))
- print *, "DONE CUDA!"
- print *, "Min:", x
- deallocate(dev_array)
- deallocate(host_array)
- end program GPU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement