1 #include "BSprivate.h"
2
3 /*@ BSsetup_block - Change the setup for triangular matrix multiplication
4 to allow for multiple vectors
5
6 Input Parameters:
7 . A - a sparse matrix
8 . comm - the communication structure
9 . block_size - the number of vectors
10 . procinfo - the usual processor stuff
11
12 Output Parameters:
13 . comm - the communication structure modified for a block of vectors
14
15 Returns:
16 void
17
18 @*/
BSsetup_block(BSpar_mat * A,BScomm * comm,int block_size,BSprocinfo * procinfo)19 void BSsetup_block(BSpar_mat *A, BScomm *comm, int block_size,
20 BSprocinfo *procinfo)
21 {
22 BMphase *to_phase, *from_phase;
23 BMmsg *msg;
24 int i;
25 BSnumbering *color2clique;
26 int msg_len;
27 FLOAT *msg_buf;
28
29 if((!A->icc_storage)||(procinfo->single)) {
30 /* Not set up for blocks with ILU so they are done individually */
31 return;
32 }
33 if(comm->num_rhs==block_size) {
34 /* already to go */
35 return;
36 }
37
38 /* set num_rhs in BScomm structure to be block_size */
39 comm->num_rhs = block_size;
40
41 color2clique = A->color2clique;
42
43 /* now do this phase by phase */
44 for (i=0;i<color2clique->length-1;i++) {
45 /* first send my messages */
46 to_phase = BMget_phase(comm->to_msg,i); CHKERR(0);
47 msg = NULL;
48 while ((msg = BMnext_msg(to_phase,msg)) != NULL) {
49 CHKERR(0);
50 msg_buf = (FLOAT *) BMget_msg_ptr(msg); CHKERR(0);
51 msg_len = BMget_msg_size(msg); CHKERR(0);
52 if (msg_buf != NULL) {
53 MY_FREE(msg_buf);
54 }
55 BMset_msg_ptr(msg,NULL); CHKERR(0);
56 BMset_msg_size(msg,msg_len*block_size); CHKERR(0);
57 }
58 CHKERR(0);
59
60 /* receive my messages and do non-local work */
61 from_phase = BMget_phase(comm->from_msg,i); CHKERR(0);
62 msg = NULL;
63 while ((msg = BMnext_msg(from_phase,msg)) != NULL) {
64 CHKERR(0);
65 msg_buf = (FLOAT *) BMget_msg_ptr(msg); CHKERR(0);
66 msg_len = BMget_msg_size(msg); CHKERR(0);
67 if (msg_buf != NULL) {
68 MY_FREE(msg_buf);
69 }
70 BMset_msg_ptr(msg,NULL); CHKERR(0);
71 BMset_msg_size(msg,msg_len*block_size); CHKERR(0);
72 }
73 CHKERR(0);
74 }
75
76 BMalloc_msg(comm->to_msg); CHKERR(0);
77 BMalloc_msg(comm->from_msg); CHKERR(0);
78 }
79