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

depress priority of worker threads, to let application thread get worken up more quickly

Samuel Thibault лет назад: 8
Родитель
Сommit
61850e3a9e
3 измененных файлов с 13 добавлено и 0 удалено
  1. 1 0
      mpi/src/starpu_mpi.c
  2. 10 0
      src/common/utils.h
  3. 2 0
      src/core/workers.c

+ 1 - 0
mpi/src/starpu_mpi.c

@@ -1280,6 +1280,7 @@ static void *_starpu_mpi_progress_thread_func(void *arg)
 	int rank, worldsize;
 
 	starpu_pthread_setname("MPI");
+	STARPU_PTHREAD_DEPRESS_PRIORITY();
 
 #ifndef STARPU_SIMGRID
 	_starpu_mpi_do_initialize(argc_argv);

+ 10 - 0
src/common/utils.h

@@ -25,6 +25,10 @@
 #include <stdlib.h>
 #include <math.h>
 #include <pthread.h>
+#ifdef __linux__
+#include <sys/resource.h>
+#include <sys/syscall.h>
+#endif
 #ifdef STARPU_HAVE_SCHED_YIELD
 #include <sched.h>
 #endif
@@ -90,6 +94,12 @@
 #define STARPU_UYIELD() _STARPU_UYIELD()
 #endif
 
+#if !defined(STARPU_SIMGRID) && defined(__linux__) && defined(SYS_gettid)
+#define STARPU_PTHREAD_DEPRESS_PRIORITY() setpriority(PRIO_PROCESS, syscall(SYS_gettid), 19)
+#else
+#define STARPU_PTHREAD_DEPRESS_PRIORITY() ((void)0)
+#endif
+
 #ifdef STARPU_VERBOSE
 #  define _STARPU_DEBUG(fmt, ...) do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%s] " fmt ,__starpu_func__ ,## __VA_ARGS__); fflush(stderr); }} while(0)
 #else

+ 2 - 0
src/core/workers.c

@@ -598,6 +598,8 @@ void _starpu_driver_start(struct _starpu_worker *worker, unsigned fut_key, unsig
 	STARPU_PTHREAD_COND_SIGNAL(&worker->started_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&worker->mutex);
 
+	STARPU_PTHREAD_DEPRESS_PRIORITY();
+
 	_starpu_bind_thread_on_cpu(worker->config, worker->bindid, worker->workerid);
 
 #if defined(STARPU_PERF_DEBUG) && !defined(STARPU_SIMGRID)