< prev index next >

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

Print this page
@@ -24,11 +24,11 @@
  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.MemoryAddress;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import jdk.incubator.vector.ShortVector;
  import jdk.incubator.vector.VectorOperators;

@@ -110,34 +110,28 @@
  
      srcBufferNative = ByteBuffer.allocateDirect(size);
      dstBufferNative = ByteBuffer.allocateDirect(size);
  
  
-     implicitScope = ResourceScope.newImplicitScope();
+     implicitScope = ResourceScope.newSharedScope();
      srcSegmentImplicit = MemorySegment.allocateNative(size, SPECIES.vectorByteSize(), implicitScope);
      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();
  
      this.longSize = longSize;
  
      a = new short[size];
      b = new short[size];
      c = new short[size];
  
    }
  
-   @TearDown
-   public void tearDown() {
-     CLinker.freeMemory(srcAddress);
-     CLinker.freeMemory(dstAddress);
-   }
- 
    @Benchmark
    @CompilerControl(CompilerControl.Mode.PRINT)
    public void array() {
      for (int i = 0; i < SPECIES.loopBound(srcArray.length); i += SPECIES.length()) {
        var v = ShortVector.fromArray(SPECIES, srcArray, i);

@@ -214,12 +208,12 @@
    }
  
    @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 = ShortVector.fromByteBuffer(SPECIES, srcBufferSegmentConfined, i, ByteOrder.nativeOrder());
          v.intoByteBuffer(dstBufferSegmentConfined, i, ByteOrder.nativeOrder());
        }
< prev index next >