Browse Source

add Fortran wrapper for starpu_timing_now and update nf_matrix to use it

Olivier Aumage 5 years ago
parent
commit
79f6b6340b
2 changed files with 24 additions and 0 deletions
  1. 10 0
      examples/native_fortran/nf_matrix.f90
  2. 14 0
      include/fstarpu_mod.f90

+ 10 - 0
examples/native_fortran/nf_matrix.f90

@@ -29,6 +29,8 @@ program nf_matrix
         type(c_ptr) :: dh_mb    ! a pointer for the 'mb' vector data handle
         integer(c_int) :: err   ! return status for fstarpu_init
         integer(c_int) :: ncpu  ! number of cpus workers
+        real(c_double) :: start_time ! start clock in usec
+        real(c_double) :: end_time   ! end clock in usec
 
         allocate(ma(5,6))
         do i=1,5
@@ -57,6 +59,9 @@ program nf_matrix
                 stop 77
         end if
 
+        ! collect the start clock time
+        start_time = fstarpu_timing_now()
+
         ! allocate an empty codelet structure
         cl_mat = fstarpu_codelet_allocate()
 
@@ -102,10 +107,15 @@ program nf_matrix
         ! free codelet structure
         call fstarpu_codelet_free(cl_mat)
 
+        ! collect the start clock time
+        end_time = fstarpu_timing_now()
+
         ! shut StarPU down
         call fstarpu_shutdown()
 
         deallocate(mb)
         deallocate(ma)
 
+        print "(es 10.3)", end_time - start_time
+
 end program nf_matrix

+ 14 - 0
include/fstarpu_mod.f90

@@ -2250,6 +2250,13 @@ module fstarpu_mod
                         use iso_c_binding, only: c_long
                         integer(c_long), value, intent(in) :: code
                 end subroutine fstarpu_trace_user_event
+
+                ! double starpu_timing_now(void)
+                function fstarpu_timing_now () bind(C,name="starpu_timing_now")
+                        use iso_c_binding, only: c_double
+                        real(c_double) :: fstarpu_timing_now
+                end function fstarpu_timing_now
+
         end interface
 
         contains
@@ -2466,4 +2473,11 @@ module fstarpu_mod
                         integer :: i
                         fstarpu_int_to_cptr = transfer(int(i,kind=c_intptr_t),C_NULL_PTR)
                 end function fstarpu_int_to_cptr
+
+                ! Note: do not add binding declarations here in 'CONTAINS'
+                ! section, because the compiler generates empty functions for
+                ! them.
+                ! Instead, put binding declarations in the 'INTERFACE' section
+                ! above.
+
 end module fstarpu_mod