cheshirekow  v0.1.0
intrinsics.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_DUBINS_CURVES_CUDA_INTRINSICS_H_
28 #define MPBLOCKS_DUBINS_CURVES_CUDA_INTRINSICS_H_
29 
30 #ifdef __CUDACC__
31 #ifdef __CUDA_ARCH__
32 #define WHICH_CUDA intr::DEVICE
33 #else
34 #define WHICH_CUDA intr::HOST
35 #endif
36 #else
37 #define WHICH_CUDA intr::NATIVE
38 #endif
39 
40 #include <cuda_runtime.h>
41 #include <mpblocks/cuda/linalg2.h>
42 
43 namespace mpblocks {
44 namespace dubins {
45 namespace curves_cuda {
46 
47 // provides overloads for cuda intrinsics for generic programming
48 namespace intr {
49 
51 
52 // defeault template calls std functions
53 template <Trajectory>
54 struct Dispatch {
55  __host__ static double sin(double x) { return std::sin(x); }
56  __host__ static float sin(float x) { return std::sin(x); }
57  __host__ static double cos(double x) { return std::cos(x); }
58  __host__ static float cos(float x) { return std::cos(x); }
59  __host__ static double acos(double x) { return std::acos(x); }
60  __host__ static float acos(float x) { return std::acos(x); }
61  __host__ static double atan2(double x, double y) { return std::atan2(x, y); }
62  __host__ static float atan2(float x, float y) { return std::atan2(x, y); }
63 };
64 
65 // specialization for device calls device functions
66 template <>
67 struct Dispatch<DEVICE> {
68  __device__ static double sin(double x) { return ::sin(x); }
69  __device__ static float sin(float x) { return __sinf(x); }
70  __device__ static double cos(double x) { return ::cos(x); }
71  __device__ static float cos(float x) { return __cosf(x); }
72  __device__ static double acos(double x) { return ::acos(x); }
73  __device__ static float acos(float x) { return ::acosf(x); }
74  __device__ static double atan2(double x, double y) { return ::atan2(x, y); }
75  __device__ static float atan2(float x, double y) { return ::atan2f(x, y);}
76 };
77 
78 } // intrinsics
79 } // curves
80 } // dubins
81 } // mpblocks
82 
83 #endif // INTRINSICS_H_
static __host__ float acos(float x)
Definition: intrinsics.h:60
static __host__ float sin(float x)
Definition: intrinsics.h:56
static __device__ double acos(double x)
Definition: intrinsics.h:72
static __host__ double atan2(double x, double y)
Definition: intrinsics.h:61
static __device__ double sin(double x)
Definition: intrinsics.h:68
static __host__ float cos(float x)
Definition: intrinsics.h:58
static __host__ float atan2(float x, float y)
Definition: intrinsics.h:62
static __host__ double cos(double x)
Definition: intrinsics.h:57
#define __device__
Definition: fakecuda.h:34
static __host__ double sin(double x)
Definition: intrinsics.h:55
static __device__ float atan2(float x, double y)
Definition: intrinsics.h:75
#define __host__
Definition: fakecuda.h:37
static __device__ double atan2(double x, double y)
Definition: intrinsics.h:74
static __device__ double cos(double x)
Definition: intrinsics.h:70
static __host__ double acos(double x)
Definition: intrinsics.h:59