-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5a4880
commit 71186d3
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#---------------------------------------------------------------------------------------------------------------------- | ||
# | ||
#---------------------------------------------------------------------------------------------------------------------- | ||
project(CommandLineCuda LANGUAGES CXX CUDA) | ||
|
||
add_executable(CommandLineCuda | ||
main.cu | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//--------------------------------------------------------------------------------------------------------------------- | ||
// | ||
//--------------------------------------------------------------------------------------------------------------------- | ||
#include <cuda.h> | ||
#include <cuda_runtime.h> | ||
#include <exception> | ||
#include <iostream> | ||
|
||
int main(int, char**) | ||
{ | ||
try | ||
{ | ||
int deviceCount = 0; | ||
cudaError_t error_id = cudaGetDeviceCount(&deviceCount); | ||
if (error_id != cudaSuccess) | ||
{ | ||
std::cerr << "cudaGetDeviceCount returned " << static_cast<int>(error_id) << ".\n" | ||
<< " -> " << cudaGetErrorString(error_id) << "\n"; | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
std::cout << "Detected " << deviceCount << " CUDA capable device(s)\n"; | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
std::cerr << "Exception: " << ex.what(); | ||
} | ||
} |