Commit 2abb70b1 authored by Andreas Marek's avatar Andreas Marek

Add cudaThreadSynchronize Fortran wrapper

parent 2c4387dd
...@@ -69,6 +69,17 @@ ...@@ -69,6 +69,17 @@
#ifdef WITH_GPU_VERSION #ifdef WITH_GPU_VERSION
extern "C" { extern "C" {
int cudaThreadSynchronizeFromC() {
cudaError_t cuerr = cudaThreadSynchronize();
if (cuerr != cudaSuccess) {
errormessage("Error in cudaThreadSynchronize: %s\n",cudaGetErrorString(cuerr));
return 0;
}
return 1;
}
int cudaSetDeviceFromC(int n) { int cudaSetDeviceFromC(int n) {
cudaError_t cuerr = cudaSetDevice(n); cudaError_t cuerr = cudaSetDevice(n);
......
...@@ -67,6 +67,15 @@ module cuda_functions ...@@ -67,6 +67,15 @@ module cuda_functions
! functions to set and query the CUDA devices ! functions to set and query the CUDA devices
interface
function cuda_threadsynchronize_c() result(istat) &
bind(C,name="cudaThreadSynchronizeFromC")
use iso_c_binding
implicit none
integer(kind=C_INT) :: istat
end function cuda_threadsynchronize_c
end interface
interface interface
function cuda_setdevice_c(n) result(istat) & function cuda_setdevice_c(n) result(istat) &
bind(C, name="cudaSetDeviceFromC") bind(C, name="cudaSetDeviceFromC")
...@@ -407,6 +416,19 @@ module cuda_functions ...@@ -407,6 +416,19 @@ module cuda_functions
! functions to set and query the CUDA devices ! functions to set and query the CUDA devices
function cuda_threadsynchronize() result(success)
use iso_c_binding
implicit none
logical :: success
#ifdef WITH_GPU_VERSION
success = cuda_threadsynchronize_c() /= 0
#else
success = .true.
#endif
end function cuda_threadsynchronize
function cuda_setdevice(n) result(success) function cuda_setdevice(n) result(success)
use iso_c_binding use iso_c_binding
...@@ -560,7 +582,6 @@ module cuda_functions ...@@ -560,7 +582,6 @@ module cuda_functions
#endif #endif
end function end function
function cuda_memcpy(dst, src, size, dir) result(success) function cuda_memcpy(dst, src, size, dir) result(success)
use iso_c_binding use iso_c_binding
...@@ -571,6 +592,7 @@ module cuda_functions ...@@ -571,6 +592,7 @@ module cuda_functions
integer(kind=C_SIZE_T), intent(in) :: size integer(kind=C_SIZE_T), intent(in) :: size
integer(kind=C_INT), intent(in) :: dir integer(kind=C_INT), intent(in) :: dir
logical :: success logical :: success
#ifdef WITH_GPU_VERSION #ifdef WITH_GPU_VERSION
success = cuda_memcpy_c(dst, src, size, dir) /= 0 success = cuda_memcpy_c(dst, src, size, dir) /= 0
#else #else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment