}
}
- private MemoryAddress getMap(ByteBuffer bb) {
- synchronized (maps) {
- // Note this can't use a hashtable as ByteBuffer
- // hashes on state like position.
- for (int i=0;i<maps.size();i++) {
- MapData d = maps.get(i);
-
- if (d.buffer == bb) {
- maps.remove(i);
- return d.raw;
- }
- }
- }
- throw new IllegalArgumentException();
- }
-
public ByteBuffer enqueueMapBuffer(CLBuffer buffer, boolean blocking,
long flags,
long offset,
if (res != 0)
throw new CLException(res);
- // Need to map the segment and track it separately
- ByteBuffer bb = Memory.ofNative(cmap, size).asByteBuffer();
-
- addMap(cmap, bb);
-
- info.post(event);
-
- return bb;
+ return Memory.ofNative(cmap, size).asByteBuffer();
} catch (CLException | RuntimeException | Error t) {
throw t;
} catch (Throwable t) {
? stride * region[1] + region[0] // 2D
: slice * region[2] + stride * region[1] + region[0]; // 3D
- // Need to map the segment and track it separately
- ByteBuffer bb = Memory.ofNative(cmap, size).asByteBuffer();
-
- addMap(cmap, bb);
-
- info.post(event);
-
- return bb;
+ return Memory.ofNative(cmap, size).asByteBuffer();
} catch (CLException | RuntimeException | Error t) {
throw t;
} catch (Throwable t) {
public void enqueueUnmapMemObject(CLMemory mem, ByteBuffer mapped,
CLEventList wait,
CLEventList event) throws CLException {
- MemoryAddress cmap = getMap(mapped);
+ MemoryAddress cmap = MemorySegment.ofByteBuffer(mapped).baseAddress();
try (Allocator frame = Memory.stack()) {
EventInfo info = new EventInfo(frame, wait, event);