-
Notifications
You must be signed in to change notification settings - Fork 0
Home
pascal edited this page Mar 4, 2024
·
13 revisions
Welcome to the kuda-12.2 wiki!
Following Semantic Versioning (major.minor.patch)
- develop : merge many githubid branches develop branch is the newest code (for versioning branch)
- githubid : it is personal-common branch for kudakit organization members
/**
* Function Description (cudaFunctionName)
*
* @param param Parameter Description
*
* @return Return Description
*/
external fun functionName(type : Type) : Type
for example,
/**
* Sets the event for an event wait node in the given graphExec. (cuGraphExecEventWaitNodeSetEvent)
*
* @param hGraphExec The executable graph in which to set the specified node
* @param hNode event wait node from the graph from which graphExec was instantiated
* @param event Updated event to use
*/
external fun graphExecEventWaitNodeSetEvent(hGraphExec : Long, hNode : Long, event : Long) : Int
for example 1, Here is code that needs cleaning up
JNIEXPORT jlong JNICALL Java_kuda_runtimeapi_DeviceHandler_getDefaultMemPool(JNIEnv* env, jclass cls, jint device) {
cudaMemPool_t memPool;
cudaError_t cudaStatus = cudaDeviceGetMemPool(&memPool, (int)device);
if (cudaStatus != cudaSuccess) {
return cudaStatus;
}
return (jlong)memPool;
}
remove type casting in 'same data type (jint<->int, jlong<->long, etc..)'
JNIEXPORT jlong JNICALL Java_kuda_runtimeapi_DeviceHandler_getDefaultMemPool(JNIEnv* env, jclass cls, jint device) {
cudaMemPool_t memPool;
cudaError_t cudaStatus = cudaDeviceGetMemPool(&memPool, device);
if (cudaStatus != cudaSuccess) {
return cudaStatus;
}
return (jlong)memPool;
}
example 2, before
JNIEXPORT jint JNICALL Java_kuda_kublas_Kublas_getPointerMode(JNIEnv* env, jobject obj, jlong handle) {
//initialize...
cublasPointerMode_t cublasPointerMode = CUBLAS_POINTER_MODE_HOST;
cublasHandle_t cublasHandle = reinterpret_cast<cublasHandle_t>(handle);
cublasStatus_t cublasStatus = cublasGetPointerMode(cublasHandle, &cublasPointerMode);
if (cublasStatus != CUBLAS_STATUS_SUCCESS) {
return cublasStatus;
}
return (jint)static_cast<int>(cublasPointerMode);
}
after
JNIEXPORT jint JNICALL Java_kuda_kublas_Kublas_getPointerMode(JNIEnv* env, jobject obj, jlong handle) {
//initialize...
cublasPointerMode_t cublasPointerMode = CUBLAS_POINTER_MODE_HOST;
cublasHandle_t cublasHandle = reinterpret_cast<cublasHandle_t>(handle);
cublasStatus_t cublasStatus = cublasGetPointerMode(cublasHandle, &cublasPointerMode);
if (cublasStatus != CUBLAS_STATUS_SUCCESS) {
return cublasStatus;
}
return static_cast<int>(cublasPointerMode);
}
example. Lets write kotlin enum class for CUDA CUmemAllocationCompType enum
enum CUmemAllocationCompType : Specifies compression attribute for an allocation.
Values
- CU_MEM_ALLOCATION_COMP_NONE = 0x0
- CU_MEM_ALLOCATION_COMP_GENERIC = 0x1
Use a Integer value
enum class MemAllocationCompType(val num : Int) {
NONE(0x0),
GENERIC(0x1)
}
/**
*
* Descriptions (CUDA Enum name)
*
* @property PROPERTY Property Descriptions
*/
enum class IpcMemFlags(val num : Int) {
PROPERTY(0)
}
for example,
/**
*
* CUDA Ipc Mem Flags (CUipcMem_flags)
*
* @property LAZY_ENABLE_PEER_ACCESS Automatically enable peer access between remote devices as needed
*/
enum class IpcMemFlags(val num : Int) {
LAZY_ENABLE_PEER_ACCESS(0x1)
}