140 likes | 267 Views
Computer Science 320. Slicing and Dicing Data with Buffers. Type-Specific Buffer Classes. edu.rit.BooleanBuf edu.rit.ByteBuf edu.rit.CharacterBuf edu.rit.DoubleBuf edu.rit.FloatBuf edu.rit.IntegerBuf edu.rit.LongBuf edu.rit.ShortBuf edu.rit.ObjectBuf.
E N D
Computer Science 320 Slicing and Dicing Data with Buffers
Type-Specific Buffer Classes • edu.rit.BooleanBuf • edu.rit.ByteBuf • edu.rit.CharacterBuf • edu.rit.DoubleBuf • edu.rit.FloatBuf • edu.rit.IntegerBuf • edu.rit.LongBuf • edu.rit.ShortBuf • edu.rit.ObjectBuf These are wrappers for primitive values or objects They all implement Serializable
Example: A Single Item Integer Buffer IntegerItemBufbuf = IntegerBuf.buffer(); buf.item = 42; System.out.println(buf.item);
Example: An Integer Array Buffer int[] data = new int[8]; IntegerBufbuf = IntegerBuf.buffer(data);
Example: An Array Slice int[] data = new int[8]; Range sliceRange = new Range(2, 4); IntegerBufbuf = IntegerBuf.buffer(data, sliceRange);
Example: Range Stride > 1 int[] data = new int[8]; Range evenRange = new Range(0, 6, 2); IntegerBufbuf = IntegerBuf.buffer(data, evenRange);
Example: Partitioning an Array int[] data = new int[8]; Range[] sliceRanges = new Range(0, 7).subranges(4); IntegerBuf[] sliceBufs = IntegerBuf.sliceBuffers(data, sliceRanges);
Example: An Integer Matrix Buffer int[] data = new int[4][8]; IntegerBufbuf = IntegerBuf.buffer(data); Data are written to and read from the communication buffer in row-major order
Example: A Matrix Row Slice int[] data = new int[4][8]; Range rowRange = new Range(2, 3); IntegerBufbuf = IntegerBuf.rowSliceBuffer(data, rowRange); Only the data values in the row range are transferred through the buffer
Example: A Matrix Column Slice int[] data = new int[4][8]; Range colRange = new Range(2, 4); IntegerBufbuf = IntegerBuf.colSliceBuffer(data, colRange); Only the data values in the column range are transferred through the buffer
Example: A Matrix Patch (Rows and Columns) int[] data = new int[4][8]; Range rowRange = new Range(1, 2); Range colRange = new Range(4, 5); IntegerBufbuf = IntegerBuf.patchBuffer(data, colRange); Only the data values in the matrix “patch” are transferred through the buffer
Example: Matrix Partition by Rows int[] data = new int[4][8]; Range[] rowRanges = new Range(0, 3).subranges(4); IntegerBufrowBufs = IntegerBuf.rowSliceBuffers(data, rowRanges); Used as source in scatter and destination in gather operations
Example: Matrix Partition by Columns int[] data = new int[4][8]; Range[] colRanges = new Range(0, 7).subranges(4); IntegerBufcolBufs = IntegerBuf.colSliceBuffers(data, colRanges); Used as source in scatter and destination in gather operations
Example: Matrix Partition by Patches int[] data = new int[4][8]; Range[] rowRanges = new Range(0, 3).subranges(2); Range[] colRanges = new Range(0, 7).subranges(2); IntegerBufpatchBufs = IntegerBuf.patchBuffers(data, rowRanges, colRanges); Used as source in scatter and destination in gather operations