-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (25 loc) · 790 Bytes
/
main.cpp
File metadata and controls
32 lines (25 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cuda.h>
#include <cuda_runtime.h>
#include <sstream>
#include <exception>
#include <cstdio>
#define CUDA_CHECK( call ) cudaCheck( call, #call, __FILE__, __LINE__ )
void cudaCheck( CUresult result, const char* expr, const char* file, unsigned int line )
{
if( result != CUDA_SUCCESS )
{
const char* errorStr;
cuGetErrorString( result, &errorStr );
std::stringstream ss;
ss << "CUDA call (" << expr << " ) failed with error: '" << errorStr << "' (" << file << ":" << line << ")\n";
throw std::runtime_error( ss.str() );
}
}
int main()
{
cudaFree(nullptr);
printf( "Calling cuModuleLoad( ..., \"%s\" )\n", PTX_FILENAME );
CUmodule module;
CUDA_CHECK( cuModuleLoad( &module, PTX_FILENAME ) );
return 0;
}