Skip to content

Commit

Permalink
Adds the JNI call for Cuda.deviceSynchronize (#10839)
Browse files Browse the repository at this point in the history
Running tests locally, but putting this up as WIP for now.

Discussing with @jlowe a solution to NVIDIA/spark-rapids#4818 could involve `cudaDeviceSynchronize.` I noticed that's not in our JNI exposed calls, so I am adding it here.

Authors:
  - Alessandro Bellina (https://github.com/abellina)

Approvers:
  - Jason Lowe (https://github.com/jlowe)

URL: #10839
  • Loading branch information
abellina authored May 12, 2022
1 parent e0d94f3 commit 1bb3aac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions java/src/main/java/ai/rapids/cudf/Cuda.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,4 +596,10 @@ public static void multiBufferCopyAsync(long [] destAddrs,
* no effect.
*/
public static native void profilerStop();

/**
* Synchronizes the whole device using cudaDeviceSynchronize.
* @note this is very expensive and should almost never be used
*/
public static native void deviceSynchronize();
}
8 changes: 8 additions & 0 deletions java/src/main/native/src/CudaJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,12 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_Cuda_profilerStop(JNIEnv *env, jclass
CATCH_STD(env, );
}

JNIEXPORT void JNICALL Java_ai_rapids_cudf_Cuda_deviceSynchronize(JNIEnv *env, jclass clazz) {
try {
cudf::jni::auto_set_device(env);
CUDF_CUDA_TRY(cudaDeviceSynchronize());
}
CATCH_STD(env, );
}

} // extern "C"

0 comments on commit 1bb3aac

Please sign in to comment.