浏览代码

add public wrappers for worker functions usable in external sched policies

Olivier Aumage 8 年之前
父节点
当前提交
1a2ba4b6a2
共有 3 个文件被更改,包括 89 次插入16 次删除
  1. 18 16
      doc/doxygen/chapters/api/workers.doxy
  2. 21 0
      include/starpu_worker.h
  3. 50 0
      src/core/workers.c

+ 18 - 16
doc/doxygen/chapters/api/workers.doxy

@@ -254,12 +254,12 @@ on which device the memory needs to be allocated.
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Return worker \p type as a string.
 Return worker \p type as a string.
 
 
-\fn int _starpu_worker_sched_op_pending(void)
+\fn int starpu_worker_sched_op_pending(void)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Return \c !0 if current worker has a scheduling operation in progress,
 Return \c !0 if current worker has a scheduling operation in progress,
 and \c 0 otherwise.
 and \c 0 otherwise.
 
 
-\fn void _starpu_worker_relax_on(void)
+\fn void starpu_worker_relax_on(void)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Allow other threads and workers to temporarily observe the current
 Allow other threads and workers to temporarily observe the current
 worker state, even though it is performing a scheduling operation.
 worker state, even though it is performing a scheduling operation.
@@ -268,30 +268,30 @@ call such as acquiring a mutex other than its own sched_mutex. This
 function increases \c state_relax_refcnt from the current worker. No
 function increases \c state_relax_refcnt from the current worker. No
 more than <c>UINT_MAX-1</c> nested relax_on calls should performed on
 more than <c>UINT_MAX-1</c> nested relax_on calls should performed on
 the same worker. This function is automatically called by \ref
 the same worker. This function is automatically called by \ref
-_starpu_worker_lock to relax the caller worker state while attempting
+starpu_worker_lock to relax the caller worker state while attempting
 to lock the targer worker.
 to lock the targer worker.
 
 
-\fn void _starpu_worker_relax_off(void)
+\fn void starpu_worker_relax_off(void)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Must be called after a potentially blocking call is complete, to
 Must be called after a potentially blocking call is complete, to
 restore the relax state in place before the corresponding relax_on.
 restore the relax state in place before the corresponding relax_on.
-Decreases \c state_relax_refcnt. Calls to \ref _starpu_worker_relax_on
-and \c _starpu_worker_relax_off must be well parenthesized. This
-function is automatically called by \ref _starpu_worker_unlock after the 
+Decreases \c state_relax_refcnt. Calls to \ref starpu_worker_relax_on
+and \c starpu_worker_relax_off must be well parenthesized. This
+function is automatically called by \ref starpu_worker_unlock after the 
 target worker has been unlocked.
 target worker has been unlocked.
 
 
-\fn int _starpu_worker_get_relax_state(void)
+\fn int starpu_worker_get_relax_state(void)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Returns \c !0 if the current worker \c state_relax_refcnt!=0 and \c 0
 Returns \c !0 if the current worker \c state_relax_refcnt!=0 and \c 0
 otherwise.
 otherwise.
 
 
-\fn void _starpu_worker_lock(int workerid)
+\fn void starpu_worker_lock(int workerid)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Acquire the sched mutex of \p workerid. If the caller is a worker,
 Acquire the sched mutex of \p workerid. If the caller is a worker,
 distinct from \p workerid, the caller worker automatically enter relax
 distinct from \p workerid, the caller worker automatically enter relax
 state while acquiring the target worker lock.
 state while acquiring the target worker lock.
 
 
-\fn int _starpu_worker_trylock(int workerid)
+\fn int starpu_worker_trylock(int workerid)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Attempt to acquire the sched mutex of \p workerid. Returns \c 0 if
 Attempt to acquire the sched mutex of \p workerid. Returns \c 0 if
 successful, \c !0 if \p workerid sched mutex is held or the
 successful, \c !0 if \p workerid sched mutex is held or the
@@ -300,22 +300,24 @@ If the caller is a worker, distinct from \p workerid, the caller
 worker automatically enter relax state if successfully acquiring the target
 worker automatically enter relax state if successfully acquiring the target
 worker lock.
 worker lock.
 
 
-\fn void _starpu_worker_unlock(int workerid)
+\fn void starpu_worker_unlock(int workerid)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Release the previously acquired sched mutex of \p workerid. Restore
 Release the previously acquired sched mutex of \p workerid. Restore
 the relaxed state of the caller worker if needed.
 the relaxed state of the caller worker if needed.
 
 
-\fn void _starpu_worker_lock_self(void)
+\fn void starpu_worker_lock_self(void)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Acquire the current worker sched mutex.
 Acquire the current worker sched mutex.
 
 
-\fn void _starpu_worker_unlock_self(void)
+\fn void starpu_worker_unlock_self(void)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
 Release the current worker sched mutex.
 Release the current worker sched mutex.
 
 
-\fn int _starpu_wake_worker_relax(int workerid)
+\fn int starpu_wake_worker_relax(int workerid)
 \ingroup API_Workers_Properties
 \ingroup API_Workers_Properties
-Wake up \p workerid while temporarily entering the current worker
-relaxed state if needed during the waiting process.
+Wake up \p workerid while temporarily entering the current worker relaxed state
+if needed during the waiting process. Returns 1 if \p workerid has been woken
+up or its state_keep_awake flag has been set to 1, and 0 otherwise (if \p
+workerid was not in the STATE_SLEEPING or in the STATE_SCHEDULING).
 
 
 */
 */

+ 21 - 0
include/starpu_worker.h

@@ -140,6 +140,27 @@ int starpu_worker_get_devids(enum starpu_worker_archtype type, int *devids, int
 int starpu_worker_get_stream_workerids(unsigned devid, int *workerids, enum starpu_worker_archtype type);
 int starpu_worker_get_stream_workerids(unsigned devid, int *workerids, enum starpu_worker_archtype type);
 
 
 unsigned starpu_worker_get_sched_ctx_id_stream(unsigned stream_workerid);
 unsigned starpu_worker_get_sched_ctx_id_stream(unsigned stream_workerid);
+
+int starpu_worker_sched_op_pending(void);
+
+void starpu_worker_relax_on(void);
+
+void starpu_worker_relax_off(void);
+
+int starpu_worker_get_relax_state(void);
+
+void starpu_worker_lock(int workerid);
+
+int starpu_worker_trylock(int workerid);
+
+void starpu_worker_unlock(int workerid);
+
+void starpu_worker_lock_self(void);
+
+void starpu_worker_unlock_self(void);
+
+int starpu_wake_worker_relax(int workerid);
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

+ 50 - 0
src/core/workers.c

@@ -2345,3 +2345,53 @@ void _starpu_worker_refuse_task(struct _starpu_worker *worker, struct starpu_tas
 	int res = _starpu_push_task_to_workers(task);
 	int res = _starpu_push_task_to_workers(task);
 	STARPU_ASSERT_MSG(res == 0, "_starpu_push_task_to_workers() unexpectedly returned = %d\n", res);
 	STARPU_ASSERT_MSG(res == 0, "_starpu_push_task_to_workers() unexpectedly returned = %d\n", res);
 }
 }
+
+int starpu_worker_sched_op_pending(void)
+{
+	return _starpu_worker_sched_op_pending();
+}
+
+void starpu_worker_relax_on(void)
+{
+	_starpu_worker_relax_on();
+}
+
+void starpu_worker_relax_off(void)
+{
+	starpu_worker_relax_off();
+}
+
+int starpu_worker_get_relax_state(void)
+{
+	return _starpu_worker_get_relax_state();
+}
+
+void starpu_worker_lock(int workerid)
+{
+	_starpu_worker_lock(workerid);
+}
+
+int starpu_worker_trylock(int workerid)
+{
+	return _starpu_worker_trylock(workerid);
+}
+
+void starpu_worker_unlock(int workerid)
+{
+	_starpu_worker_unlock(workerid);
+}
+
+void starpu_worker_lock_self(void)
+{
+	_starpu_worker_lock_self();
+}
+
+void starpu_worker_unlock_self(void)
+{
+	_starpu_worker_unlock_self();
+}
+
+int starpu_wake_worker_relax(int workerid)
+{
+	return _starpu_wake_worker_relax(workerid);
+}