< prev index next >

test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreBytes.java

Print this page
@@ -24,12 +24,10 @@
  package org.openjdk.bench.jdk.incubator.vector;
  
  import java.nio.ByteBuffer;
  import java.nio.ByteOrder;
  import java.util.concurrent.TimeUnit;
- import jdk.incubator.foreign.CLinker;
- import jdk.incubator.foreign.MemoryAccess;
  import jdk.incubator.foreign.MemoryAddress;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import jdk.incubator.vector.ByteVector;
  import jdk.incubator.vector.VectorOperators;

@@ -44,10 +42,12 @@
  import org.openjdk.jmh.annotations.Param;
  import org.openjdk.jmh.annotations.Setup;
  import org.openjdk.jmh.annotations.State;
  import org.openjdk.jmh.annotations.Warmup;
  
+ import static jdk.incubator.foreign.ValueLayout.JAVA_BYTE;
+ 
  @BenchmarkMode(Mode.AverageTime)
  @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
  @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
  @State(org.openjdk.jmh.annotations.Scope.Thread)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)

@@ -114,12 +114,12 @@
      srcBufferSegmentImplicit = srcSegmentImplicit.asByteBuffer();
      dstSegmentImplicit = MemorySegment.allocateNative(size, SPECIES.vectorByteSize(), implicitScope);
      dstBufferSegmentImplicit = dstSegmentImplicit.asByteBuffer();
  
  
-     srcAddress = CLinker.allocateMemory(size);
-     dstAddress = CLinker.allocateMemory(size);
+     srcAddress = MemorySegment.allocateNative(size, implicitScope).address();
+     dstAddress = MemorySegment.allocateNative(size, implicitScope).address();
  
      a = new byte[size];
      b = new byte[size];
      c = new byte[size];
    }

@@ -230,20 +230,20 @@
  
    @Benchmark
    @CompilerControl(CompilerControl.Mode.PRINT)
    public void segmentImplicitScalar() {
      for (int i = 0; i < SPECIES.loopBound(srcArray.length); i++) {
-       var v = MemoryAccess.getByteAtOffset(srcSegmentImplicit, i);
-       MemoryAccess.setByteAtOffset(dstSegmentImplicit, i, v);
+       var v = srcSegmentImplicit.get(JAVA_BYTE, i);
+       dstSegmentImplicit.set(JAVA_BYTE, i, v);
      }
    }
  
    @Benchmark
    public void bufferSegmentConfined() {
      try (final var scope = ResourceScope.newConfinedScope()) {
-       final var srcBufferSegmentConfined = srcAddress.asSegment(size, scope).asByteBuffer();
-       final var dstBufferSegmentConfined = dstAddress.asSegment(size, scope).asByteBuffer();
+       final var srcBufferSegmentConfined = MemorySegment.ofAddressNative(srcAddress, size, scope).asByteBuffer();
+       final var dstBufferSegmentConfined = MemorySegment.ofAddressNative(dstAddress, size, scope).asByteBuffer();
  
        for (int i = 0; i < SPECIES.loopBound(srcArray.length); i += SPECIES.length()) {
          var v = ByteVector.fromByteBuffer(SPECIES, srcBufferSegmentConfined, i, ByteOrder.nativeOrder());
          v.intoByteBuffer(dstBufferSegmentConfined, i, ByteOrder.nativeOrder());
        }
< prev index next >