Просмотр исходного кода

Merge branch 'master' into mpi_redux-tree

Antoine JEGO лет назад: 4
Родитель
Сommit
cdd304ad97

+ 1 - 0
ChangeLog

@@ -86,6 +86,7 @@ Small features:
   * Add STARPU_SCHED_SORTED_ABOVE and STARPU_SCHED_SORTED_BELOW environment
     variables.
   * Add STARPU_SCHED_SIMPLE_PRE_DECISION.
+  * Add starpu_bcsr_filter_canonical_block_get_nchildren.
 
 StarPU 1.3.7
 ====================================================================

+ 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()
 

+ 1 - 6
examples/spmv/dw_block_spmv.c

@@ -119,11 +119,6 @@ void init_problem_callback(void *arg)
 	}
 }
 
-unsigned get_bcsr_nchildren(struct starpu_data_filter *f, starpu_data_handle_t handle)
-{
-  return (unsigned)starpu_bcsr_get_nnz(handle);
-}
-
 void call_filters(void)
 {
 
@@ -131,7 +126,7 @@ void call_filters(void)
 	struct starpu_data_filter vector_in_f, vector_out_f;
 
 	bcsr_f.filter_func    = starpu_bcsr_filter_canonical_block;
-	bcsr_f.get_nchildren = get_bcsr_nchildren;
+	bcsr_f.get_nchildren = starpu_bcsr_filter_canonical_block_get_nchildren;
 	/* the children use a matrix interface ! */
 	bcsr_f.get_child_ops = starpu_bcsr_filter_canonical_block_child_ops;
 

+ 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

+ 8 - 0
include/starpu_data_filters.h

@@ -314,8 +314,16 @@ void starpu_data_partition_not_automatic(starpu_data_handle_t handle);
    Partition a block-sparse matrix into dense matrices.
    starpu_data_filter::get_child_ops needs to be set to
    starpu_bcsr_filter_canonical_block_child_ops()
+   and starpu_data_filter::get_nchildren set to
+   starpu_bcsr_filter_canonical_block_get_nchildren().
 */
 void starpu_bcsr_filter_canonical_block(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);
+
+/**
+   Return the number of children obtained with starpu_bcsr_filter_canonical_block().
+*/
+unsigned starpu_bcsr_filter_canonical_block_get_nchildren(struct starpu_data_filter *f, starpu_data_handle_t handle)
+;
 /**
    Return the child_ops of the partition obtained with starpu_bcsr_filter_canonical_block().
 */

+ 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

+ 5 - 0
src/datawizard/interfaces/bcsr_filters.c

@@ -91,6 +91,11 @@ void starpu_bcsr_filter_canonical_block(void *father_interface, void *child_inte
 	}
 }
 
+unsigned starpu_bcsr_filter_canonical_block_get_nchildren(struct starpu_data_filter *f, starpu_data_handle_t handle)
+{
+  return (unsigned)starpu_bcsr_get_nnz(handle);
+}
+
 struct starpu_data_interface_ops *starpu_bcsr_filter_canonical_block_child_ops(STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, STARPU_ATTRIBUTE_UNUSED unsigned child)
 {
 	return &starpu_interface_matrix_ops;

+ 11 - 0
src/sched_policies/work_stealing_policy.c

@@ -717,6 +717,15 @@ int ws_push_task(struct starpu_task *task)
 	return 0;
 }
 
+static void ws_push_task_notify(struct starpu_task *task, int workerid, int perf_workerid, unsigned sched_ctx_id)
+{
+	(void)task;
+	(void)perf_workerid;
+
+	struct _starpu_work_stealing_data *ws = (struct _starpu_work_stealing_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
+	ws->per_worker[workerid].busy = 1;
+}
+
 static void ws_add_workers(unsigned sched_ctx_id, int *workerids,unsigned nworkers)
 {
 	struct _starpu_work_stealing_data *ws = (struct _starpu_work_stealing_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
@@ -791,6 +800,7 @@ struct starpu_sched_policy _starpu_sched_ws_policy =
 	.remove_workers = ws_remove_workers,
 	.push_task = ws_push_task,
 	.pop_task = ws_pop_task,
+	.push_task_notify = ws_push_task_notify,
 	.pre_exec_hook = NULL,
 	.post_exec_hook = NULL,
 	.pop_every_task = NULL,
@@ -902,6 +912,7 @@ struct starpu_sched_policy _starpu_sched_lws_policy =
 	.remove_workers = ws_remove_workers,
 	.push_task = ws_push_task,
 	.pop_task = ws_pop_task,
+	.push_task_notify = ws_push_task_notify,
 	.pre_exec_hook = NULL,
 	.post_exec_hook = NULL,
 	.pop_every_task = NULL,