Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfRunner.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of mdcore.
3 * Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4 * Coypright (c) 2017 Andy Somogyi (somogyie at indiana dot edu)
5 * Copyright (c) 2022-2024 T.J. Sego
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ******************************************************************************/
21
26
27#ifndef _MDCORE_INCLUDE_TFRUNNER_H_
28#define _MDCORE_INCLUDE_TFRUNNER_H_
29
30#include "tf_platform.h"
31#include "tf_cycle.h"
32
33
34/* some constants */
35/* Minimum number of nanoseconds to sleep if no task available. */
36#define runner_minsleep 1000
37
39#define runner_bitesize 3
40
42#define runner_verlet_bitesize 200
43
45#define runner_dispatch_stop 0xffffffff
46#define runner_dispatch_lookahead 20
47
48
50enum {
51 runner_timer_queue = 0,
52 runner_timer_pair,
53 runner_timer_self,
54 runner_timer_sort,
55 runner_timer_count
56};
57
58
59namespace TissueForge {
60
61
62 CAPI_DATA(ticks) runner_timers[];
63
64};
65
66#ifdef TIMER
67#define TIMER_TIC_ND tic = getticks();
68#define TIMER_TIC2_ND ticks tic2 = getticks();
69#define TIMER_TIC ticks tic = getticks();
70#define TIMER_TOC(t) timers_toc(t, tic)
71#define TIMER_TIC2 ticks tic2 = getticks();
72#define TIMER_TOC2(t) timers_toc(t, tic2)
73#ifndef INLINE
74# if __GNUC__ && !__GNUC_STDC_INLINE__
75# define INLINE extern inline
76# else
77# define INLINE inline
78# endif
79#endif
80INLINE static ticks timers_toc(int t, ticks tic) {
81 ticks d = (getticks() - tic);
82 __sync_add_and_fetch(&TissueForge::runner_timers[t], d);
83 return d;
84}
85#else
86#define TIMER_TIC_ND
87#define TIMER_TIC
88#define TIMER_TOC(t)
89#define TIMER_TIC2
90#define TIMER_TOC2(t)
91#endif
92
93MDCORE_BEGIN_DECLS
94
95
96namespace TissueForge {
97
98
99 /* The fifo-queue for dispatching. */
100 typedef struct runner_fifo {
101
102 /* Access mutex and condition signal for blocking use. */
103 pthread_mutex_t mutex;
104 pthread_cond_t cond;
105
106 /* Counters. */
107 int first, last, size, count;
108
109 /* The FIFO data. */
110 int *data;
111
112 } runner_fifo;
113
114 /* the runner structure */
115 typedef struct runner {
116
117 /* the engine with which i am associated */
118 struct engine *e;
119
120 /* this runner's id */
121 int id;
122
123 /* my thread */
124 pthread_t thread;
125
127 int err;
128
130 FPTYPE epot;
131
132 } runner;
133
134 /* associated functions */
135
143 HRESULT runner_init(struct runner *r, struct engine *e, int id);
144
147
157 void runner_sort_ascending(unsigned int *parts, int N);
158
168 void runner_sort_descending(unsigned int *parts, int N);
169
179 HRESULT runner_verlet_eval(struct runner *r, struct space_cell *c, FPTYPE *f_out);
180
190 HRESULT runner_verlet_fill(struct runner *r, struct space_cell *cell_i, struct space_cell *cell_j, FPTYPE *pshift);
191
208 HRESULT runner_dosort(struct runner *r, struct space_cell *c, int flags);
209
224 HRESULT runner_dopair(struct runner *r, struct space_cell *cell_i, struct space_cell *cell_j, int sid);
225
240 HRESULT runner_dopair_fluxonly(struct runner *r, struct space_cell *cell_i, struct space_cell *cell_j, int sid);
241
248 HRESULT runner_doself(struct runner *r, struct space_cell *cell_i);
249
257
258};
259
260MDCORE_END_DECLS
261
262#endif // _MDCORE_INCLUDE_TFRUNNER_H_
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
void runner_sort_ascending(unsigned int *parts, int N)
Sort the particles in ascending order using QuickSort.
HRESULT runner_run(struct runner *r)
HRESULT runner_dopair_fluxonly(struct runner *r, struct space_cell *cell_i, struct space_cell *cell_j, int sid)
Compute the pairwise fluxes for the given pair.
HRESULT runner_dopair(struct runner *r, struct space_cell *cell_i, struct space_cell *cell_j, int sid)
Compute the pairwise interactions for the given pair.
HRESULT runner_dosort(struct runner *r, struct space_cell *c, int flags)
Fill in the pairwise Verlet list entries for the given cell pair if needed and compute the interactio...
void runner_sort_descending(unsigned int *parts, int N)
Sort the particles in descending order using QuickSort.
HRESULT runner_verlet_eval(struct runner *r, struct space_cell *c, FPTYPE *f_out)
Compute the interactions between the particles in the given space_cell using the verlet list.
HRESULT runner_verlet_fill(struct runner *r, struct space_cell *cell_i, struct space_cell *cell_j, FPTYPE *pshift)
Fill in the Verlet list entries for the given space_cell pair.
HRESULT runner_doself(struct runner *r, struct space_cell *cell_i)
Compute the self-interactions for the given cell.
HRESULT runner_init(struct runner *r, struct engine *e, int id)
Initialize the runner associated to the given engine.
HRESULT runner_doself_fluxonly(struct runner *r, struct space_cell *cell_i)
Compute the self-fluxes for the given cell.
Definition tfEngine.h:164
Definition tfRunner.h:100
Definition tfRunner.h:115
int err
Definition tfRunner.h:127
FPTYPE epot
Definition tfRunner.h:130
the space_cell structure
Definition tfSpace_cell.h:103
int32_t HRESULT
Definition tf_port.h:255