| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /* StarPU --- Runtime system for heterogeneous multicore architectures.
- *
- * Copyright (C) 2011 INRIA
- *
- * StarPU is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * StarPU is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
- #ifndef __SCHED_CONTEXT_H__
- #define __SCHED_CONTEXT_H__
- #include <starpu.h>
- #include <starpu_scheduler.h>
- #include <common/config.h>
- #include <common/barrier_counter.h>
- #include <profiling/profiling.h>
- struct starpu_sched_ctx {
- /* id of the context used in user mode*/
- unsigned sched_ctx_id;
- /* name of context */
- const char *sched_name;
- /* policy of the context */
- struct starpu_sched_policy_s *sched_policy;
- /* data necessary for the policy */
- void *policy_data;
-
- /* list of indices of workers */
- int workerid[STARPU_NMAXWORKERS];
-
- /* number of threads in contex */
- int nworkers_in_ctx;
- /* temporary variable for number of threads in contex */
- int temp_nworkers_in_ctx;
-
- /* mutext for temp_nworkers_in_ctx*/
- pthread_mutex_t changing_ctx_mutex;
- /* we keep an initial sched which we never delete */
- unsigned is_initial_sched;
- /* wait for the tasks submitted to the context to be executed */
- struct _starpu_barrier_counter_t tasks_barrier;
- /* table of sched cond corresponding to each worker in this ctx */
- pthread_cond_t **sched_cond;
- /* table of sched mutex corresponding to each worker in this ctx */
- pthread_mutex_t **sched_mutex;
- };
- struct starpu_machine_config_s;
- struct callback_list callback_lists[STARPU_NMAXWORKERS];
- /* init sched_ctx_id of all contextes*/
- void _starpu_init_all_sched_ctx(struct starpu_machine_config_s *config);
- /* init the list of contextes of the worker */
- void _starpu_init_sched_ctx_for_worker(unsigned workerid);
- /* allocate all structures belonging to a context */
- struct starpu_sched_ctx* _starpu_create_sched_ctx(const char *policy_name, int *workerid, int nworkerids, unsigned is_init_sched, const char *sched_name);
- /* delete all sched_ctx */
- void _starpu_delete_all_sched_ctxs();
- /* Keeps track of the number of tasks currently submitted to a worker */
- void _starpu_decrement_nsubmitted_tasks_of_worker(int workerid);
- void _starpu_increment_nsubmitted_tasks_of_worker(int workerid);
- /* In order to implement starpu_wait_for_all_tasks_of_ctx, we keep track of the number of
- * task currently submitted to the context */
- void _starpu_decrement_nsubmitted_tasks_of_sched_ctx(unsigned sched_ctx_id);
- void _starpu_increment_nsubmitted_tasks_of_sched_ctx(unsigned sched_ctx_id);
- /* Return the corresponding index of the workerid in the ctx table */
- int _starpu_get_index_in_ctx_of_workerid(unsigned sched_ctx, unsigned workerid);
- /* Get the mutex corresponding to the global workerid */
- pthread_mutex_t *_starpu_get_sched_mutex(struct starpu_sched_ctx *sched_ctx, int worker);
- /* Get the cond corresponding to the global workerid */
- pthread_cond_t *_starpu_get_sched_cond(struct starpu_sched_ctx *sched_ctx, int worker);
- /* Get the total number of sched_ctxs created till now */
- unsigned _starpu_get_nsched_ctxs();
- #endif // __SCHED_CONTEXT_H__
|