TileLayout(Section localSection, Section wantSection) throws InvalidRangeException { Section dataSection = localSection.compact(); Section resultSection = wantSection.compact(); if (debug) System.out.println(" resultSection: " + resultSection); if (debug) System.out.println(" dataSection: " + dataSection); int rank = dataSection.getRank(); // total elements to transfer total = (int) dataSection.computeSize(); // figure out the offset long product = 1; startElem = 0; // offset in want for (int ii = rank - 1; ii >= 0; ii--) { int d = dataSection.getOrigin(ii) - resultSection.getOrigin(ii); if (d > 0) startElem += product * d; product *= resultSection.getShape(ii); } resultPos = startElem; // we will use an Index object to keep track of the chunks // last range length is nelems; reduce index rank nelems = localSection.getShape(rank - 1); int[] stride = new int[rank - 1]; int[] shape = new int[rank - 1]; product = resultSection.getShape(rank - 1); for (int ii = rank - 2; ii >= 0; ii--) { stride[ii] = (int) product; shape[ii] = dataSection.getShape(ii); product *= resultSection.getShape(ii); } index = new Index(shape, stride); }
TileLayout(Section localSection, Section wantSection) throws InvalidRangeException { Section dataSection = localSection.compact(); Section resultSection = wantSection.compact(); if (debug) System.out.println(" resultSection: " + resultSection); if (debug) System.out.println(" dataSection: " + dataSection); int rank = dataSection.getRank(); // total elements to transfer total = (int) dataSection.computeSize(); // figure out the offset long product = 1; startElem = 0; // offset in want for (int ii = rank - 1; ii >= 0; ii--) { int d = dataSection.getOrigin(ii) - resultSection.getOrigin(ii); if (d > 0) startElem += product * d; product *= resultSection.getShape(ii); } resultPos = startElem; // we will use an Index object to keep track of the chunks // last range length is nelems; reduce index rank nelems = localSection.getShape(rank - 1); int[] stride = new int[rank - 1]; int[] shape = new int[rank - 1]; product = resultSection.getShape(rank - 1); for (int ii = rank - 2; ii >= 0; ii--) { stride[ii] = (int) product; shape[ii] = dataSection.getShape(ii); product *= resultSection.getShape(ii); } index = new Index(shape, stride); }
TileLayout(Section localSection, Section wantSection) throws InvalidRangeException { Section dataSection = localSection.compact(); Section resultSection = wantSection.compact(); if (debug) System.out.println(" resultSection: " + resultSection); if (debug) System.out.println(" dataSection: " + dataSection); int rank = dataSection.getRank(); // total elements to transfer total = (int) dataSection.computeSize(); // figure out the offset long product = 1; startElem = 0; // offset in want for (int ii = rank - 1; ii >= 0; ii--) { int d = dataSection.getOrigin(ii) - resultSection.getOrigin(ii); if (d > 0) startElem += product * d; product *= resultSection.getShape(ii); } resultPos = startElem; // we will use an Index object to keep track of the chunks // last range length is nelems; reduce index rank nelems = localSection.getShape(rank - 1); int[] stride = new int[rank - 1]; int[] shape = new int[rank - 1]; product = resultSection.getShape(rank - 1); for (int ii = rank - 2; ii >= 0; ii--) { stride[ii] = (int) product; shape[ii] = dataSection.getShape(ii); product *= resultSection.getShape(ii); } index = new Index(shape, stride); }