forked from carlren/ORUtils
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlatformIndependence.h
executable file
·44 lines (37 loc) · 1.05 KB
/
PlatformIndependence.h
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
// Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM
#pragma once
#if !defined(__METALC__)
#include <cstdio>
#include <stdexcept>
#endif
#if defined(__CUDACC__) && defined(__CUDA_ARCH__)
#define _CPU_AND_GPU_CODE_ __device__ // for CUDA device code
#else
#define _CPU_AND_GPU_CODE_
#endif
#if defined(__CUDACC__)
#define _CPU_AND_GPU_CODE_TEMPLATE_ __device__ // for CUDA device code
#else
#define _CPU_AND_GPU_CODE_TEMPLATE_
#endif
#if defined(__CUDACC__) && defined(__CUDA_ARCH__)
#define _CPU_AND_GPU_CONSTANT_ __constant__ // for CUDA device code
#else
#define _CPU_AND_GPU_CONSTANT_
#endif
#if defined(__METALC__) // for METAL device code
#define THREADPTR(x) thread x
#define DEVICEPTR(x) device x
#define THREADGRPPTR(x) threadgroup x
#define CONSTPTR(x) constant x
#else
#define THREADPTR(x) x
#define DEVICEPTR(x) x
#define THREADGROUPPTR(x) x
#define CONSTPTR(x) x
#endif
#ifdef ANDROID
#define DIEWITHEXCEPTION(x) { fprintf(stderr, "%s\n", x); exit(-1); }
#else
#define DIEWITHEXCEPTION(x) throw std::runtime_error(x)
#endif