1 |
|
2 |
/***************************************************************************** |
3 |
* |
4 |
* Copyright (c) 2003-2013 by University of Queensland |
5 |
* http://www.uq.edu.au |
6 |
* |
7 |
* Primary Business: Queensland, Australia |
8 |
* Licensed under the Open Software License version 3.0 |
9 |
* http://www.opensource.org/licenses/osl-3.0.php |
10 |
* |
11 |
* Development until 2012 by Earth Systems Science Computational Center (ESSCC) |
12 |
* Development since 2012 by School of Earth Sciences |
13 |
* |
14 |
*****************************************************************************/ |
15 |
|
16 |
|
17 |
/************************************************************************************/ |
18 |
|
19 |
/* Paso: coupler */ |
20 |
|
21 |
/************************************************************************************/ |
22 |
|
23 |
/* Author: Lutz Gross, l.gross@uq.edu.au */ |
24 |
|
25 |
/************************************************************************************/ |
26 |
|
27 |
#ifndef INC_PASO_COUPLER |
28 |
#define INC_PASO_COUPLER |
29 |
|
30 |
#include "SharedComponents.h" |
31 |
/************************************************************************************/ |
32 |
|
33 |
typedef struct Paso_Connector { |
34 |
|
35 |
Paso_SharedComponents* send; |
36 |
Paso_SharedComponents* recv; |
37 |
dim_t reference_counter; |
38 |
Esys_MPIInfo *mpi_info; |
39 |
|
40 |
} Paso_Connector; |
41 |
typedef struct Paso_Coupler { |
42 |
|
43 |
dim_t block_size; |
44 |
|
45 |
Paso_Connector* connector; |
46 |
|
47 |
bool_t in_use; |
48 |
double *data; /* unmanaged pointer to data to be sent */ |
49 |
double *send_buffer; |
50 |
double *recv_buffer; |
51 |
#ifdef ESYS_MPI |
52 |
MPI_Request* mpi_requests; |
53 |
MPI_Status* mpi_stati; |
54 |
#else |
55 |
void* mpi_requests; |
56 |
void* mpi_stati; |
57 |
#endif |
58 |
|
59 |
dim_t reference_counter; |
60 |
Esys_MPIInfo *mpi_info; |
61 |
|
62 |
} Paso_Coupler; |
63 |
|
64 |
|
65 |
|
66 |
PASO_DLL_API |
67 |
Paso_Connector* Paso_Connector_alloc(Paso_SharedComponents * send, Paso_SharedComponents* recv); |
68 |
|
69 |
PASO_DLL_API |
70 |
Paso_Connector* Paso_Connector_getReference(Paso_Connector*); |
71 |
|
72 |
PASO_DLL_API |
73 |
Paso_Connector* Paso_Connector_unroll(Paso_Connector* in, index_t block_size); |
74 |
|
75 |
PASO_DLL_API |
76 |
Paso_Connector* Paso_Connector_copy(Paso_Connector* in); |
77 |
|
78 |
PASO_DLL_API |
79 |
void Paso_Connector_free(Paso_Connector*); |
80 |
|
81 |
|
82 |
PASO_DLL_API |
83 |
Paso_Coupler* Paso_Coupler_alloc(Paso_Connector*, dim_t blockSize); |
84 |
|
85 |
PASO_DLL_API |
86 |
Paso_Coupler* Paso_Coupler_getReference(Paso_Coupler*); |
87 |
|
88 |
PASO_DLL_API |
89 |
void Paso_Coupler_startCollect(Paso_Coupler* self,const double* in); |
90 |
|
91 |
PASO_DLL_API |
92 |
double* Paso_Coupler_finishCollect(Paso_Coupler* self); |
93 |
|
94 |
PASO_DLL_API |
95 |
void Paso_Coupler_free(Paso_Coupler* in); |
96 |
|
97 |
#define Paso_Coupler_borrowLocalData(_in_) (_in_)->data |
98 |
#define Paso_Coupler_borrowRemoteData(_in_) (_in_)->recv_buffer |
99 |
#define Paso_Coupler_getNumSharedComponents(_in_) ((_in_)->connector->send->numSharedComponents) |
100 |
#define Paso_Coupler_getNumOverlapComponents(_in_) ((_in_)->connector->recv->numSharedComponents) |
101 |
#define Paso_Coupler_getNumSharedValues(_in_) ( Paso_Coupler_getNumSharedComponents(_in_) * (_in_)->block_size ) |
102 |
#define Paso_Coupler_getNumOverlapValues(_in_) ( Paso_Coupler_getNumOverlapComponents(_in_) * (_in_)->block_size ) |
103 |
#define Paso_Coupler_getLocalLength(_in_) ( (_in_)->connector->send->local_length ) |
104 |
|
105 |
PASO_DLL_API |
106 |
void Paso_Coupler_copyAll(const Paso_Coupler* src, Paso_Coupler* target); |
107 |
|
108 |
|
109 |
PASO_DLL_API |
110 |
void Paso_Coupler_fillOverlap(const dim_t n, double* x, Paso_Coupler *coupler); |
111 |
|
112 |
PASO_DLL_API |
113 |
void Paso_Coupler_max(const dim_t n, double* x, Paso_Coupler *coupler); |
114 |
|
115 |
#endif |
116 |
|