1 #include "BSprivate.h"
2 
3 /*@ BSbjacobi - Apply the block Jacobi preconditioner
4 
5     Input Parameters:
6 .   A - The sparse matrix
7 .   x - a vector
8 .   comm - the compiled communication pattern
9 .   procinfo - the usual processor info
10 
11     Input Parameters:
12 .   x - the preconditioner applied to the vector
13 
14     Returns:
15     void
16 
17  @*/
BSbjacobi(BSpar_mat * A,FLOAT * x,BScomm * comm,BSprocinfo * procinfo)18 void BSbjacobi(BSpar_mat *A, FLOAT *x, BScomm *comm, BSprocinfo *procinfo)
19 {
20 	BMphase *to_phase, *from_phase;
21 	BMmsg *msg;
22 	int	i, j, k;
23 	int	cl_ind, in_ind;
24 	int	count, size, ind, num_cols;
25 	int *row;
26 	FLOAT *nz;
27 	BScl_2_inode *clique2inode;
28 	BSnumbering *color2clique;
29 	BSinode *inodes;
30 	int	*data_ptr, msg_len;
31 	FLOAT *msg_buf, *matrix;
32 	FLOAT *work, *nzptr;
33 	char UP = 'U';
34 	char TR = 'T';
35 	char NTR = 'N';
36 	char ND = 'N';
37 	int	ione = 1;
38 	FLOAT one = 1.0;
39 	FLOAT zero = 0.0;
40 
41 	color2clique = A->color2clique;
42 	clique2inode = A->clique2inode;
43 	inodes = A->inodes->list;
44 
45 	/* now do this phase by phase */
46 	for (i=0;i<color2clique->length-1;i++) {
47 		/* find my portion of the solution using the cliques on the diagonal */
48 		for (cl_ind=color2clique->numbers[i];
49 			cl_ind<color2clique->numbers[i+1];cl_ind++) {
50 			if (procinfo->my_id == clique2inode->proc[cl_ind]) {
51 				/* first, multiply the clique */
52 				/* the clique is stored, inverted, in the upper triangle */
53 				size = clique2inode->d_mats[cl_ind].size;
54 				ind = clique2inode->d_mats[cl_ind].local_ind;
55 				matrix = clique2inode->d_mats[cl_ind].matrix;
56 				DTRMV(&UP,&TR,&ND,&size,matrix,&size,&(x[ind]),&ione);
57 				DTRMV(&UP,&NTR,&ND,&size,matrix,&size,&(x[ind]),&ione);
58 				MLOG_flop((2*(size*(size+1))));
59 			}
60 		}
61 	}
62 }
63