97 lines
1.7 KiB
Plaintext
Raw Normal View History

2017-04-14 19:02:05 +02:00
#include <iostream>
2020-02-01 23:06:01 +01:00
#include <cuda.h>
#include <cuda_runtime.h>
2018-04-23 21:13:27 +02:00
#include <inc_cuda.h>
#ifndef INC_CUDA
2018-08-09 18:06:22 +02:00
# error "INC_CUDA not defined!"
2018-04-23 21:13:27 +02:00
#endif
2020-08-30 11:54:41 +02:00
#ifdef __NVCC__
# ifndef HOST_DEFINE
# error "HOST_DEFINE not defined!"
# endif
2017-07-20 19:35:53 +02:00
#endif
2017-04-14 19:02:05 +02:00
#ifndef PACKED_DEFINE
2018-08-09 18:06:22 +02:00
# error "PACKED_DEFINE not defined!"
2017-04-14 19:02:05 +02:00
#endif
2018-04-23 21:13:27 +02:00
#ifndef FLAG_COMPILE_LANG_CUDA
2018-08-09 18:06:22 +02:00
# error "FLAG_COMPILE_LANG_CUDA not defined!"
2018-04-23 21:13:27 +02:00
#endif
#ifndef FLAG_LANG_IS_CUDA
2018-08-09 18:06:22 +02:00
# error "FLAG_LANG_IS_CUDA not defined!"
2018-04-23 21:13:27 +02:00
#endif
#if !FLAG_LANG_IS_CUDA
2018-08-09 18:06:22 +02:00
# error "Expected FLAG_LANG_IS_CUDA"
2018-04-23 21:13:27 +02:00
#endif
#ifndef DEF_COMPILE_LANG_CUDA
2018-08-09 18:06:22 +02:00
# error "DEF_COMPILE_LANG_CUDA not defined!"
2018-04-23 21:13:27 +02:00
#endif
#ifndef DEF_LANG_IS_CUDA
2018-08-09 18:06:22 +02:00
# error "DEF_LANG_IS_CUDA not defined!"
2018-04-23 21:13:27 +02:00
#endif
#if !DEF_LANG_IS_CUDA
2018-08-09 18:06:22 +02:00
# error "Expected DEF_LANG_IS_CUDA"
2018-04-23 21:13:27 +02:00
#endif
2019-11-11 23:01:05 +01:00
#ifndef DEF_CUDA_COMPILER
# error "DEF_CUDA_COMPILER not defined!"
#endif
#ifndef DEF_CUDA_COMPILER_VERSION
# error "DEF_CUDA_COMPILER_VERSION not defined!"
#endif
2017-04-14 19:02:05 +02:00
static __global__ void DetermineIfValidCudaDevice()
{
}
#ifdef _MSC_VER
2018-08-09 18:06:22 +02:00
# pragma pack(push, 1)
# undef PACKED_DEFINE
# define PACKED_DEFINE
2017-04-14 19:02:05 +02:00
#endif
struct PACKED_DEFINE result_type
{
bool valid;
int value;
#if defined(NDEBUG) && !defined(DEFREL)
2018-08-09 18:06:22 +02:00
# error missing DEFREL flag
2017-04-14 19:02:05 +02:00
#endif
};
#ifdef _MSC_VER
2018-08-09 18:06:22 +02:00
# pragma pack(pop)
2017-04-14 19:02:05 +02:00
#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;
}