Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
elpa
elpa
Commits
924b2848
Commit
924b2848
authored
Jun 10, 2021
by
Andreas Marek
Browse files
Check that user does not specify GPU outside of range
parent
1ab373e1
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/GPU/check_for_gpu.F90
View file @
924b2848
...
...
@@ -84,6 +84,36 @@ module mod_check_for_gpu
stop
endif
success
=
.true.
numberOfDevices
=
-1
#ifdef WITH_NVIDIA_GPU_VERSION
! call getenv("CUDA_PROXY_PIPE_DIRECTORY", envname)
success
=
cuda_getdevicecount
(
numberOfDevices
)
#endif
#ifdef WITH_AMD_GPU_VERSION
! call getenv("CUDA_PROXY_PIPE_DIRECTORY", envname)
success
=
hip_getdevicecount
(
numberOfDevices
)
#endif
if
(
.not.
(
success
))
then
#ifdef WITH_NVIDIA_GPU_VERSION
print
*
,
"error in cuda_getdevicecount"
#endif
#ifdef WITH_AMD_GPU_VERSION
print
*
,
"error in hip_getdevicecount"
#endif
stop
1
endif
#ifdef WITH_INTEL_GPU_VERSION
gpuAvailable
=
.false.
numberOfDevices
=
-1
numberOfDevices
=
1
print
*
,
"Manually setting"
,
numberOfDevices
,
" of GPUs"
if
(
numberOfDevices
.ge.
1
)
then
gpuAvailable
=
.true.
endif
#endif
if
(
obj
%
is_set
(
"use_gpu_id"
)
==
1
)
then
call
obj
%
get
(
"use_gpu_id"
,
use_gpu_id
,
error
)
if
(
use_gpu_id
==
-99
)
then
...
...
@@ -110,6 +140,12 @@ module mod_check_for_gpu
endif
endif
if
(
use_gpu_id
+1
.gt.
numberOfDevices
)
then
print
*
,
"Task="
,
myid
,
" wants to use GPU id="
,
use_gpu_id
,
" allowed (0:#GPUs-1)"
print
*
,
"However, there are only "
,
numberOfDevices
,
" on the node"
stop
1
endif
success
=
.true.
#ifdef WITH_NVIDIA_GPU_VERSION
success
=
cuda_setdevice
(
use_gpu_id
)
...
...
test/Fortran/test.F90
View file @
924b2848
...
...
@@ -689,7 +689,8 @@ program test
#if (TEST_GPU_SET_ID == 1) && (TEST_INTEL_GPU == 0)
! simple test
! Can (and should) fail often
gpuID
=
mod
(
myid
,
2
)
!gpuID = mod(myid,2)
gpuID
=
mod
(
myid
,
1
)
print
*
,
"Task"
,
myid
,
"wants to use GPU"
,
gpuID
call
e
%
set
(
"use_gpu_id"
,
int
(
gpuID
,
kind
=
c_int
),
error_elpa
)
assert_elpa_ok
(
error_elpa
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment