task.h 2.31 KB
Newer Older
1
/*******************************************************************************
2
 * This file is part of SWIFT.
3
 * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4
 *
5
6
7
8
 * 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.
9
 *
10
11
12
13
 * 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.
14
 *
15
16
 * 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/>.
17
 *
18
 ******************************************************************************/
19
20
#ifndef SWIFT_TASK_H
#define SWIFT_TASK_H
21

22
23
24
/* Includes. */
#include "cell.h"

25
/* Some constants. */
26
27
#define task_maxwait 3
#define task_maxunlock 15
28

29
30
/* The different task types. */
enum task_types {
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  task_type_none = 0,
  task_type_sort,
  task_type_self,
  task_type_pair,
  task_type_sub,
  task_type_ghost,
  task_type_kick1,
  task_type_kick2,
  task_type_send,
  task_type_recv,
  task_type_link,
  task_type_grav_pp,
  task_type_grav_mm,
  task_type_grav_up,
  task_type_grav_down,
  task_type_count
};

49
extern const char *taskID_names[];
50

51
52
/* The different task sub-types. */
enum task_subtypes {
53
54
55
56
57
58
59
  task_subtype_none = 0,
  task_subtype_density,
  task_subtype_force,
  task_subtype_grav,
  task_subtype_count
};

60
extern const char *taskID_names[];
61

62
63
64
/* Data of a task. */
struct task {

65
66
67
68
69
70
71
72
  enum task_types type;
  enum task_subtypes subtype;
  char skip, tight, implicit;
  int flags, wait, rank, weight;

  lock_type lock;

  struct cell *ci, *cj;
73

74
75
76
#ifdef WITH_MPI
  MPI_Request req;
#endif
77

78
79
80
81
82
83
  int rid;
  ticks tic, toc;

  int nr_unlock_tasks;
  struct task *unlock_tasks[task_maxunlock + 1];
};
84
85

/* Function prototypes. */
86
87
88
89
90
91
92
93
void task_rmunlock(struct task *ta, struct task *tb);
void task_rmunlock_blind(struct task *ta, struct task *tb);
void task_cleanunlock(struct task *t, int type);
void task_addunlock(struct task *ta, struct task *tb);
void task_unlock(struct task *t);
int task_lock(struct task *t);

#endif /* SWIFT_TASK_H */