1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include <cuda.h>
- #include <cuda_runtime.h>
- #include <iostream>
- #include <inc_cuda.h>
- #ifndef INC_CUDA
- #error "INC_CUDA not defined!"
- #endif
- #ifndef HOST_DEFINE
- #error "HOST_DEFINE not defined!"
- #endif
- #ifndef PACKED_DEFINE
- #error "PACKED_DEFINE not defined!"
- #endif
- #ifndef FLAG_COMPILE_LANG_CUDA
- #error "FLAG_COMPILE_LANG_CUDA not defined!"
- #endif
- #ifndef FLAG_LANG_IS_CUDA
- #error "FLAG_LANG_IS_CUDA not defined!"
- #endif
- #if !FLAG_LANG_IS_CUDA
- #error "Expected FLAG_LANG_IS_CUDA"
- #endif
- #ifndef DEF_COMPILE_LANG_CUDA
- #error "DEF_COMPILE_LANG_CUDA not defined!"
- #endif
- #ifndef DEF_LANG_IS_CUDA
- #error "DEF_LANG_IS_CUDA not defined!"
- #endif
- #if !DEF_LANG_IS_CUDA
- #error "Expected DEF_LANG_IS_CUDA"
- #endif
- static __global__ void DetermineIfValidCudaDevice()
- {
- }
- #ifdef _MSC_VER
- #pragma pack(push, 1)
- #undef PACKED_DEFINE
- #define PACKED_DEFINE
- #endif
- struct PACKED_DEFINE result_type
- {
- bool valid;
- int value;
- #if defined(NDEBUG) && !defined(DEFREL)
- #error missing DEFREL flag
- #endif
- };
- #ifdef _MSC_VER
- #pragma pack(pop)
- #endif
- result_type can_launch_kernel()
- {
- result_type r;
- DetermineIfValidCudaDevice<<<1, 1>>>();
- r.valid = (cudaSuccess == cudaGetLastError());
- if (r.valid) {
- r.value = 1;
- } else {
- r.value = -1;
- }
- return r;
- }
- int main(int argc, char** argv)
- {
- cudaError_t err;
- int nDevices = 0;
- err = cudaGetDeviceCount(&nDevices);
- if (err != cudaSuccess) {
- std::cerr << cudaGetErrorString(err) << std::endl;
- return 1;
- }
- return 0;
- }
|