HYPRE_Int hypre_SMGResidualSetup( void *residual_vdata, hypre_StructMatrix *A, hypre_StructVector *x, hypre_StructVector *b, hypre_StructVector *r ) { HYPRE_Int ierr = 0; hypre_SMGResidualData *residual_data = residual_vdata; hypre_IndexRef base_index = (residual_data -> base_index); hypre_IndexRef base_stride = (residual_data -> base_stride); hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArray *base_points; hypre_ComputeInfo *compute_info; hypre_ComputePkg *compute_pkg; /*---------------------------------------------------------- * Set up base points and the compute package *----------------------------------------------------------*/ grid = hypre_StructMatrixGrid(A); stencil = hypre_StructMatrixStencil(A); base_points = hypre_BoxArrayDuplicate(hypre_StructGridBoxes(grid)); hypre_ProjectBoxArray(base_points, base_index, base_stride); hypre_CreateComputeInfo(grid, stencil, &compute_info); hypre_ComputeInfoProjectComp(compute_info, base_index, base_stride); hypre_ComputePkgCreate(compute_info, hypre_StructVectorDataSpace(x), 1, grid, &compute_pkg); /*---------------------------------------------------------- * Set up the residual data structure *----------------------------------------------------------*/ (residual_data -> A) = hypre_StructMatrixRef(A); (residual_data -> x) = hypre_StructVectorRef(x); (residual_data -> b) = hypre_StructVectorRef(b); (residual_data -> r) = hypre_StructVectorRef(r); (residual_data -> base_points) = base_points; (residual_data -> compute_pkg) = compute_pkg; /*----------------------------------------------------- * Compute flops *-----------------------------------------------------*/ (residual_data -> flops) = (hypre_StructMatrixGlobalSize(A) + hypre_StructVectorGlobalSize(x)) / (hypre_IndexX(base_stride) * hypre_IndexY(base_stride) * hypre_IndexZ(base_stride) ); return ierr; }
int hypre_StructMatvecSetup( void *matvec_vdata, hypre_StructMatrix *A, hypre_StructVector *x ) { int ierr = 0; hypre_StructMatvecData *matvec_data = matvec_vdata; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArrayArray *send_boxes; hypre_BoxArrayArray *recv_boxes; int **send_processes; int **recv_processes; hypre_BoxArrayArray *indt_boxes; hypre_BoxArrayArray *dept_boxes; hypre_Index unit_stride; hypre_ComputePkg *compute_pkg; /*---------------------------------------------------------- * Set up the compute package *----------------------------------------------------------*/ grid = hypre_StructMatrixGrid(A); stencil = hypre_StructMatrixStencil(A); hypre_CreateComputeInfo(grid, stencil, &send_boxes, &recv_boxes, &send_processes, &recv_processes, &indt_boxes, &dept_boxes); hypre_SetIndex(unit_stride, 1, 1, 1); hypre_ComputePkgCreate(send_boxes, recv_boxes, unit_stride, unit_stride, send_processes, recv_processes, indt_boxes, dept_boxes, unit_stride, grid, hypre_StructVectorDataSpace(x), 1, &compute_pkg); /*---------------------------------------------------------- * Set up the matvec data structure *----------------------------------------------------------*/ (matvec_data -> A) = hypre_StructMatrixRef(A); (matvec_data -> x) = hypre_StructVectorRef(x); (matvec_data -> compute_pkg) = compute_pkg; return ierr; }
HYPRE_Int hypre_SparseMSGInterpSetup( void *interp_vdata, hypre_StructMatrix *P, hypre_StructVector *xc, hypre_StructVector *e, hypre_Index cindex, hypre_Index findex, hypre_Index stride, hypre_Index strideP ) { hypre_SparseMSGInterpData *interp_data = interp_vdata; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_ComputeInfo *compute_info; hypre_ComputePkg *compute_pkg; HYPRE_Int ierr = 0; /*---------------------------------------------------------- * Set up the compute package *----------------------------------------------------------*/ grid = hypre_StructVectorGrid(e); stencil = hypre_StructMatrixStencil(P); hypre_CreateComputeInfo(grid, stencil, &compute_info); hypre_ComputeInfoProjectSend(compute_info, cindex, stride); hypre_ComputeInfoProjectRecv(compute_info, cindex, stride); hypre_ComputeInfoProjectComp(compute_info, findex, stride); hypre_ComputePkgCreate(compute_info, hypre_StructVectorDataSpace(e), 1, grid, &compute_pkg); /*---------------------------------------------------------- * Set up the interp data structure *----------------------------------------------------------*/ (interp_data -> P) = hypre_StructMatrixRef(P); (interp_data -> compute_pkg) = compute_pkg; hypre_CopyIndex(cindex, (interp_data -> cindex)); hypre_CopyIndex(findex, (interp_data -> findex)); hypre_CopyIndex(stride, (interp_data -> stride)); hypre_CopyIndex(strideP, (interp_data -> strideP)); return ierr; }
int hypre_SMGResidualSetup(void *residual_vdata,hypre_StructMatrix *A,hypre_StructVector *x,hypre_StructVector *b,hypre_StructVector *r) { int ierr = 0; hypre_SMGResidualData *residual_data = residual_vdata; hypre_IndexRef base_index = (residual_data -> base_index); hypre_IndexRef base_stride = (residual_data -> base_stride); hypre_Index unit_stride; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArrayArray *send_boxes; hypre_BoxArrayArray *recv_boxes; int **send_processes; int **recv_processes; hypre_BoxArrayArray *indt_boxes; hypre_BoxArrayArray *dept_boxes; hypre_BoxArray *base_points; hypre_ComputePkg *compute_pkg; /*---------------------------------------------------------- * Set up base points and the compute package *----------------------------------------------------------*/ grid = (A -> grid); stencil = (A -> stencil); ((((unit_stride[0] = 1) , (unit_stride[1] = 1))) , (unit_stride[2] = 1)); base_points = hypre_BoxArrayDuplicate((grid -> boxes)); hypre_ProjectBoxArray(base_points,base_index,base_stride); hypre_CreateComputeInfo(grid,stencil,&send_boxes,&recv_boxes,&send_processes,&recv_processes,&indt_boxes,&dept_boxes); hypre_ProjectBoxArrayArray(indt_boxes,base_index,base_stride); hypre_ProjectBoxArrayArray(dept_boxes,base_index,base_stride); hypre_ComputePkgCreate(send_boxes,recv_boxes,unit_stride,unit_stride,send_processes,recv_processes,indt_boxes,dept_boxes,base_stride,grid,(x -> data_space),1,&compute_pkg); /*---------------------------------------------------------- * Set up the residual data structure *----------------------------------------------------------*/ residual_data -> A = hypre_StructMatrixRef(A); residual_data -> x = hypre_StructVectorRef(x); residual_data -> b = hypre_StructVectorRef(b); residual_data -> r = hypre_StructVectorRef(r); residual_data -> base_points = base_points; residual_data -> compute_pkg = compute_pkg; /*----------------------------------------------------- * Compute flops *-----------------------------------------------------*/ residual_data -> flops = (((A -> global_size) + (x -> global_size)) / (((base_stride[0]) * (base_stride[1])) * (base_stride[2]))); return ierr; }
int hypre_SMGResidualSetup( void *residual_vdata, hypre_StructMatrix *A, hypre_StructVector *x, hypre_StructVector *b, hypre_StructVector *r ) { int ierr = 0; hypre_SMGResidualData *residual_data = residual_vdata; hypre_IndexRef base_index = (residual_data -> base_index); hypre_IndexRef base_stride = (residual_data -> base_stride); hypre_Index unit_stride; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArrayArray *send_boxes; hypre_BoxArrayArray *recv_boxes; int **send_processes; int **recv_processes; hypre_BoxArrayArray *indt_boxes; hypre_BoxArrayArray *dept_boxes; hypre_BoxArray *base_points; hypre_ComputePkg *compute_pkg; /*---------------------------------------------------------- * Set up base points and the compute package *----------------------------------------------------------*/ grid = hypre_StructMatrixGrid(A); stencil = hypre_StructMatrixStencil(A); hypre_SetIndex(unit_stride, 1, 1, 1); base_points = hypre_BoxArrayDuplicate(hypre_StructGridBoxes(grid)); hypre_ProjectBoxArray(base_points, base_index, base_stride); hypre_CreateComputeInfo(grid, stencil, &send_boxes, &recv_boxes, &send_processes, &recv_processes, &indt_boxes, &dept_boxes); hypre_ProjectBoxArrayArray(indt_boxes, base_index, base_stride); hypre_ProjectBoxArrayArray(dept_boxes, base_index, base_stride); hypre_ComputePkgCreate(send_boxes, recv_boxes, unit_stride, unit_stride, send_processes, recv_processes, indt_boxes, dept_boxes, base_stride, grid, hypre_StructVectorDataSpace(x), 1, &compute_pkg); /*---------------------------------------------------------- * Set up the residual data structure *----------------------------------------------------------*/ (residual_data -> A) = hypre_StructMatrixRef(A); (residual_data -> x) = hypre_StructVectorRef(x); (residual_data -> b) = hypre_StructVectorRef(b); (residual_data -> r) = hypre_StructVectorRef(r); (residual_data -> base_points) = base_points; (residual_data -> compute_pkg) = compute_pkg; /*----------------------------------------------------- * Compute flops *-----------------------------------------------------*/ (residual_data -> flops) = (hypre_StructMatrixGlobalSize(A) + hypre_StructVectorGlobalSize(x)) / (hypre_IndexX(base_stride) * hypre_IndexY(base_stride) * hypre_IndexZ(base_stride) ); return ierr; }
int hypre_PointRelaxSetup( void *relax_vdata, hypre_StructMatrix *A, hypre_StructVector *b, hypre_StructVector *x ) { hypre_PointRelaxData *relax_data = (hypre_PointRelaxData *)relax_vdata; int num_pointsets = (relax_data -> num_pointsets); int *pointset_sizes = (relax_data -> pointset_sizes); hypre_Index *pointset_strides = (relax_data -> pointset_strides); hypre_Index **pointset_indices = (relax_data -> pointset_indices); hypre_StructVector *t; int diag_rank; hypre_ComputePkg **compute_pkgs; hypre_Index unit_stride; hypre_Index diag_index; hypre_IndexRef stride; hypre_IndexRef index; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArrayArray *send_boxes; hypre_BoxArrayArray *recv_boxes; int **send_processes; int **recv_processes; hypre_BoxArrayArray *indt_boxes; hypre_BoxArrayArray *dept_boxes; hypre_BoxArrayArray *orig_indt_boxes; hypre_BoxArrayArray *orig_dept_boxes; hypre_BoxArrayArray *box_aa; hypre_BoxArray *box_a; hypre_Box *box; int box_aa_size; int box_a_size; hypre_BoxArrayArray *new_box_aa; hypre_BoxArray *new_box_a; hypre_Box *new_box; double scale; int frac; int i, j, k, p, m, compute_i; int ierr = 0; /*---------------------------------------------------------- * Set up the temp vector *----------------------------------------------------------*/ if ((relax_data -> t) == NULL) { t = hypre_StructVectorCreate(hypre_StructVectorComm(b), hypre_StructVectorGrid(b)); hypre_StructVectorSetNumGhost(t, hypre_StructVectorNumGhost(b)); hypre_StructVectorInitialize(t); hypre_StructVectorAssemble(t); (relax_data -> t) = t; } /*---------------------------------------------------------- * Find the matrix diagonal *----------------------------------------------------------*/ grid = hypre_StructMatrixGrid(A); stencil = hypre_StructMatrixStencil(A); hypre_SetIndex(diag_index, 0, 0, 0); diag_rank = hypre_StructStencilElementRank(stencil, diag_index); /*---------------------------------------------------------- * Set up the compute packages *----------------------------------------------------------*/ hypre_SetIndex(unit_stride, 1, 1, 1); compute_pkgs = hypre_CTAlloc(hypre_ComputePkg *, num_pointsets); for (p = 0; p < num_pointsets; p++) { hypre_CreateComputeInfo(grid, stencil, &send_boxes, &recv_boxes, &send_processes, &recv_processes, &orig_indt_boxes, &orig_dept_boxes); stride = pointset_strides[p]; for (compute_i = 0; compute_i < 2; compute_i++) { switch(compute_i) { case 0: box_aa = orig_indt_boxes; break; case 1: box_aa = orig_dept_boxes; break; } box_aa_size = hypre_BoxArrayArraySize(box_aa); new_box_aa = hypre_BoxArrayArrayCreate(box_aa_size); for (i = 0; i < box_aa_size; i++) { box_a = hypre_BoxArrayArrayBoxArray(box_aa, i); box_a_size = hypre_BoxArraySize(box_a); new_box_a = hypre_BoxArrayArrayBoxArray(new_box_aa, i); hypre_BoxArraySetSize(new_box_a, box_a_size * pointset_sizes[p]); k = 0; for (m = 0; m < pointset_sizes[p]; m++) { index = pointset_indices[p][m]; for (j = 0; j < box_a_size; j++) { box = hypre_BoxArrayBox(box_a, j); new_box = hypre_BoxArrayBox(new_box_a, k); hypre_CopyBox(box, new_box); hypre_ProjectBox(new_box, index, stride); k++; } } } switch(compute_i) { case 0: indt_boxes = new_box_aa; break; case 1: dept_boxes = new_box_aa; break; } } hypre_ComputePkgCreate(send_boxes, recv_boxes, unit_stride, unit_stride, send_processes, recv_processes, indt_boxes, dept_boxes, stride, grid, hypre_StructVectorDataSpace(x), 1, &compute_pkgs[p]); hypre_BoxArrayArrayDestroy(orig_indt_boxes); hypre_BoxArrayArrayDestroy(orig_dept_boxes); } /*---------------------------------------------------------- * Set up the relax data structure *----------------------------------------------------------*/ (relax_data -> A) = hypre_StructMatrixRef(A); (relax_data -> x) = hypre_StructVectorRef(x); (relax_data -> b) = hypre_StructVectorRef(b); (relax_data -> diag_rank) = diag_rank; (relax_data -> compute_pkgs) = compute_pkgs; /*----------------------------------------------------- * Compute flops *-----------------------------------------------------*/ scale = 0.0; for (p = 0; p < num_pointsets; p++) { stride = pointset_strides[p]; frac = hypre_IndexX(stride); frac *= hypre_IndexY(stride); frac *= hypre_IndexZ(stride); scale += (pointset_sizes[p] / frac); } (relax_data -> flops) = scale * (hypre_StructMatrixGlobalSize(A) + hypre_StructVectorGlobalSize(x)); return ierr; }
int hypre_SemiInterpSetup( void *interp_vdata, hypre_StructMatrix *P, int P_stored_as_transpose, hypre_StructVector *xc, hypre_StructVector *e, hypre_Index cindex, hypre_Index findex, hypre_Index stride ) { hypre_SemiInterpData *interp_data = interp_vdata; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArrayArray *send_boxes; hypre_BoxArrayArray *recv_boxes; int **send_processes; int **recv_processes; hypre_BoxArrayArray *indt_boxes; hypre_BoxArrayArray *dept_boxes; hypre_ComputePkg *compute_pkg; int ierr = 0; /*---------------------------------------------------------- * Set up the compute package *----------------------------------------------------------*/ grid = hypre_StructVectorGrid(e); stencil = hypre_StructMatrixStencil(P); hypre_CreateComputeInfo(grid, stencil, &send_boxes, &recv_boxes, &send_processes, &recv_processes, &indt_boxes, &dept_boxes); hypre_ProjectBoxArrayArray(send_boxes, cindex, stride); hypre_ProjectBoxArrayArray(recv_boxes, cindex, stride); hypre_ProjectBoxArrayArray(indt_boxes, findex, stride); hypre_ProjectBoxArrayArray(dept_boxes, findex, stride); hypre_ComputePkgCreate(send_boxes, recv_boxes, stride, stride, send_processes, recv_processes, indt_boxes, dept_boxes, stride, grid, hypre_StructVectorDataSpace(e), 1, &compute_pkg); /*---------------------------------------------------------- * Set up the interp data structure *----------------------------------------------------------*/ (interp_data -> P) = hypre_StructMatrixRef(P); (interp_data -> P_stored_as_transpose) = P_stored_as_transpose; (interp_data -> compute_pkg) = compute_pkg; hypre_CopyIndex(cindex, (interp_data -> cindex)); hypre_CopyIndex(findex, (interp_data -> findex)); hypre_CopyIndex(stride, (interp_data -> stride)); return ierr; }
int hypre_SemiRestrictSetup( void *restrict_vdata, hypre_StructMatrix *R, int R_stored_as_transpose, hypre_StructVector *r, hypre_StructVector *rc, hypre_Index cindex, hypre_Index findex, hypre_Index stride ) { hypre_SemiRestrictData *restrict_data = (hypre_SemiRestrictData *)restrict_vdata; hypre_StructGrid *grid; hypre_StructStencil *stencil; hypre_BoxArrayArray *send_boxes; hypre_BoxArrayArray *recv_boxes; int **send_processes; int **recv_processes; hypre_BoxArrayArray *indt_boxes; hypre_BoxArrayArray *dept_boxes; hypre_ComputePkg *compute_pkg; int ierr = 0; /*---------------------------------------------------------- * Set up the compute package *----------------------------------------------------------*/ grid = hypre_StructVectorGrid(r); stencil = hypre_StructMatrixStencil(R); hypre_CreateComputeInfo(grid, stencil, &send_boxes, &recv_boxes, &send_processes, &recv_processes, &indt_boxes, &dept_boxes); hypre_ProjectBoxArrayArray(send_boxes, findex, stride); hypre_ProjectBoxArrayArray(recv_boxes, findex, stride); hypre_ProjectBoxArrayArray(indt_boxes, cindex, stride); hypre_ProjectBoxArrayArray(dept_boxes, cindex, stride); hypre_ComputePkgCreate(send_boxes, recv_boxes, stride, stride, send_processes, recv_processes, indt_boxes, dept_boxes, stride, grid, hypre_StructVectorDataSpace(r), 1, &compute_pkg); /*---------------------------------------------------------- * Set up the restrict data structure *----------------------------------------------------------*/ (restrict_data -> R) = hypre_StructMatrixRef(R); (restrict_data -> R_stored_as_transpose) = R_stored_as_transpose; (restrict_data -> compute_pkg) = compute_pkg; hypre_CopyIndex(cindex ,(restrict_data -> cindex)); hypre_CopyIndex(stride ,(restrict_data -> stride)); return ierr; }