Commit d900a3e1 authored by Pavel Kus's avatar Pavel Kus

doing GPU initialization for the first time only

The GPU initialization is actually quite constly, e.g. on Minsky it
takes roughly 0.7s. That is hurting performance for small matrices.
Thus a check has been added and now GPU should be initialized only the
first time.
parent c14f2990
......@@ -62,6 +62,19 @@ module mod_check_for_gpu
gpuAvailable = .false.
if(cublasHandle .ne. -1) then
gpuAvailable = .true.
numberOfDevices = -1
if(myid == 0) then
print *, "Skipping GPU init, should have already been initialized "
endif
return
else
if(myid == 0) then
print *, "Initializing the GPU devices"
endif
endif
if (.not.(present(wantDebug))) then
wantDebugMessage = .false.
else
......
......@@ -55,7 +55,8 @@ module cuda_functions
integer(kind=ik) :: cudaHostRegisterMapped
integer(kind=ik) :: cudaMemcpyDeviceToDevice
integer(kind=C_intptr_T) :: cublasHandle
! TODO global variable, has to be changed
integer(kind=C_intptr_T) :: cublasHandle = -1
integer(kind=c_intptr_t), parameter :: size_of_double_real = 8_rk8
#ifdef WANT_SINGLE_PRECISION_REAL
......
......@@ -220,10 +220,10 @@ function elpa_solve_evp_&
wantDebug = debug == 1
do_useGPU = .false.
if (useGPU) then
call obj%timer%start("check_for_gpu")
if (check_for_gpu(my_pe,numberOfGPUDevices, wantDebug=wantDebug)) then
do_useGPU = .true.
! set the neccessary parameters
cudaMemcpyHostToDevice = cuda_memcpyHostToDevice()
......@@ -236,8 +236,10 @@ function elpa_solve_evp_&
success = .false.
return
endif
call obj%timer%stop("check_for_gpu")
endif
do_useGPU_tridiag = do_useGPU
do_useGPU_solve_tridi = do_useGPU
do_useGPU_trans_ev = do_useGPU
......
......@@ -239,6 +239,7 @@
do_useGPU = .false.
if (useGPU) then
call obj%timer%start("check_for_gpu")
if (check_for_gpu(my_pe,numberOfGPUDevices, wantDebug=wantDebug)) then
do_useGPU = .true.
......@@ -254,6 +255,7 @@
success = .false.
return
endif
call obj%timer%stop("check_for_gpu")
endif
do_useGPU_bandred = do_useGPU
......
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