File: main.hip.cpp

package info (click to toggle)
cmake 4.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,336 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (93 lines) | stat: -rw-r--r-- 1,656 bytes parent folder | download | duplicates (3)
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
#include <iostream>

#include <hip/hip_runtime_api.h>
#include <inc_hip.h>
#ifndef INC_HIP
#  error "INC_HIP not defined!"
#endif

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

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

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

#if !FLAG_LANG_IS_HIP
#  error "Expected FLAG_LANG_IS_HIP"
#endif

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

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

#if !DEF_LANG_IS_HIP
#  error "Expected DEF_LANG_IS_HIP"
#endif

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

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

static __global__ void DetermineIfValidHIPDevice()
{
}

#ifdef _MSC_VER
#  pragma pack(push, 1)
#  undef PACKED_DEFINE
#  define PACKED_DEFINE
#endif
#ifdef __NVCC__
#  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;
  DetermineIfValidHIPDevice<<<1, 1>>>();
  r.valid = (hipSuccess == hipGetLastError());
  if (r.valid) {
    r.value = 1;
  } else {
    r.value = -1;
  }
  return r;
}

int main(int argc, char** argv)
{
  hipError_t err;
  int nDevices = 0;
  err = hipGetDeviceCount(&nDevices);
  if (err != hipSuccess) {
    std::cerr << hipGetErrorString(err) << std::endl;
    return 1;
  }
  return 0;
}