Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
83889f1e
Commit
83889f1e
authored
Feb 19, 2010
by
Christopher Bruns
Browse files
Added some cmake to avoid running CUDA tests on non-gpu machines.
So far tested only on GPU-having windows machine.
parent
f61903c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
platforms/cuda/CMakeLists.txt
platforms/cuda/CMakeLists.txt
+23
-1
platforms/cuda/tests/has_cuda_gpu.c
platforms/cuda/tests/has_cuda_gpu.c
+20
-0
No files found.
platforms/cuda/CMakeLists.txt
View file @
83889f1e
...
...
@@ -14,7 +14,29 @@
# libOpenMMCuda_static[_d].a
#----------------------------------------------------
SUBDIRS
(
tests
)
# Only run tests if this machine has a cuda-capable GPU
# So run a little test program at configuration time to sniff for GPUs
find_package
(
CUDA
)
try_run
(
RUN_RESULT_VAR COMPILE_RESULT_VAR
${
CMAKE_BINARY_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/tests/has_cuda_gpu.c
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=
${
CUDA_TOOLKIT_INCLUDE
}
-DLINK_LIBRARIES:STRING=
${
CUDA_CUDART_LIBRARY
}
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR
RUN_OUTPUT_VARIABLE RUN_OUTPUT_VAR
)
message
(
"
${
RUN_OUTPUT_VAR
}
"
)
# Display number of GPUs found
# COMPILE_RESULT_VAR is TRUE when compile succeeds
# RUN_RESULT_VAR is equal to the number of GPUs found
if
(
COMPILE_RESULT_VAR AND RUN_RESULT_VAR
)
set
(
CUDA_HAVE_GPU TRUE CACHE BOOL
"Whether CUDA-capable GPU is present"
)
else
()
set
(
CUDA_HAVE_GPU FALSE CACHE BOOL
"Whether CUDA-capable GPU is present"
)
endif
()
if
(
CUDA_HAVE_GPU
)
SUBDIRS
(
tests
)
endif
(
CUDA_HAVE_GPU
)
# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
...
...
platforms/cuda/tests/has_cuda_gpu.c
0 → 100644
View file @
83889f1e
#include <stdio.h>
#include <cuda_runtime.h>
int
main
()
{
int
deviceCount
,
device
;
int
gpuDeviceCount
=
0
;
struct
cudaDeviceProp
properties
;
cudaError_t
cudaResultCode
=
cudaGetDeviceCount
(
&
deviceCount
);
if
(
cudaResultCode
!=
cudaSuccess
)
deviceCount
=
0
;
for
(
device
=
0
;
device
<
deviceCount
;
++
device
)
{
cudaGetDeviceProperties
(
&
properties
,
device
);
if
(
properties
.
major
!=
9999
)
/* 9999 means emulation only */
++
gpuDeviceCount
;
}
printf
(
"%d GPU CUDA device(s) found
\n
"
,
gpuDeviceCount
);
return
gpuDeviceCount
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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