Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
7a08bbbc
Commit
7a08bbbc
authored
Feb 26, 2013
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add CUDA_GENERATION macro
parent
0e5255d4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
2 deletions
+57
-2
OpenCVDetectCUDA.cmake
cmake/OpenCVDetectCUDA.cmake
+42
-2
OpenCVDetectCudaArch.cu
cmake/OpenCVDetectCudaArch.cu
+15
-0
No files found.
cmake/OpenCVDetectCUDA.cmake
View file @
7a08bbbc
...
...
@@ -33,8 +33,48 @@ if(CUDA_FOUND)
message
(
STATUS
"CUDA detected: "
${
CUDA_VERSION
}
)
set
(
CUDA_ARCH_BIN
"1.1 1.2 1.3 2.0 2.1(2.0) 3.0"
CACHE STRING
"Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported"
)
set
(
CUDA_ARCH_PTX
"2.0 3.0"
CACHE STRING
"Specify 'virtual' PTX architectures to build PTX intermediate code for"
)
set
(
_generations
"Fermi"
"Kepler"
)
if
(
NOT CMAKE_CROSSCOMPILING
)
list
(
APPEND _generations
"Auto"
)
endif
()
set
(
CUDA_GENERATION
""
CACHE STRING
"Build CUDA device code only for specific GPU architecture. Leave empty to build for all architectures."
)
if
(
CMAKE_VERSION VERSION_GREATER
"2.8"
)
set_property
(
CACHE CUDA_GENERATION PROPERTY STRINGS
""
${
_generations
}
)
endif
()
if
(
CUDA_GENERATION
)
if
(
NOT
";
${
_generations
}
;"
MATCHES
";
${
CUDA_GENERATION
}
;"
)
string
(
REPLACE
";"
", "
_generations
"
${
_generations
}
"
)
message
(
FATAL_ERROR
"ERROR:
${
_generations
}
Generations are suppered."
)
endif
()
unset
(
CUDA_ARCH_BIN CACHE
)
unset
(
CUDA_ARCH_PTX CACHE
)
endif
()
set
(
__cuda_arch_ptx
""
)
if
(
CUDA_GENERATION STREQUAL
"Fermi"
)
set
(
__cuda_arch_bin
"2.0 2.1(2.0)"
)
elseif
(
CUDA_GENERATION STREQUAL
"Kepler"
)
set
(
__cuda_arch_bin
"3.0"
)
elseif
(
CUDA_GENERATION STREQUAL
"Auto"
)
execute_process
(
COMMAND
"
${
CUDA_NVCC_EXECUTABLE
}
"
"
${
OpenCV_SOURCE_DIR
}
/cmake/OpenCVDetectCudaArch.cu"
"--run"
WORKING_DIRECTORY
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeTmp/"
RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
NOT _nvcc_res EQUAL 0
)
message
(
STATUS
"Automatic detection of CUDA generation failed. Going to build for all known architectures."
)
else
()
set
(
__cuda_arch_bin
"
${
_nvcc_out
}
"
)
endif
()
endif
()
if
(
NOT DEFINED __cuda_arch_bin
)
set
(
__cuda_arch_bin
"1.1 1.2 1.3 2.0 2.1(2.0) 3.0"
)
set
(
__cuda_arch_ptx
"2.0 3.0"
)
endif
()
set
(
CUDA_ARCH_BIN
${
__cuda_arch_bin
}
CACHE STRING
"Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported"
)
set
(
CUDA_ARCH_PTX
${
__cuda_arch_ptx
}
CACHE STRING
"Specify 'virtual' PTX architectures to build PTX intermediate code for"
)
string
(
REGEX REPLACE
"
\\
."
""
ARCH_BIN_NO_POINTS
"
${
CUDA_ARCH_BIN
}
"
)
string
(
REGEX REPLACE
"
\\
."
""
ARCH_PTX_NO_POINTS
"
${
CUDA_ARCH_PTX
}
"
)
...
...
cmake/OpenCVDetectCudaArch.cu
0 → 100644
View file @
7a08bbbc
#include <stdio.h>
int main()
{
int count = 0;
if (cudaSuccess != cudaGetDeviceCount(&count)){return -1;}
if (count == 0) {return -1;}
for (int device = 0; device < count; ++device)
{
cudaDeviceProp prop;
if (cudaSuccess != cudaGetDeviceProperties(&prop, device)){ continue;}
printf("%d.%d ", prop.major, prop.minor);
}
return 0;
}
\ No newline at end of file
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