ergo
barrier.h
Go to the documentation of this file.
1 /* Ergo, version 3.4, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2014 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Primary academic reference:
19  * Kohn−Sham Density Functional Theory Electronic Structure Calculations
20  * with Linearly Scaling Computational Time and Memory Usage,
21  * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek,
22  * J. Chem. Theory Comput. 7, 340 (2011),
23  * <http://dx.doi.org/10.1021/ct100611z>
24  *
25  * For further information about Ergo, see <http://www.ergoscf.org>.
26  */
27 
28 #if !defined(_ERGO_BARRIER_H_)
29 #define _ERGO_BARRIER_H_
30 
34 #if !defined(HAS_PTHREAD_BARRIER)
35 
36 #ifdef __cplusplus
37 #define EXTERN_C extern "C"
38 #else
39 #define EXTERN_C extern
40 #endif
41 
42 #if !defined(PTHREAD_BARRIER_SERIAL_THREAD)
43 #define PTHREAD_BARRIER_SERIAL_THREAD -1
44 #endif
45 
46 typedef struct ergo_barrier {
47  pthread_mutex_t barrierMutex;
48  pthread_cond_t conditionVar;
49  int initCount;
50  int currCount;
51  int cycle;
53 
54 EXTERN_C int ergo_barrier_init(ergo_barrier_t *__restrict barrier,
55  const void * attr_ignored,
56  unsigned int count);
57 
60 
61 #else /* HAS_PTHREAD_BARRIER */
62 #define ergo_barrier_t pthread_barrier_t
63 #define ergo_barrier_init pthread_barrier_init
64 #define ergo_barrier_destroy pthread_barrier_destroy
65 #define ergo_barrier_wait pthread_barrier_wait
66 #endif /* HAS_PTHREAD_BARRIER */
67 
68 #endif /* _ERGO_BARRIER_H_ */
EXTERN_C int ergo_barrier_init(ergo_barrier_t *__restrict barrier, const void *attr_ignored, unsigned int count)
Definition: barrier.c:42
int cycle
Definition: barrier.h:51
int initCount
Definition: barrier.h:49
EXTERN_C int ergo_barrier_wait(ergo_barrier_t *__barrier)
Definition: barrier.c:66
pthread_mutex_t barrierMutex
Definition: barrier.h:47
struct ergo_barrier ergo_barrier_t
EXTERN_C int ergo_barrier_destroy(ergo_barrier_t *__barrier)
Definition: barrier.c:56
pthread_cond_t conditionVar
Definition: barrier.h:48
Definition: barrier.h:46
#define EXTERN_C
Definition: barrier.h:39
int currCount
Definition: barrier.h:50