task.h 2.97 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
/* Includes. */
#include "cell.h"
28
#include "cycle.h"
29

30
/* Some constants. */
31
#define task_maxwait 3
32
#define task_maxunlock 15
33

34
35
/* The different task types. */
enum task_types {
36
37
38
39
  task_type_none = 0,
  task_type_sort,
  task_type_self,
  task_type_pair,
40
41
  task_type_sub_self,
  task_type_sub_pair,
Matthieu Schaller's avatar
Matthieu Schaller committed
42
  task_type_init,
43
  task_type_ghost,
Matthieu Schaller's avatar
Matthieu Schaller committed
44
45
  task_type_drift,
  task_type_kick,
46
  task_type_kick_fixdt,
47
48
  task_type_send,
  task_type_recv,
49
50
  task_type_grav_gather_m,
  task_type_grav_fft,
51
  task_type_grav_mm,
52
  task_type_grav_up,
Tom Theuns's avatar
Tom Theuns committed
53
  task_type_grav_external,
54
55
  task_type_part_sort,
  task_type_gpart_sort,
56
57
  task_type_split_cell,
  task_type_rewait,
58
59
60
  task_type_count
};

61
extern const char *taskID_names[];
62

63
64
/* The different task sub-types. */
enum task_subtypes {
65
66
67
68
  task_subtype_none = 0,
  task_subtype_density,
  task_subtype_force,
  task_subtype_grav,
69
  task_subtype_tend,
70
71
72
  task_subtype_count
};

73
74
75
76
77
78
79
80
81
82
/* The kind of action the task perform */
enum task_actions {
  task_action_none,
  task_action_part,
  task_action_gpart,
  task_action_all,
  task_action_multipole,
  task_action_count
};

83
extern const char *subtaskID_names[];
84

85
86
87
/* Data of a task. */
struct task {

88
89
90
91
92
93
  enum task_types type;
  enum task_subtypes subtype;
  char skip, tight, implicit;
  int flags, wait, rank, weight;

  struct cell *ci, *cj;
94

95
96
  void *buff;

97
98
99
#ifdef WITH_MPI
  MPI_Request req;
#endif
100

101
  int rid, last_rid;
102
103
104
  ticks tic, toc;

  int nr_unlock_tasks;
105
  struct task **unlock_tasks;
106
};
107
108

/* Function prototypes. */
109
void task_unlock(struct task *t);
110
float task_overlap(const struct task *ta, const struct task *tb);
111
int task_lock(struct task *t);
112
void task_print_mask(unsigned int mask);
113
void task_print_submask(unsigned int submask);
114
void task_do_rewait(struct task *t);
115
enum task_actions task_acts_on(const struct task *t);
116
117

#endif /* SWIFT_TASK_H */