/[escript]/trunk/paso/src/SystemMatrix_copyColCoupleBlock.cpp
ViewVC logotype

Contents of /trunk/paso/src/SystemMatrix_copyColCoupleBlock.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4829 - (show annotations)
Thu Apr 3 04:02:53 2014 UTC (5 years, 5 months ago) by caltinay
File size: 4838 byte(s)
checkpointing some SparseMatrix cleanup.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *****************************************************************************/
13
14
15 /************************************************************************************
16
17 Paso: SystemMatrix: copies the col_coupleBlock into
18 row_coupleBlock.
19
20 WARNING: function uses mpi_requests of the coupler attached to A.
21
22 No reordering on the columns received is performed.
23 In practice this means that components in
24 A->row_coupleBlock->pattern->index
25 and
26 A->row_coupler->connector->recv->shared
27 are ordered by increasing value.
28
29 Notice: that send and receive A->row_coupler->connectors
30 are swapping roles.
31
32 ************************************************************************************/
33
34 /* Author: Lutz Gross, l.gross@uq.edu.au */
35
36 /************************************************************************************/
37
38 #include "SystemMatrix.h"
39 #include "esysUtils/error.h"
40
41 /************************************************************************************/
42
43 void Paso_SystemMatrix_copyColCoupleBlock(Paso_SystemMatrix *A)
44 {
45 dim_t p;
46 index_t z0, iPtr, rPtr;
47 const dim_t block_size=A->block_size;
48 const size_t block_size_size=block_size*sizeof(double);
49 double * send_buffer = NULL;
50
51 if ( A->mpi_info->size > 1 ) {
52 if ( A->row_coupleBlock == NULL ) {
53 Esys_setError(VALUE_ERROR, "SystemMatrix_copyColCoupleBlock: creation of row_coupleBlock pattern not supported yet.");
54 return;
55 }
56 if ( A->row_coupler->in_use ) {
57 Esys_setError(SYSTEM_ERROR,"SystemMatrix_copyColCoupleBlock: Coupler in use.");
58 return;
59 }
60
61 /* start receiving */
62 for (p=0; p<A->row_coupler->connector->recv->numNeighbors; p++) {
63 #ifdef ESYS_MPI
64 const index_t irow1= A->row_coupler->connector->recv->offsetInShared[p];
65 const index_t irow2= A->row_coupler->connector->recv->offsetInShared[p+1];
66 const index_t a = A->row_coupleBlock->pattern->ptr[irow1];
67 const index_t b = A->row_coupleBlock->pattern->ptr[irow2];
68
69 MPI_Irecv(&(A->row_coupleBlock->val[a * block_size]), (b-a) * block_size, MPI_DOUBLE,
70 A->row_coupler->connector->recv->neighbor[p],
71 A->mpi_info->msg_tag_counter+A->row_coupler->connector->recv->neighbor[p],
72 A->mpi_info->comm,
73 &(A->row_coupler->mpi_requests[p]) );
74
75 #endif
76 }
77 /* start sending */
78 z0=0;
79 send_buffer = new double[A->col_coupleBlock->len];
80
81 for (p=0; p<A->row_coupler->connector->send->numNeighbors; p++) {
82 /* j_min, j_max defines the range of columns to be sent to processor p*/
83 const index_t j_min = A->col_coupler->connector->recv->offsetInShared[p];
84 const index_t j_max = A->col_coupler->connector->recv->offsetInShared[p+1];
85 index_t z = z0;
86
87 /* run over the rows to be connected to processor p */
88 for (rPtr= A->row_coupler->connector->send->offsetInShared[p]; rPtr< A->row_coupler->connector->send->offsetInShared[p+1]; ++rPtr) {
89 const index_t row=A->row_coupler->connector->send->shared[rPtr];
90
91 /* collect the entries in the col. couple block referring to columns on processor p */
92 for (iPtr =A->col_coupleBlock->pattern->ptr[row]; iPtr<A->col_coupleBlock->pattern->ptr[row+1]; ++iPtr) {
93 register index_t j =A->col_coupleBlock->pattern->index[iPtr];
94 if ( (j_min <= j) && (j < j_max) ) {
95 memcpy(&(send_buffer[z]),&(A->col_coupleBlock->val[ block_size * iPtr]), block_size_size);
96 z+=block_size;
97 }
98 }
99
100 }
101 #ifdef ESYS_MPI
102 MPI_Issend(&(send_buffer[z0]),z-z0, MPI_DOUBLE,
103 A->row_coupler->connector->send->neighbor[p],
104 A->mpi_info->msg_tag_counter+A->mpi_info->rank,
105 A->mpi_info->comm,
106 &(A->row_coupler->mpi_requests[p+A->row_coupler->connector->recv->numNeighbors]));
107
108 #endif
109 z0 = z;
110 }
111
112
113 /* wait until everything is done */
114 #ifdef ESYS_MPI
115 MPI_Waitall(A->row_coupler->connector->send->numNeighbors+A->row_coupler->connector->recv->numNeighbors,
116 A->row_coupler->mpi_requests,
117 A->row_coupler->mpi_stati);
118 #endif
119 ESYS_MPI_INC_COUNTER(*(A->mpi_info), A->mpi_info->size);
120 delete[] send_buffer;
121 }
122 return;
123 }

Properties

Name Value
svn:mergeinfo /branches/amg_from_3530/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3531-3826 /branches/lapack2681/paso/src/SystemMatrix_copyColCoupleBlock.cpp:2682-2741 /branches/pasowrap/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3661-3674 /branches/py3_attempt2/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3871-3891 /branches/restext/paso/src/SystemMatrix_copyColCoupleBlock.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3669-3791 /branches/stage3.0/paso/src/SystemMatrix_copyColCoupleBlock.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3517-3974 /release/3.0/paso/src/SystemMatrix_copyColCoupleBlock.cpp:2591-2601 /trunk/paso/src/SystemMatrix_copyColCoupleBlock.cpp:4257-4344 /trunk/ripley/test/python/paso/src/SystemMatrix_copyColCoupleBlock.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26