/home/kcamus/qaas_runs/169-443-9681/intel/AMG/build/AMG/AMG/parcsr_mv/par_csr_matvec.c: 38 - 248
--------------------------------------------------------------------------------

38: {
39:    hypre_ParCSRCommHandle **comm_handle;
40:    hypre_ParCSRCommPkg *comm_pkg = hypre_ParCSRMatrixCommPkg(A);
41:    hypre_CSRMatrix   *diag   = hypre_ParCSRMatrixDiag(A);
42:    hypre_CSRMatrix   *offd   = hypre_ParCSRMatrixOffd(A);
43:    hypre_Vector      *x_local  = hypre_ParVectorLocalVector(x);   
44:    hypre_Vector      *b_local  = hypre_ParVectorLocalVector(b);   
45:    hypre_Vector      *y_local  = hypre_ParVectorLocalVector(y);   
46:    HYPRE_Int          num_rows = hypre_ParCSRMatrixGlobalNumRows(A);
47:    HYPRE_Int          num_cols = hypre_ParCSRMatrixGlobalNumCols(A);
48: 
49:    hypre_Vector      *x_tmp;
50:    HYPRE_Int          x_size = hypre_ParVectorGlobalSize(x);
51:    HYPRE_Int          b_size = hypre_ParVectorGlobalSize(b);
52:    HYPRE_Int          y_size = hypre_ParVectorGlobalSize(y);
53:    HYPRE_Int          num_vectors = hypre_VectorNumVectors(x_local);
54:    HYPRE_Int          num_cols_offd = hypre_CSRMatrixNumCols(offd);
55:    HYPRE_Int          ierr = 0;
56:    HYPRE_Int          num_sends, i, j, jv, index, start;
57: 
58:    HYPRE_Int          vecstride = hypre_VectorVectorStride( x_local );
59:    HYPRE_Int          idxstride = hypre_VectorIndexStride( x_local );
60: 
61:    HYPRE_Complex     *x_tmp_data, **x_buf_data;
62:    HYPRE_Complex     *x_local_data = hypre_VectorData(x_local);
[...]
74:    hypre_assert( idxstride>0 );
75: 
76:    if (num_cols != x_size)
77:       ierr = 11;
78: 
79:    if (num_rows != y_size || num_rows != b_size)
[...]
85:    hypre_assert( hypre_VectorNumVectors(b_local)==num_vectors );
86:    hypre_assert( hypre_VectorNumVectors(y_local)==num_vectors );
87: 
88:    if ( num_vectors==1 )
89:       x_tmp = hypre_SeqVectorCreate( num_cols_offd );
90:    else
91:    {
92:       hypre_assert( num_vectors>1 );
93:       x_tmp = hypre_SeqMultiVectorCreate( num_cols_offd, num_vectors );
[...]
100:    if (!comm_pkg)
101:    {
102:       hypre_MatvecCommPkgCreate(A);
103:       comm_pkg = hypre_ParCSRMatrixCommPkg(A); 
[...]
118:    if ( use_persistent_comm )
119:    {
120: #ifdef HYPRE_USING_PERSISTENT_COMM
121:       persistent_comm_handle = hypre_ParCSRCommPkgGetPersistentCommHandle(1, comm_pkg);
122: 
123:       HYPRE_Int num_recvs = hypre_ParCSRCommPkgNumRecvs(comm_pkg);
124:       hypre_assert(num_cols_offd == hypre_ParCSRCommPkgRecvVecStart(comm_pkg, num_recvs));
125: 
126:       hypre_VectorData(x_tmp) = (HYPRE_Complex *)persistent_comm_handle->recv_data;
127:       hypre_SeqVectorSetDataOwner(x_tmp, 0);
128: #endif
129:    }
130:    else
131:    {
132:       comm_handle = hypre_CTAlloc(hypre_ParCSRCommHandle*,num_vectors);
133:    }
134:    hypre_SeqVectorInitialize(x_tmp);
135:    x_tmp_data = hypre_VectorData(x_tmp);
136: 
137:    num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
138:    if (!use_persistent_comm)
139:    {
140:       x_buf_data = hypre_CTAlloc( HYPRE_Complex*, num_vectors );
141:       for ( jv=0; jv<num_vectors; ++jv )
142:          x_buf_data[jv] = hypre_CTAlloc(HYPRE_Complex, hypre_ParCSRCommPkgSendMapStart
[...]
148:       HYPRE_Int begin = hypre_ParCSRCommPkgSendMapStart(comm_pkg, 0);
149:       HYPRE_Int end   = hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends);
150: #ifdef HYPRE_USING_OPENMP
151: #pragma omp parallel for HYPRE_SMP_SCHEDULE
152: #endif
153:       for (i = begin; i < end; i++)
[...]
164:       for ( jv=0; jv<num_vectors; ++jv )
165:       {
166:          index = 0;
167:          for (i = 0; i < num_sends; i++)
168:          {
169:             start = hypre_ParCSRCommPkgSendMapStart(comm_pkg, i);
170:             for (j = start; j < hypre_ParCSRCommPkgSendMapStart(comm_pkg, i+1); j++)
171:                x_buf_data[jv][index++] 
172:                   = x_local_data[
173:                      jv*vecstride +
174:                      idxstride*hypre_ParCSRCommPkgSendMapElmt(comm_pkg,j) ];
175:          }
176:       }
177: 
178:    hypre_assert( idxstride==1 );
[...]
191:    if (use_persistent_comm)
192:    {
193: #ifdef HYPRE_USING_PERSISTENT_COMM
194:       hypre_ParCSRPersistentCommHandleStart(persistent_comm_handle);
195: #endif
196:    }
197:    else
198:    {
199:       for ( jv=0; jv<num_vectors; ++jv )
200:       {
201:          comm_handle[jv] = hypre_ParCSRCommHandleCreate
202:             ( 1, comm_pkg, x_buf_data[jv], &(x_tmp_data[jv*num_cols_offd]) );
[...]
209:    hypre_CSRMatrixMatvecOutOfPlace( alpha, diag, x_local, beta, b_local, y_local, 0);
[...]
216:       hypre_ParCSRPersistentCommHandleWait(persistent_comm_handle);
217: #endif
218:    }
219:    else
220:    {
221:       for ( jv=0; jv<num_vectors; ++jv )
222:       {
223:          hypre_ParCSRCommHandleDestroy(comm_handle[jv]);
224:          comm_handle[jv] = NULL;
225:       }
226:       hypre_TFree(comm_handle);
[...]
232:    if (num_cols_offd) hypre_CSRMatrixMatvec( alpha, offd, x_tmp, 1.0, y_local);    
233: 
234: #ifdef HYPRE_PROFILE
235:    hypre_profile_times[HYPRE_TIMER_ID_PACK_UNPACK] -= hypre_MPI_Wtime();
236: #endif
237:    hypre_SeqVectorDestroy(x_tmp);
238:    x_tmp = NULL;
239:    if (!use_persistent_comm)
240:    {
241:       for ( jv=0; jv<num_vectors; ++jv ) hypre_TFree(x_buf_data[jv]);
242:       hypre_TFree(x_buf_data);
[...]
248:    return ierr;
