void ComputeRegFromStencil( Region **dep_reg_ptr, Region **ind_reg_ptr, SubregionArray *cr_array, /* compute region SubregionArray */ Region *send_reg, Region *recv_reg, Stencil *stencil) { Region *dep_reg; Region *ind_reg; SubregionArray *ir_array; SubregionArray *dr_array; SubregionArray *a0, *a1; int i, j, k; (void)recv_reg; (void)stencil; /*----------------------------------------------------------------------- * Set up the dependent region *-----------------------------------------------------------------------*/ dep_reg = NewRegion(SubregionArraySize(cr_array)); #ifndef NO_OVERLAP_COMM_COMP ForSubregionArrayI(i, dep_reg) { FreeSubregionArray(RegionSubregionArray(dep_reg, i)); RegionSubregionArray(dep_reg, i) = UnionSubgridArray((SubgridArray *) RegionSubregionArray(send_reg, i)); }
CommPkg *NewCommPkg( Region * send_region, Region * recv_region, SubregionArray *data_space, int num_vars, /* number of variables in the vector */ double * data) { CommPkg *new_comm_pkg; amps_Invoice invoice; SubregionArray *comm_sra; Subregion *comm_sr; Subregion *data_sr; int *loop_array; int *send_proc_array = NULL; int *recv_proc_array = NULL; int num_send_subregions; int num_recv_subregions; int num_send_procs; int num_recv_procs; int proc; int i, j, p; int dim; new_comm_pkg = ctalloc(CommPkg, 1); /*------------------------------------------------------ * compute num send and recv subregions *------------------------------------------------------*/ num_send_subregions = 0; num_recv_subregions = 0; ForSubregionI(i, data_space) { num_send_subregions += SubregionArraySize(RegionSubregionArray(send_region, i)); num_recv_subregions += SubregionArraySize(RegionSubregionArray(recv_region, i)); }
ForSubregionArrayI(k, ind_reg) { ir_array = RegionSubregionArray(ind_reg, k); dr_array = RegionSubregionArray(dep_reg, k); AppendSubregion(DuplicateSubregion(SubregionArraySubregion(cr_array, k)), ir_array); ForSubregionI(i, dr_array) { a0 = NewSubregionArray(); ForSubregionI(j, ir_array) { a1 = SubtractSubgrids(SubregionArraySubregion(ir_array, j), SubregionArraySubregion(dr_array, i)); AppendSubregionArray(a1, a0); SubregionArraySize(a1) = 0; FreeSubregionArray(a1); }
#else ForSubregionArrayI(i, dep_reg) { AppendSubregion(RegionSubregionArray(dep_reg, i), SubregionArraySubregion(cr_array, i)); } #endif /*----------------------------------------------------------------------- * Set up the independent region *-----------------------------------------------------------------------*/ ind_reg = NewRegion(SubregionArraySize(cr_array)); #ifndef OVERLAP_COMM_COMP ForSubregionArrayI(k, ind_reg) { ir_array = RegionSubregionArray(ind_reg, k); dr_array = RegionSubregionArray(dep_reg, k); AppendSubregion(DuplicateSubregion(SubregionArraySubregion(cr_array, k)), ir_array); ForSubregionI(i, dr_array) { a0 = NewSubregionArray();