Package java.nio

Examples of java.nio.LongBuffer


    public EnumSet<Partition> getPartitionTypes() {

        if(!isFissionSupported()) {
            return EnumSet.noneOf(Partition.class);
        }
        LongBuffer types = getInfoLongs(CL_DEVICE_PARTITION_TYPES_EXT);

        List<Partition> list = new ArrayList<Partition>();
        while(types.hasRemaining()) {
            Partition type = Partition.valueOf((int)types.get());
            if(type != null) {
                list.add(type);
            }
        }
        return EnumSet.copyOf(list);


        if(!getPartitionTypes().contains(Partition.DOMAIN)) {
            return EnumSet.noneOf(AffinityDomain.class);
        }

        LongBuffer types = getInfoLongs(CL_DEVICE_AFFINITY_DOMAINS_EXT);

        List<AffinityDomain> list = new ArrayList<AffinityDomain>();
        while(types.hasRemaining()) {
            AffinityDomain type = AffinityDomain.valueOf((int)types.get());
            if(type != null) {
                list.add(type);
            }
        }
        return EnumSet.copyOf(list);

        NativeSizeBuffer nsb = NativeSizeBuffer.allocateDirect(1);
        int ret = cl.clGetDeviceInfo(ID, flag, 0, null, nsb);
        CLException.checkForError(ret, "clGetDeviceInfo failed");

        LongBuffer types = Buffers.newDirectByteBuffer((int)nsb.get(0)).asLongBuffer();
        ret = cl.clGetDeviceInfo(ID, flag, types.capacity()*Buffers.SIZEOF_LONG, types, null);
        CLException.checkForError(ret, "clGetDeviceInfo failed");

        return types;
    }

     * If N does not divide evenly into {@link #getMaxComputeUnits() } then the remaining compute units are
     * not used.
     */
    public CLSubDevice[] createSubDevicesEqually(int computeUnitsPerDevice) {

        LongBuffer props = Buffers.newDirectLongBuffer(3);
        props.put(CL_DEVICE_PARTITION_EQUALLY_EXT).put(computeUnitsPerDevice).put(0).rewind();

        return createSubDevices(props);
    }

        if(computeUnitsArray.length == 0) {
            throw new IllegalArgumentException("list was empty");
        }

        LongBuffer props = Buffers.newDirectLongBuffer(computeUnitsArray.length+3);
        props.put(CL_DEVICE_PARTITION_BY_COUNTS_EXT);
        for (int units : computeUnitsArray) {
            props.put(units);
        }
        props.put(0).put(0).rewind();
        return createSubDevices(props);
    }

   * Get an ID associated with a given long value.
   */
  public static ID idValue(long in) {
    byte[] bArray = new byte[8];
    ByteBuffer bBuffer = ByteBuffer.wrap(bArray);
    LongBuffer lBuffer = bBuffer.asLongBuffer();
    lBuffer.put(0, in);
    ID out = new ID();
    out.bytes(bArray);
    return out;
  }

        buf.clear();
        buf.mark();
        buf.position(buf.limit());

        // readonly's contents should be the same as buf
        LongBuffer readonly = buf.asReadOnlyBuffer();
        assertNotSame(buf, readonly);
        assertTrue(readonly.isReadOnly());
        assertEquals(buf.position(), readonly.position());
        assertEquals(buf.limit(), readonly.limit());
        assertEquals(buf.isDirect(), readonly.isDirect());
        assertEquals(buf.order(), readonly.order());
        assertContentEquals(buf, readonly);

        // readonly's position, mark, and limit should be independent to buf
        readonly.reset();
        assertEquals(readonly.position(), 0);
        readonly.clear();
        assertEquals(buf.position(), buf.limit());
        buf.reset();
        assertEquals(buf.position(), 0);
    }

    public void testCompact() {
        // case: buffer is full
        buf.clear();
        buf.mark();
        loadTestData1(buf);
        LongBuffer ret = buf.compact();
        assertSame(ret, buf);
        assertEquals(buf.position(), buf.capacity());
        assertEquals(buf.limit(), buf.capacity());
        assertContentLikeTestData1(buf, 0, 0, buf.capacity());
        try {

        assertEquals(0, buf.compareTo(buf));

        // normal cases
        assertTrue(buf.capacity() > 5);
        buf.clear();
        LongBuffer other = LongBuffer.allocate(buf.capacity());
        loadTestData1(other);
        assertEquals(0, buf.compareTo(other));
        assertEquals(0, other.compareTo(buf));
        buf.position(1);
        assertTrue(buf.compareTo(other) > 0);
        assertTrue(other.compareTo(buf) < 0);
        other.position(2);
        assertTrue(buf.compareTo(other) < 0);
        assertTrue(other.compareTo(buf) > 0);
        buf.position(2);
        other.limit(5);
        assertTrue(buf.compareTo(other) > 0);
        assertTrue(other.compareTo(buf) < 0);
    }

        buf.clear();
        buf.mark();
        buf.position(buf.limit());

        // duplicate's contents should be the same as buf
        LongBuffer duplicate = buf.duplicate();
        assertNotSame(buf, duplicate);
        assertEquals(buf.position(), duplicate.position());
        assertEquals(buf.limit(), duplicate.limit());
        assertEquals(buf.isReadOnly(), duplicate.isReadOnly());
        assertEquals(buf.isDirect(), duplicate.isDirect());
        assertEquals(buf.order(), duplicate.order());
        assertContentEquals(buf, duplicate);

        // duplicate's position, mark, and limit should be independent to buf
        duplicate.reset();
        assertEquals(duplicate.position(), 0);
        duplicate.clear();
        assertEquals(buf.position(), buf.limit());
        buf.reset();
        assertEquals(buf.position(), 0);

        // duplicate share the same content with buf
        if (!duplicate.isReadOnly()) {
            loadTestData1(buf);
            assertContentEquals(buf, duplicate);
            loadTestData2(duplicate);
            assertContentEquals(buf, duplicate);
        }

TOP

Related Classes of java.nio.LongBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.