summaryrefslogtreecommitdiffstats
path: root/Tests/CudaOnly/WithDefs/main.notcu
blob: 9119eba1124c38e3a4f1d7ff3649c5717d473bc0 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>

#include <cuda.h>
#include <cuda_runtime.h>
#include <inc_cuda.h>
#ifndef INC_CUDA
#  error "INC_CUDA not defined!"
#endif

#ifdef __NVCC__
#  ifndef HOST_DEFINE
#    error "HOST_DEFINE not defined!"
#  endif
#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

#ifndef DEF_CUDA_COMPILER
#  error "DEF_CUDA_COMPILER not defined!"
#endif

#ifndef DEF_CUDA_COMPILER_VERSION
#  error "DEF_CUDA_COMPILER_VERSION not defined!"
#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;
}