From 26e5155dc349ff9db9a01fe6d9ec08104a0a5d70 Mon Sep 17 00:00:00 2001 From: Juan Fumero Date: Thu, 10 Mar 2022 12:30:31 +0100 Subject: [PATCH] Buffer allocation size match to jlong --- levelZeroLib/src/levelZeroContext.cpp | 44 ++++++++--------- levelZeroLib/src/levelZeroContext.h | 20 ++++---- .../levelzero/LevelZeroBufferInteger.java | 6 +-- .../spirv/levelzero/LevelZeroBufferLong.java | 10 ++-- .../spirv/levelzero/LevelZeroByteBuffer.java | 12 ++--- .../spirv/levelzero/LevelZeroContext.java | 49 ++++++++++--------- .../spirv/levelzero/utils/LevelZeroUtils.java | 8 +-- 7 files changed, 75 insertions(+), 74 deletions(-) diff --git a/levelZeroLib/src/levelZeroContext.cpp b/levelZeroLib/src/levelZeroContext.cpp index 4569589..05e053b 100644 --- a/levelZeroLib/src/levelZeroContext.cpp +++ b/levelZeroLib/src/levelZeroContext.cpp @@ -315,10 +315,10 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocShared_native - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocShared_1native - (JNIEnv *env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jobject javaHostMemAllocDesc, jint bufferSize, jint aligmnent, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { + (JNIEnv *env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jobject javaHostMemAllocDesc, jlong bufferSize, jlong aligmnent, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { ze_context_handle_t context = reinterpret_cast(javaContextPtr); ze_device_handle_t device = reinterpret_cast(javaDeviceHandler); @@ -362,10 +362,10 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocShared_nativeByte - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocShared_1nativeByte - (JNIEnv *env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jobject javaHostMemAllocDesc, jint bufferSize, jint aligmnent, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { + (JNIEnv *env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jobject javaHostMemAllocDesc, jlong bufferSize, jlong aligmnent, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { ze_context_handle_t context = reinterpret_cast(javaContextPtr); ze_device_handle_t device = reinterpret_cast(javaDeviceHandler); @@ -409,10 +409,10 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocDevice_native - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocDevice_1native - (JNIEnv *env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jint allocSize, jint alignment, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { + (JNIEnv *env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jlong allocSize, jlong alignment, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { ze_context_handle_t context = reinterpret_cast(javaContextPtr); ze_device_handle_t device = reinterpret_cast(javaDeviceHandler); @@ -438,11 +438,11 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev LOG_ZE_JNI("zeMemAllocDevice", result) // Set Buffer Pointer and attributes - jfieldID fieldBufferSize = env->GetFieldID(javaBufferClass, "size", "I"); - jfieldID alignmentField = env->GetFieldID(javaBufferClass, "alignment", "I"); + jfieldID fieldBufferSize = env->GetFieldID(javaBufferClass, "size", "J"); + jfieldID alignmentField = env->GetFieldID(javaBufferClass, "alignment", "J"); env->SetLongField(javaLevelZeroBuffer, fieldBuffer, reinterpret_cast(buffer)); - env->SetIntField(javaLevelZeroBuffer, fieldBufferSize, allocSize); - env->SetIntField(javaLevelZeroBuffer, alignmentField, alignment); + env->SetLongField(javaLevelZeroBuffer, fieldBufferSize, allocSize); + env->SetLongField(javaLevelZeroBuffer, alignmentField, alignment); return result; } @@ -450,10 +450,10 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocDevice_nativeLong - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocDevice_1nativeLong - (JNIEnv * env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jint allocSize, jint alignment, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { + (JNIEnv * env, jobject object, jlong javaContextPtr, jobject javaDeviceMemAllocDesc, jlong allocSize, jlong alignment, jlong javaDeviceHandler, jobject javaLevelZeroBuffer) { ze_context_handle_t context = reinterpret_cast(javaContextPtr); ze_device_handle_t device = reinterpret_cast(javaDeviceHandler); @@ -478,11 +478,11 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev LOG_ZE_JNI("zeMemAllocDevice - [LONG]", result) // Set Buffer Pointer and attributes - jfieldID fieldBufferSize = env->GetFieldID(javaBufferClass, "size", "I"); - jfieldID alignmentField = env->GetFieldID(javaBufferClass, "alignment", "I"); + jfieldID fieldBufferSize = env->GetFieldID(javaBufferClass, "size", "J"); + jfieldID alignmentField = env->GetFieldID(javaBufferClass, "alignment", "J"); env->SetLongField(javaLevelZeroBuffer, fieldBuffer, reinterpret_cast(buffer)); - env->SetIntField(javaLevelZeroBuffer, fieldBufferSize, allocSize); - env->SetIntField(javaLevelZeroBuffer, alignmentField, alignment); + env->SetLongField(javaLevelZeroBuffer, fieldBufferSize, allocSize); + env->SetLongField(javaLevelZeroBuffer, alignmentField, alignment); return result; } @@ -797,10 +797,10 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocHost_native - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;IILuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;JJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocHost_1native - (JNIEnv *env, jobject, jlong javaContextPtr, jobject javaHostMemAllocDesc, jint allocSize, jint alignment, jobject javaLevelZeroBuffer) { + (JNIEnv *env, jobject, jlong javaContextPtr, jobject javaHostMemAllocDesc, jlong allocSize, jlong alignment, jobject javaLevelZeroBuffer) { ze_context_handle_t context = reinterpret_cast(javaContextPtr); @@ -829,11 +829,11 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev LOG_ZE_JNI("zeMemAllocHost", result); // Set Buffer Pointer and attributes - jfieldID fieldBufferSize = env->GetFieldID(javaBufferClass, "size", "I"); - jfieldID alignmentField = env->GetFieldID(javaBufferClass, "alignment", "I"); + jfieldID fieldBufferSize = env->GetFieldID(javaBufferClass, "size", "J"); + jfieldID alignmentField = env->GetFieldID(javaBufferClass, "alignment", "J"); env->SetLongField(javaLevelZeroBuffer, fieldBuffer, reinterpret_cast(buffer)); - env->SetIntField(javaLevelZeroBuffer, fieldBufferSize, allocSize); - env->SetIntField(javaLevelZeroBuffer, alignmentField, alignment); + env->SetLongField(javaLevelZeroBuffer, fieldBufferSize, allocSize); + env->SetLongField(javaLevelZeroBuffer, alignmentField, alignment); return result; } \ No newline at end of file diff --git a/levelZeroLib/src/levelZeroContext.h b/levelZeroLib/src/levelZeroContext.h index d5ff713..11bd47c 100644 --- a/levelZeroLib/src/levelZeroContext.h +++ b/levelZeroLib/src/levelZeroContext.h @@ -66,34 +66,34 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocShared_native - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocShared_1native - (JNIEnv *, jobject, jlong, jobject, jobject, jint, jint, jlong, jobject); + (JNIEnv *, jobject, jlong, jobject, jobject, jlong, jlong, jlong, jobject); /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocShared_nativeByte - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;Luk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocShared_1nativeByte - (JNIEnv *, jobject, jlong, jobject, jobject, jint, jint, jlong, jobject); + (JNIEnv *, jobject, jlong, jobject, jobject, jlong, jlong, jlong, jobject); /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocDevice_native - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocDevice_1native - (JNIEnv *, jobject, jlong, jobject, jint, jint, jlong, jobject); + (JNIEnv *, jobject, jlong, jobject, jlong, jlong, jlong, jobject); /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocDevice_nativeLong - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;IIJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeDeviceMemAllocDesc;JJJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocDevice_1nativeLong - (JNIEnv *, jobject, jlong, jobject, jint, jint, jlong, jobject); + (JNIEnv *, jobject, jlong, jobject, jlong, jlong, jlong, jobject); /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext @@ -171,10 +171,10 @@ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_Lev /* * Class: uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext * Method: zeMemAllocHost_native - * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;IILuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I + * Signature: (JLuk/ac/manchester/tornado/drivers/spirv/levelzero/ZeHostMemAllocDesc;JJLuk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer;)I */ JNIEXPORT jint JNICALL Java_uk_ac_manchester_tornado_drivers_spirv_levelzero_LevelZeroContext_zeMemAllocHost_1native - (JNIEnv *, jobject, jlong, jobject, jint, jint, jobject); + (JNIEnv *, jobject, jlong, jobject, jlong, jlong, jobject); #ifdef __cplusplus } #endif diff --git a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger.java b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger.java index cdd5f75..187534f 100644 --- a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger.java +++ b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferInteger.java @@ -36,7 +36,7 @@ public long getPtrBuffer() { return ptrBuffer; } - public void memset(int value, int bufferSize) { + public void memset(int value, long bufferSize) { memset_native(this, value, bufferSize); } @@ -48,7 +48,7 @@ public void initPtr() { this.ptrBuffer = -1; } - native void memset_native(LevelZeroBufferInteger javaBuffer, int value, int bufferSize); + native void memset_native(LevelZeroBufferInteger javaBuffer, int value, long bufferSize); - native boolean isEqual(long bufferAPtr, long bufferBPtr, int size); + native boolean isEqual(long bufferAPtr, long bufferBPtr, long size); } diff --git a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong.java b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong.java index 63a83c4..8eee58a 100644 --- a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong.java +++ b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroBufferLong.java @@ -27,8 +27,8 @@ public class LevelZeroBufferLong { private long ptrBuffer; - private int size; - private int alignment; + private long size; + private long alignment; public LevelZeroBufferLong() { this.ptrBuffer = -1; @@ -44,11 +44,11 @@ public long getPtrBuffer() { return this.ptrBuffer; } - public int getSize() { + public long getSize() { return this.size; } - public int getAlignment() { + public long getAlignment() { return this.alignment; } @@ -79,7 +79,7 @@ public void copy(long[] array) { copy_native(this.ptrBuffer, array); } - private native long[] getLongBuffer_native(long ptrBuffer, int size); + private native long[] getLongBuffer_native(long ptrBuffer, long size); public long[] getLongBuffer() { return getLongBuffer_native(this.ptrBuffer, this.size); diff --git a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer.java b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer.java index 712f3e1..e5cecbb 100644 --- a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer.java +++ b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroByteBuffer.java @@ -27,8 +27,8 @@ public class LevelZeroByteBuffer { private long ptrBuffer; - private int size; - private int alignment; + private long size; + private long alignment; public LevelZeroByteBuffer() { this.ptrBuffer = -1; @@ -44,11 +44,11 @@ public long getPtrBuffer() { return this.ptrBuffer; } - public int getSize() { + public long getSize() { return this.size; } - public int getAlignment() { + public long getAlignment() { return this.alignment; } @@ -78,14 +78,14 @@ public void initPtr() { /** * Copies the input array into the LevelZeroBuffer - * + * * @param array */ public void copy(byte[] array) { copy_native(this.ptrBuffer, array); } - private native byte[] getByteBuffer_native(long ptrBuffer, int size); + private native byte[] getByteBuffer_native(long ptrBuffer, long size); public byte[] getByteBuffer() { return getByteBuffer_native(this.ptrBuffer, this.size); diff --git a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroContext.java b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroContext.java index c8a25e1..2419ead 100644 --- a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroContext.java +++ b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/LevelZeroContext.java @@ -31,6 +31,11 @@ public class LevelZeroContext { ZeContextHandle contextHandle; ZeContextDesc contextDescription; + public LevelZeroContext(ZeDriverHandle driver, ZeContextDesc contextDescription) { + this.driver = driver; + this.contextDescription = contextDescription; + } + native int zeContextCreate(long driverHandler, ZeContextDesc contextDescriptionPtr, long[] contextPtr); public int zeContextCreate(long driverHandler) { @@ -40,11 +45,6 @@ public int zeContextCreate(long driverHandler) { return status; } - public LevelZeroContext(ZeDriverHandle driver, ZeContextDesc contextDescription) { - this.driver = driver; - this.contextDescription = contextDescription; - } - public ZeDriverHandle getDriver() { return driver; } @@ -71,29 +71,30 @@ public int zeCommandListCreateImmediate(long contextPtr, long deviceHandlerPtr, return zeCommandListCreateImmediate_native(contextPtr, deviceHandlerPtr, commandQueueDescription, commandList); } - native int zeMemAllocShared_native(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, int bufferSize, int alignment, long deviceHandlerPtr, + native int zeMemAllocShared_native(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, long bufferSize, long alignment, long deviceHandlerPtr, LevelZeroBufferInteger buffer); - native int zeMemAllocShared_nativeByte(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, int bufferSize, int alignment, long deviceHandlerPtr, + native int zeMemAllocShared_nativeByte(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, long bufferSize, long alignment, long deviceHandlerPtr, LevelZeroByteBuffer buffer); - public int zeMemAllocShared(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, int bufferSize, int alignment, long deviceHandlerPtr, + public int zeMemAllocShared(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, long bufferSize, long alignment, long deviceHandlerPtr, LevelZeroBufferInteger buffer) { return zeMemAllocShared_native(contextPtr, deviceMemAllocDesc, hostMemAllocDesc, bufferSize, alignment, deviceHandlerPtr, buffer); } - public int zeMemAllocShared(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, int bufferSize, int alignment, long deviceHandlerPtr, + public int zeMemAllocShared(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, ZeHostMemAllocDesc hostMemAllocDesc, long bufferSize, long alignment, long deviceHandlerPtr, LevelZeroByteBuffer buffer) { return zeMemAllocShared_nativeByte(contextPtr, deviceMemAllocDesc, hostMemAllocDesc, bufferSize, alignment, deviceHandlerPtr, buffer); } - native int zeMemAllocDevice_native(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, int allocSize, int alignment, long deviceHandlerPtr, LevelZeroByteBuffer deviceBuffer); + native int zeMemAllocDevice_native(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, long allocSize, long alignment, long deviceHandlerPtr, LevelZeroByteBuffer deviceBuffer); - public int zeMemAllocDevice(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, int allocSize, int alignment, long deviceHandlerPtr, LevelZeroByteBuffer deviceBuffer) { + public int zeMemAllocDevice(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, long allocSize, long alignment, long deviceHandlerPtr, LevelZeroByteBuffer deviceBuffer) { return zeMemAllocDevice_native(contextPtr, deviceMemAllocDesc, allocSize, alignment, deviceHandlerPtr, deviceBuffer); } - private native int zeMemAllocDevice_nativeLong(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, int allocSize, int alignment, long deviceHandlerPtr, LevelZeroBufferLong deviceBufferLong); + private native int zeMemAllocDevice_nativeLong(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, long allocSize, long alignment, long deviceHandlerPtr, + LevelZeroBufferLong deviceBufferLong); public int zeMemAllocDevice(long contextPtr, ZeDeviceMemAllocDesc deviceMemAllocDesc, int allocSize, int alignment, long deviceHandlerPtr, LevelZeroBufferLong deviceBufferLong) { return zeMemAllocDevice_nativeLong(contextPtr, deviceMemAllocDesc, allocSize, alignment, deviceHandlerPtr, deviceBufferLong); @@ -268,10 +269,10 @@ public int zeModuleBuildLogGetString(ZeBuildLogHandle buildLog, int[] sizeLog, S *
  • The application may call this function from simultaneous threads.
  • *
  • - The implementation of this function must be thread-safe.
  • * - * - * + * + * * @return Error code: - * + * *

    * ZE_RESULT_SUCCESS *

    @@ -312,7 +313,7 @@ public int zeEventPoolCreate(long defaultContextPtr, ZeEventPoolDescription even /** * Creates an event from the pool. - * + * * Details: *
      *
    • An event is used to communicate fine-grain host-to-device, device-to-host @@ -323,13 +324,13 @@ public int zeEventPoolCreate(long defaultContextPtr, ZeEventPoolDescription even * with the same event pool handle.
    • *
    • The implementation of this function should be lock-free.
    • *
    - * + * * Similar to: - * + * * * clCreateUserEvent, vkCreateEvent * - * + * * @param eventPool * [IN] Handle of the event Pool * @param eventDescription @@ -338,7 +339,7 @@ public int zeEventPoolCreate(long defaultContextPtr, ZeEventPoolDescription even * [out] Object that contains a pointer to handle of event object * created * @return An error code: - * + * *

    * ZE_RESULT_SUCCESS *

    @@ -360,8 +361,8 @@ public int zeEventPoolCreate(long defaultContextPtr, ZeEventPoolDescription even *

    * ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY *

    - * - * + * + * */ public int zeEventCreate(ZeEventPoolHandle eventPool, ZeEventDescription eventDescription, ZeEventHandle event) { return zeEventCreate_native(eventPool, eventDescription, event); @@ -383,9 +384,9 @@ public int zeEventDestroy(ZeEventHandle event) { return result; } - private native int zeMemAllocHost_native(long contextPtr, ZeHostMemAllocDesc hostMemAllocDesc, int allocSize, int alignment, LevelZeroByteBuffer hostBuffer); + private native int zeMemAllocHost_native(long contextPtr, ZeHostMemAllocDesc hostMemAllocDesc, long allocSize, long alignment, LevelZeroByteBuffer hostBuffer); - public int zeMemAllocHost(long contextPtr, ZeHostMemAllocDesc hostMemAllocDesc, int allocSize, int alignment, LevelZeroByteBuffer hostBuffer) { + public int zeMemAllocHost(long contextPtr, ZeHostMemAllocDesc hostMemAllocDesc, long allocSize, long alignment, LevelZeroByteBuffer hostBuffer) { return zeMemAllocHost_native(contextPtr, hostMemAllocDesc, allocSize, alignment, hostBuffer); } diff --git a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/utils/LevelZeroUtils.java b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/utils/LevelZeroUtils.java index 00dbd8a..d7ba164 100644 --- a/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/utils/LevelZeroUtils.java +++ b/src/main/java/uk/ac/manchester/tornado/drivers/spirv/levelzero/utils/LevelZeroUtils.java @@ -62,10 +62,9 @@ public class LevelZeroUtils { - public static final boolean DEBUG = Boolean.parseBoolean(System.getProperties().getProperty("tornado.debug", "False")); - public static final String YELLOW = "\u001B[33m"; - public static final String RESET = "\u001B[0m"; - + public static final boolean DEBUG = Boolean.parseBoolean(System.getProperties().getProperty("tornado.debug", "False")); + public static final String YELLOW = "\u001B[33m"; + public static final String RESET = "\u001B[0m"; /** * Utility for controlling error from a method invoked using the JNI Level Zero @@ -328,6 +327,7 @@ public static long dispatchLookUpBuffer(LevelZeroCommandList commandList, LevelZ if (DEBUG) { System.out.printf(YELLOW + "[SPIRV-V-Runtime] Base Address " + baseAddress + RESET + "%%n"); } + commandList.zeCommandListReset(commandList.getCommandListHandlerPtr()); errorLog("zeCommandListReset", result); return baseAddress;