task.h 4.22 KB
Newer Older
1
/*******************************************************************************
2
 * This file is part of SWIFT.
3
 * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4
 *                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
5
6
7
 *               2015 Peter W. Draper (p.w.draper@durham.ac.uk)
 *               2016 John A. Regan (john.a.regan@durham.ac.uk)
 *                    Tom Theuns (tom.theuns@durham.ac.uk)
8
 *
9
10
11
12
 * This program 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 3 of the License, or
 * (at your option) any later version.
13
 *
14
15
16
17
 * This program 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 General Public License for more details.
18
 *
19
20
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 ******************************************************************************/
23
24
#ifndef SWIFT_TASK_H
#define SWIFT_TASK_H
25

26
27
#include "../config.h"

28
/* Includes. */
29
#include "align.h"
30
#include "cell.h"
31
#include "cycle.h"
32

33
#define task_align 128
34

35
36
37
/**
 * @brief The different task types.
 */
38
enum task_types {
39
40
41
42
  task_type_none = 0,
  task_type_sort,
  task_type_self,
  task_type_pair,
43
44
  task_type_sub_self,
  task_type_sub_pair,
Matthieu Schaller's avatar
Matthieu Schaller committed
45
  task_type_init,
46
  task_type_ghost,
47
  task_type_extra_ghost,
48
  task_type_drift,
49
50
  task_type_kick1,
  task_type_kick2,
51
  task_type_timestep,
52
53
  task_type_send,
  task_type_recv,
54
55
  task_type_grav_gather_m,
  task_type_grav_fft,
56
  task_type_grav_mm,
57
  task_type_grav_up,
58
  task_type_cooling,
Tom Theuns's avatar
Tom Theuns committed
59
  task_type_sourceterms,
60
  task_type_count
61
} __attribute__((packed));
62

63
64
65
/**
 * @brief The different task sub-types (for pairs, selfs and sub-tasks).
 */
66
enum task_subtypes {
67
68
  task_subtype_none = 0,
  task_subtype_density,
69
  task_subtype_gradient,
70
71
  task_subtype_force,
  task_subtype_grav,
72
  task_subtype_external_grav,
73
  task_subtype_tend,
74
  task_subtype_xv,
75
76
  task_subtype_rho,
  task_subtype_count
77
} __attribute__((packed));
78

79
80
81
/**
 * @brief The type of particles/objects this task acts upon in a given cell.
 */
82
83
84
85
86
87
88
89
90
enum task_actions {
  task_action_none,
  task_action_part,
  task_action_gpart,
  task_action_all,
  task_action_multipole,
  task_action_count
};

91
92
93
94
95
96
97
98
/**
 * @brief Names of the task types.
 */
extern const char *taskID_names[];

/**
 * @brief Names of the task sub-types.
 */
99
extern const char *subtaskID_names[];
100

101
102
103
/**
 * @brief A task to be run by the #scheduler.
 */
104
105
struct task {

106
107
  /*! Pointers to the cells this task acts upon */
  struct cell *ci, *cj;
108

109
110
111
  /*! List of tasks unlocked by this one */
  struct task **unlock_tasks;

112
113
114
115
116
117
118
119
120
#ifdef WITH_MPI

  /*! Buffer for this task's communications */
  void *buff;

  /*! MPI request corresponding to this task */
  MPI_Request req;

#endif
121

122
123
124
125
126
127
128
129
  /*! Flags used to carry additional information (e.g. sort directions) */
  int flags;

  /*! Rank of a task in the order */
  int rank;

  /*! Weight of the task */
  int weight;
Pedro Gonnet's avatar
Pedro Gonnet committed
130

131
132
133
134
#if defined(WITH_MPI) && defined(HAVE_METIS)
  /*! Individual cost estimate for this task. */
  int cost;
#endif
135
136

  /*! Number of tasks unlocked by this one */
137
  short int nr_unlock_tasks;
138

139
140
  /*! Number of unsatisfied dependencies */
  short int wait;
141

142
143
  /*! Type of the task */
  enum task_types type;
144

145
146
  /*! Sub-type of the task (for the tasks that have one */
  enum task_subtypes subtype;
147

148
149
150
151
152
153
154
155
  /*! Should the scheduler skip this task ? */
  char skip;

  /*! Does this task require the particles to be tightly in the cell ? */
  char tight;

  /*! Is this task implicit (i.e. does not do anything) ? */
  char implicit;
Pedro Gonnet's avatar
Pedro Gonnet committed
156

157
#ifdef SWIFT_DEBUG_TASKS
158
159
160
161
162
163
  /*! ID of the queue or runner owning this task */
  short int rid;

  /*! Start and end time of this task */
  ticks tic, toc;
#endif
164

165
166
167
168
#ifdef SWIFT_DEBUG_CHECKS
  int ti_run;
#endif

169
} SWIFT_STRUCT_ALIGN;
170
171

/* Function prototypes. */
172
void task_unlock(struct task *t);
173
float task_overlap(const struct task *ta, const struct task *tb);
174
int task_lock(struct task *t);
175
void task_do_rewait(struct task *t);
176
void task_print(const struct task *t);
177
178

#endif /* SWIFT_TASK_H */