1 /*+ BSprivate.h - Include file for the sparse solver package. 2 This file is for use only inside the BlockSolve package. 3 +*/ 4 5 #ifndef __BSprivateh 6 #define __BSprivateh 7 8 /* include the "system" dependent routines */ 9 #include "BSdepend.h" 10 11 /* include the "public" include file as well */ 12 #include "BSsparse.h" 13 14 /* include the special message passing stuff that I wrote */ 15 #include "BMmsg.h" 16 17 /* include some logging stuff that I wrote */ 18 #include "BSlog.h" 19 20 /* ****************************************************************** */ 21 /* Definitions of misc. constants */ 22 /* ****************************************************************** */ 23 24 #define MAT_NAME_MSG 10000 25 #define RHS_NAME_MSG 10001 26 #define OFFSETD_MSG 10002 27 #define OFFSETU_MSG 10003 28 #define BB_SQ_MSG 10004 29 #define BB_SA_MSG 10005 30 #define COLOR_MSG 10006 31 #define SETUP_FORWARD_MSG 10007 32 #define SETUP_ORIGINAL_MSG 10008 33 #define SETUP_FACTOR_MSG 10009 34 #define DEGREE_MSG 10010 35 /* these next three messages need a lot of room */ 36 /* this next message number is actually a range of messages */ 37 /* needed by the BMcomp_msg routines. The total number */ 38 /* of messages used is MAX_NUM_MSGS*nprocs */ 39 /* MAX_NUM_MSGS should be greater than the number of messages */ 40 /* that a processor sends in one compiled message execution */ 41 /* For example, one compiled message execution is typically */ 42 /* an entire parallel forward matrix solution. So the number */ 43 /* of messages is less than or equal to the number of processors */ 44 /* that a single processor is connected to in the graph of the */ 45 /* matrix times the number of colors used to color the graph */ 46 /* we think the current setting of 10,000 is ample, but feel free */ 47 /* to change it (recompile EVERYTHING if you do) */ 48 #define COMP_MSG_BASE 10020 49 #define MAX_NUM_MSGS 10000 50 51 /* used in coloring */ 52 #define NO_COLOR -2 53 54 /* used in cg and symmlq */ 55 #define CG_MATVECR 1 56 #define CG_MATVECZ 2 57 #define CG_MSOLVE 3 58 #define CG_ERROR -1 59 #define SYMM_MATVECXR 1 60 #define SYMM_MATVECVZ 2 61 #define SYMM_MSOLVE1 3 62 #define SYMM_MSOLVE2 4 63 #define SYMM_MSOLVEB 5 64 #define SYMM_DONE 6 65 #define SYMM_ERROR -1 66 67 #define TRUE 1 68 #define FALSE 0 69 70 /* ****************************************************************** */ 71 /* End of section */ 72 /* ****************************************************************** */ 73 74 75 /* ****************************************************************** */ 76 /* Definitions of data structures */ 77 /* ****************************************************************** */ 78 79 /* used to store new global address for each row */ 80 typedef struct __BSkey_arr { 81 int length; 82 int **array; 83 } BSkey_arr; 84 85 /* Bulletin Board */ 86 typedef struct __BSbb { 87 int length; /* the number of elements */ 88 BSmapping *map; /* the mapping to use */ 89 int *info; /* the information to store in the BB */ 90 } BSbb; 91 92 /* Bulletin Board for floating point */ 93 typedef struct __BSbb_d { 94 int length; /* the number of elements */ 95 BSmapping *map; /* the mapping to use */ 96 FLOAT *info; /* the information to store in the BB */ 97 } BSbb_d; 98 99 /* ****************************************************************** */ 100 /* End of section */ 101 /* ****************************************************************** */ 102 103 104 /* ****************************************************************** */ 105 /* Definitions of misc macros */ 106 /* ****************************************************************** */ 107 108 #define MY_SETERR(a) {SETERR(a); return;} 109 #define MY_SETERRN(a) {SETERR(a); return(0);} 110 #define MY_SETERRC(a,s) {SETERRC(a,s); return;} 111 #define MY_SETERRCN(a,s) {SETERRC(a,s); return(0);} 112 #define MY_MALLOC(a,b,c,d) { \ 113 if (c == 0) { \ 114 a = NULL; \ 115 } else { \ 116 if ((a = b MALLOC(c)) == NULL) {MY_SETERRC(MEM_ERROR,"Out of Memory\n");} \ 117 } \ 118 } 119 #define MY_MALLOCN(a,b,c,d) { \ 120 if (c == 0) { \ 121 a = NULL; \ 122 } else { \ 123 if ((a = b MALLOC(c)) == NULL) {MY_SETERRCN(MEM_ERROR,"Out of Memory\n");} \ 124 } \ 125 } 126 #define MY_FREE(a) \ 127 { \ 128 if (a != NULL) FREE(a); \ 129 } 130 #define MY_FREEN(a) \ 131 { \ 132 if (a != NULL) FREE(a); \ 133 } 134 135 /* ****************************************************************** */ 136 /* End of section */ 137 /* ****************************************************************** */ 138 139 /* ****************************************************************** */ 140 /* Declarations of my functions */ 141 /* ****************************************************************** */ 142 143 /* BMmsg functions */ 144 extern BMcomp_msg *BMcomp_init(int); 145 extern void BMfree_comp_msg(BMcomp_msg *); 146 extern BMphase *BMget_phase(BMcomp_msg *,int); 147 extern void BMadd_msg(BMcomp_msg *,BMmsg *,BSprocinfo *); 148 extern BMmsg *BMcreate_msg(int,int,MPI_Datatype,int); 149 extern int BMget_msg_size(BMmsg *); 150 extern void BMset_msg_size(BMmsg *,int); 151 extern void BMinit_user(BMuser_data *); 152 extern void BMfree_user(BMuser_data *); 153 extern void BMfree_user_data(BMmsg *); 154 extern void BMfree_setup_data(BMmsg *); 155 extern void BMset_user(BMuser_data *,int *,int,void (*)(int *)); 156 extern void BMset_user_data(BMmsg *,int *,int,void (*)(int *)); 157 extern void BMset_setup_data(BMmsg *,int *,int,void (*)(int *)); 158 extern int *BMget_user(BMmsg *,int *); 159 extern int *BMget_setup(BMmsg *,int *); 160 extern void BMset_msg_ptr(BMmsg *,void *); 161 extern void *BMget_msg_ptr(BMmsg *); 162 extern BMmsg *BMnext_msg(BMphase *,BMmsg *); 163 extern void BMalloc_msg(BMcomp_msg *); 164 extern int BMfix_send(int,int,MPI_Datatype,BMcomp_msg *,BMphase *,void(*)(int *), 165 BSprocinfo *); 166 extern void BMinit_comp_msg(BMcomp_msg *,BSprocinfo *); 167 extern void BMfinish_comp_msg(BMcomp_msg *,BSprocinfo *); 168 extern void BMsendf_msg(BMmsg *,BSprocinfo *); 169 extern void BMcheck_on_async_block(BMphase *); 170 extern void BMfinish_on_async_block(BMphase *); 171 extern void BMsend_block_msg(BMphase *,BMmsg *,BSprocinfo *); 172 extern BMmsg *BMrecv_block_msg(BMphase *,BSprocinfo *); 173 extern BMmsg *BMrecv_msg(BMphase *); 174 extern void BMfree_block_msg(BMphase *); 175 extern void BMfree_msg(BMmsg *); 176 177 /* other BS private functions */ 178 extern BSnumbering *BSfnd_inode(BSspmat *,int,BSprocinfo *); 179 extern BSnumbering *BSalloc_numbering(int); 180 extern void BSfree_numbering(BSnumbering *); 181 extern BSpermutation *BSnum2perm(BSnumbering *,BSdistribution *); 182 extern BSpermutation *BSalloc_permutation(int); 183 extern void BSreset_permutation(int,BSpermutation *); 184 extern void BSfree_permutation(BSpermutation *); 185 extern BSdistribution *BSalloc_distribution(int); 186 extern void BSfree_distribution(BSdistribution *); 187 extern BSdistribution *BSnum2distr(BSnumbering *); 188 extern BSnumbering *BSfnd_clique(BSspmat *,int,int *,BSprocinfo *); 189 extern BSkey_arr *BSalloc_key_arr(int); 190 extern void BSfree_key_arr(BSkey_arr *key_arr); 191 extern void BSperm_ivec(int *,int *,BSpermutation *); 192 extern void BSiperm_ivec(int *,int *,BSpermutation *); 193 extern void BSperm_dvec(FLOAT *,FLOAT *,BSpermutation *); 194 extern void BSiperm_dvec(FLOAT *,FLOAT *,BSpermutation *); 195 extern void BSperm2iperm(BSpermutation *,BSpermutation *); 196 extern BSspmat *BSdo_contract(BSspmat *,BSnumbering *,BSpermutation *, 197 BSprocinfo *,int); 198 extern BSbb *BSinit_bb(int,BSmapping *); 199 extern void BSfree_bb(BSbb *); 200 extern void BSpost_bb(BSbb *,int,int *,int *); 201 extern void BSpost_noaddr_bb(BSbb *,int,int *); 202 extern void BSquery_match_bb(BSbb *,int,int *,int *,BSprocinfo *); 203 extern void BSquery_nomatch_bb(BSbb *,int,int *,int *,BSprocinfo *); 204 extern BSbb_d *BSinit_bb_d(int,BSmapping *); 205 extern void BSfree_bb_d(BSbb_d *); 206 extern void BSpost_bb_d(BSbb_d *,int,int *,FLOAT *); 207 extern void BSpost_noaddr_bb_d(BSbb_d *,int,FLOAT *); 208 extern void BSquery_match_bb_d(BSbb_d *,int,int *,FLOAT *,BSprocinfo *); 209 extern void BSquery_nomatch_bb_d(BSbb_d *,int,int *,FLOAT *,BSprocinfo *); 210 extern void BSx_color(int *,BSspmat *,BSprocinfo *,int *,int); 211 extern void BSido_color(int *,int,BSspmat *,int *,int **,int *,int *,int *, 212 int *,int *,int *,BSprocinfo *); 213 extern void BSsdo_color(int *,int,BSspmat *,int *,int **,int *,int *, 214 int *,int *,int *,int *,BSprocinfo *); 215 extern void BSpack_n_send(BSmsg_list *,int,int *,BSspmat *,BSprocinfo *, 216 int *,int *,int *,int *,int,int); 217 extern int BSmy_rand(int); 218 extern BSnumbering *BSoff_gnum(BSnumbering *,BSnumbering *,BSdistribution *); 219 extern BSdistribution *BSfold_distr(BSdistribution *,BSdistribution *,BSnumbering *); 220 extern BScl_2_inode *BStrans_perm_cl(BSspmat *,BSnumbering *,BSprocinfo *); 221 extern BSinode_list *BStrans_perm_in(BSspmat *,BSnumbering *,BSnumbering *, 222 BSdistribution *,BSprocinfo *); 223 extern void BSclique_2_inode(BSspmat *,BScl_2_inode *,BSinode_list *, 224 BSprocinfo *); 225 extern void BSrem_diag(BSspmat *); 226 extern void BSins_diag(BSspmat *); 227 extern BSkey_arr *BSperm_rows(BSspmat *,BSnumbering *,BSpermutation *, 228 BSdistribution *,BSprocinfo *,int,int *); 229 extern int BSrows_2_inode(BSspmat *,BSnumbering *,BSpermutation *, 230 BSpermutation *, BSsprow **,BSinode_list *,BScl_2_inode *, 231 BSkey_arr *,BSnumbering *,BSdistribution *,BSprocinfo *); 232 extern void BSnz_2_inode(BSspmat *,BSsprow **,BSinode_list *, 233 BScl_2_inode *,BSprocinfo *); 234 extern void BSsort_rows(BSspmat *,BSpermutation *,BSdistribution *,int); 235 extern BSpermutation *BSglobal_perm(BSnumbering *); 236 extern BSsprow **BSrow_perm(BSspmat *,BSpermutation *); 237 extern void BSfree_cl_2_inode(BScl_2_inode *,int); 238 extern void BSfree_inode_list(BSinode_list *); 239 extern BSnumbering *BSlow2high(BSspmat *,BSnumbering *,BSdistribution *, 240 BSprocinfo *); 241 extern BSnumbering *BSbase(BSdistribution *,BSprocinfo *); 242 extern BSnumbering *BScolor_2_clique(BSnumbering *,BScl_2_inode *); 243 extern void BSfree_reperm(BSreperm *); 244 extern void BSorig_inode(BSpar_mat *,BSprocinfo *); 245 FLOAT BSpar_ip(int,FLOAT *,FLOAT *,BSprocinfo *); 246 extern void BSpar_bip(int,FLOAT *,FLOAT *,int,FLOAT *,BSprocinfo *); 247 extern int BSpar_symmlq(int,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *, 248 FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *, 249 FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,int *,int,int *, 250 int *,BSprocinfo *); 251 extern int BSpar_bcg(int,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *,FLOAT *, 252 FLOAT *,int *,int *,int,BSprocinfo *); 253 extern void BSrow_err_check(BSspmat *,BSprocinfo *); 254 extern int BScount_nz(BSpar_mat *,BSprocinfo *); 255 extern int BSnonlocalnz(BSspmat *,int *,BSprocinfo *); 256 extern void BScopy_cliques(BSpar_mat *,BSpar_mat *); 257 extern void BSheap_sort0(int,int *); 258 extern void BSheap_sort1(int,int *,int *); 259 extern void BSheap_sort2(int,int *,int *,int *); 260 extern void BSheap_sorthl1(int,int *,int *); 261 extern void BSheap_sort1d(int,int *,FLOAT *); 262 extern void BSiheap_sort1(int,int *,int *); 263 extern void BSiheap_sort2(int,int *,int *,int *); 264 extern int BSfactor1(BSpar_mat *,BScomm *,BSprocinfo *); 265 extern int BSfactorn(BSpar_mat *,BScomm *,BSprocinfo *); 266 extern int BSilu_factor1(BSpar_mat *,BScomm *,BSprocinfo *); 267 extern int BSilu_factorn(BSpar_mat *,BScomm *,BSprocinfo *); 268 269 /* ****************************************************************** */ 270 /* End of section */ 271 /* ****************************************************************** */ 272 #endif 273