Quellcode durchsuchen

add api call to query whether starpu is currently paused

Olivier Aumage vor 4 Jahren
Ursprung
Commit
4d757e284c
4 geänderte Dateien mit 38 neuen und 0 gelöschten Zeilen
  1. 21 0
      examples/native_fortran/nf_vector.f90
  2. 6 0
      include/fstarpu_mod.f90
  3. 5 0
      include/starpu.h
  4. 6 0
      src/core/workers.c

+ 21 - 0
examples/native_fortran/nf_vector.f90

@@ -29,6 +29,7 @@ program nf_vector
         type(c_ptr) :: dh_vb    ! a pointer for the 'vb' vector data handle
         integer(c_int) :: err   ! return status for fstarpu_init
         integer(c_int) :: ncpu  ! number of cpus workers
+        integer(c_int) :: bool_ret
 
         allocate(va(5))
         va = (/ (i,i=1,5) /)
@@ -49,6 +50,26 @@ program nf_vector
                 stop 77
         end if
 
+        ! illustrate use of pause/resume/is_paused
+        bool_ret = fstarpu_is_paused()
+        if (bool_ret /= 0) then
+                stop 1
+        end if
+
+        call fstarpu_pause
+
+        bool_ret = fstarpu_is_paused()
+        if (bool_ret == 0) then
+                stop 1
+        end if
+
+        call fstarpu_resume
+
+        bool_ret = fstarpu_is_paused()
+        if (bool_ret /= 0) then
+                stop 1
+        end if
+
         ! allocate an empty perfmodel structure
         perfmodel_vec = fstarpu_perfmodel_allocate()
 

+ 6 - 0
include/fstarpu_mod.f90

@@ -203,6 +203,12 @@ module fstarpu_mod
                 subroutine fstarpu_resume() bind(C,name="starpu_resume")
                 end subroutine fstarpu_resume
 
+                ! int starpu_is_paused(void);
+                function fstarpu_is_paused() bind(C,name="starpu_is_paused")
+                        use iso_c_binding, only: c_int
+                        integer(c_int) :: fstarpu_is_paused
+                end function fstarpu_is_paused
+
                 ! void starpu_shutdown(void);
                 subroutine fstarpu_shutdown () bind(C,name="starpu_shutdown")
                 end subroutine fstarpu_shutdown

+ 5 - 0
include/starpu.h

@@ -537,6 +537,11 @@ void starpu_pause(void);
 void starpu_resume(void);
 
 /**
+   Return !0 if task processing by workers is currently paused, 0 otherwise.
+ */
+int starpu_is_paused(void);
+
+/**
    Value to be passed to starpu_get_next_bindid() and
    starpu_bind_thread_on() when binding a thread which will
    significantly eat CPU time, and should thus have its own dedicated

+ 6 - 0
src/core/workers.c

@@ -1792,6 +1792,12 @@ void starpu_resume()
 	starpu_fxt_trace_user_event_string("starpu_resume");
 }
 
+int starpu_is_paused()
+{
+	STARPU_RMB();
+	return _starpu_config.pause_depth > 0;
+}
+
 unsigned _starpu_worker_can_block(unsigned memnode STARPU_ATTRIBUTE_UNUSED, struct _starpu_worker *worker STARPU_ATTRIBUTE_UNUSED)
 {
 #ifdef STARPU_NON_BLOCKING_DRIVERS