codelets.f90 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ! StarPU --- Runtime system for heterogeneous multicore architectures.
  2. !
  3. ! Copyright (C) 2016 Inria
  4. !
  5. ! StarPU is free software; you can redistribute it and/or modify
  6. ! it under the terms of the GNU Lesser General Public License as published by
  7. ! the Free Software Foundation; either version 2.1 of the License, or (at
  8. ! your option) any later version.
  9. !
  10. ! StarPU is distributed in the hope that it will be useful, but
  11. ! WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. !
  14. ! See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. module codelets
  16. contains
  17. ! 'cl1' codelet routine
  18. !
  19. ! Note: codelet routines must:
  20. ! . be declared recursive (~ 'reentrant routine')
  21. ! . be declared with the 'bind(C)' attribute for proper C interfacing
  22. recursive subroutine cl_cpu_func1 (buffers, cl_args) bind(C)
  23. use iso_c_binding ! C interfacing module
  24. use fstarpu_mod ! StarPU interfacing module
  25. implicit none
  26. type(c_ptr), value, intent(in) :: buffers, cl_args ! cl_args is unused
  27. real(8), dimension(:), pointer :: va
  28. integer, dimension(:), pointer :: vb
  29. integer :: nx_va,nx_vb,i
  30. write(*,*) "task -->"
  31. ! get 'va' number of elements
  32. nx_va = fstarpu_vector_get_nx(buffers, 0)
  33. write(*,*) "nx_va"
  34. write(*,*) nx_va
  35. ! get 'vb' number of elements
  36. nx_vb = fstarpu_vector_get_nx(buffers, 1)
  37. write(*,*) "nx_vb"
  38. write(*,*) nx_vb
  39. ! get 'va' converted Fortran pointer
  40. call c_f_pointer(fstarpu_vector_get_ptr(buffers, 0), va, shape=[nx_va])
  41. write(*,*) "va"
  42. do i=1,nx_va
  43. write(*,*) i,va(i)
  44. end do
  45. ! get 'vb' converted Fortran pointer
  46. call c_f_pointer(fstarpu_vector_get_ptr(buffers, 1), vb, shape=[nx_vb])
  47. write(*,*) "vb"
  48. do i=1,nx_vb
  49. write(*,*) i,vb(i)
  50. end do
  51. write(*,*) "task <--"
  52. end subroutine cl_cpu_func1
  53. end module codelets