Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cuda
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
hello-world
cuda
Commits
67b753f5
Commit
67b753f5
authored
Nov 12, 2020
by
Erik Strand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CUDA test app
parent
1ed3a695
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
Makefile
Makefile
+2
-0
get_gpu_info.cu
get_gpu_info.cu
+50
-0
No files found.
Makefile
0 → 100644
View file @
67b753f5
get_gpu_info
:
get_gpu_info.cu
nvcc get_gpu_info.cu
-o
get_gpu_info
get_gpu_info.cu
0 → 100644
View file @
67b753f5
#include <iostream>
int
main
()
{
int
n_gpus
;
cudaGetDeviceCount
(
&
n_gpus
);
if
(
n_gpus
==
0
)
{
std
::
cout
<<
"Found no NVIDIA GPUs.
\n
"
;
return
0
;
}
if
(
n_gpus
==
1
)
{
std
::
cout
<<
"Found 1 NVIDIA GPU.
\n\n
"
;
}
if
(
n_gpus
>
1
)
{
std
::
cout
<<
"Lucky you, you have "
<<
n_gpus
<<
" GPUs.
\n\n
"
;
}
for
(
int
i
=
0
;
i
<
n_gpus
;
++
i
)
{
// This struct has many other fields too.
// https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html
cudaDeviceProp
prop
;
cudaGetDeviceProperties
(
&
prop
,
i
);
std
::
cout
<<
"GPU "
<<
i
<<
":
\n
"
;
std
::
cout
<<
" name: "
<<
prop
.
name
<<
'\n'
;
std
::
cout
<<
" compute capability: "
<<
prop
.
major
<<
'.'
<<
prop
.
minor
<<
'\n'
;
std
::
cout
<<
" global memory: "
<<
prop
.
totalGlobalMem
<<
" bytes
\n
"
;
std
::
cout
<<
" constant memory: "
<<
prop
.
totalConstMem
<<
" bytes
\n
"
;
std
::
cout
<<
" L2 cache: "
<<
prop
.
l2CacheSize
<<
" bytes
\n
"
;
std
::
cout
<<
" shared memory per block: "
<<
prop
.
sharedMemPerBlock
<<
" bytes
\n
"
;
std
::
cout
<<
" shared memory per multiprocessor: "
<<
prop
.
sharedMemPerMultiprocessor
<<
" bytes
\n
"
;
std
::
cout
<<
" registers per block: "
<<
prop
.
regsPerBlock
<<
'\n'
;
std
::
cout
<<
" registers per multiprocessor: "
<<
prop
.
regsPerMultiprocessor
<<
'\n'
;
std
::
cout
<<
" multiprocessor count: "
<<
prop
.
multiProcessorCount
<<
'\n'
;
std
::
cout
<<
" max threads per multiprocessor: "
<<
prop
.
maxThreadsPerMultiProcessor
<<
'\n'
;
std
::
cout
<<
" max blocks per multiprocessor: "
<<
prop
.
maxBlocksPerMultiProcessor
<<
'\n'
;
std
::
cout
<<
" max grid size: "
<<
prop
.
maxGridSize
[
0
]
<<
" x "
<<
prop
.
maxGridSize
[
1
]
<<
" x "
<<
prop
.
maxGridSize
[
2
]
<<
'\n'
;
std
::
cout
<<
" max threads dim: "
<<
prop
.
maxThreadsDim
[
0
]
<<
" x "
<<
prop
.
maxThreadsDim
[
1
]
<<
" x "
<<
prop
.
maxThreadsDim
[
2
]
<<
'\n'
;
std
::
cout
<<
" max threads per block: "
<<
prop
.
maxThreadsPerBlock
<<
'\n'
;
std
::
cout
<<
'\n'
;
}
return
0
;
}
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