compose MemorySegments
Douglas Surber
douglas.surber at oracle.com
Thu Jun 10 23:24:31 UTC 2021
Maurizio,
I can certainly respect a decision that composing multiple MemorySegments might be out of scope. Without composition I would write something like this.
MemorySegment.ofArray(dest)
.asSlice(destOffset, firstPartLength)
.copyFrom(MemorySegment.ofArray(src0).asSlice(srcOffset, firstPartLength);
MemorySegment.ofArray(dest)
.asSlice(destOffset + firstPartLength, destOffset + firstPartLength + secondPartLength)
.copyFrom(MemorySegment.ofArray(src1).asSlice(0L, secondPartLength));
This would copy the bits from the end of src0 into the first part of dest and the bits from the beginning of src1 into the second part of dest. Would all this result in just two SIMD instructions modulo bounds checking? And no allocations?
Douglas
More information about the panama-dev
mailing list