ESYS13  Revision_
Coupler.h
Go to the documentation of this file.
00001 
00002 /*******************************************************
00003 *
00004 * Copyright (c) 2003-2012 by University of Queensland
00005 * Earth Systems Science Computational Center (ESSCC)
00006 * http://www.uq.edu.au/esscc
00007 *
00008 * Primary Business: Queensland, Australia
00009 * Licensed under the Open Software License version 3.0
00010 * http://www.opensource.org/licenses/osl-3.0.php
00011 *
00012 *******************************************************/
00013 
00014 
00015 /**************************************************************/
00016 
00017 /*   Paso: coupler                                            */ 
00018 
00019 /**************************************************************/
00020 
00021 /*   Author: Lutz Gross, l.gross@uq.edu.au */
00022 
00023 /**************************************************************/
00024 
00025 #ifndef INC_PASO_COUPLER
00026 #define INC_PASO_COUPLER
00027 
00028 #include "SharedComponents.h"
00029 /**************************************************************/
00030 
00031 typedef struct Paso_Connector {
00032 
00033   Paso_SharedComponents* send;
00034   Paso_SharedComponents* recv;
00035   dim_t reference_counter;
00036   Esys_MPIInfo *mpi_info;
00037 
00038 } Paso_Connector;
00039 typedef struct Paso_Coupler {
00040 
00041   dim_t block_size;
00042 
00043   Paso_Connector* connector;
00044 
00045   bool_t in_use;
00046   double *data; /* unmanaged pointer to data to be sent */
00047   double *send_buffer;
00048   double *recv_buffer;
00049   #ifdef ESYS_MPI
00050     MPI_Request* mpi_requests;
00051     MPI_Status* mpi_stati;
00052  #else
00053     void* mpi_requests;
00054     void* mpi_stati;
00055  #endif
00056   
00057   dim_t reference_counter;
00058   Esys_MPIInfo *mpi_info;
00059 
00060 } Paso_Coupler;
00061 
00062 
00063 
00064 PASO_DLL_API
00065 Paso_Connector* Paso_Connector_alloc(Paso_SharedComponents * send, Paso_SharedComponents* recv);
00066 
00067 PASO_DLL_API
00068 Paso_Connector* Paso_Connector_getReference(Paso_Connector*);
00069 
00070 PASO_DLL_API
00071 Paso_Connector* Paso_Connector_unroll(Paso_Connector* in, index_t block_size);
00072 
00073 PASO_DLL_API
00074 Paso_Connector* Paso_Connector_copy(Paso_Connector* in);
00075 
00076 PASO_DLL_API
00077 void Paso_Connector_free(Paso_Connector*);
00078 
00079 
00080 PASO_DLL_API
00081 Paso_Coupler* Paso_Coupler_alloc(Paso_Connector*, dim_t blockSize);
00082 
00083 PASO_DLL_API
00084 Paso_Coupler* Paso_Coupler_getReference(Paso_Coupler*);
00085 
00086 PASO_DLL_API
00087 void Paso_Coupler_startCollect(Paso_Coupler* self,const double* in);
00088 
00089 PASO_DLL_API
00090 double* Paso_Coupler_finishCollect(Paso_Coupler* self);
00091 
00092 PASO_DLL_API
00093 void Paso_Coupler_free(Paso_Coupler* in);
00094 
00095 #define Paso_Coupler_borrowLocalData(_in_) (_in_)->data
00096 #define Paso_Coupler_borrowRemoteData(_in_) (_in_)->recv_buffer
00097 #define Paso_Coupler_getNumSharedComponents(_in_)  ((_in_)->connector->send->numSharedComponents)
00098 #define Paso_Coupler_getNumOverlapComponents(_in_) ((_in_)->connector->recv->numSharedComponents)
00099 #define Paso_Coupler_getNumSharedValues(_in_) ( Paso_Coupler_getNumSharedComponents(_in_) * (_in_)->block_size )
00100 #define Paso_Coupler_getNumOverlapValues(_in_) ( Paso_Coupler_getNumOverlapComponents(_in_) * (_in_)->block_size )
00101 #define Paso_Coupler_getLocalLength(_in_) ( (_in_)->connector->send->local_length )
00102 
00103 PASO_DLL_API
00104 void Paso_Coupler_copyAll(const Paso_Coupler* src, Paso_Coupler* target);
00105 
00106 
00107 PASO_DLL_API
00108 void Paso_Coupler_fillOverlap(const dim_t n, double* x, Paso_Coupler *coupler);
00109 
00110 PASO_DLL_API
00111 void Paso_Coupler_max(const dim_t n, double* x, Paso_Coupler *coupler);
00112 
00113 #endif
00114