ViennaCL - The Vienna Computing Library: viennacl/linalg/detail/bisect/util.hpp Source File

ViennaCL - The Vienna Computing Library 1.7.1 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_DETAIL_BISECT_UTIL_HPP_
2 #define VIENNACL_LINALG_DETAIL_BISECT_UTIL_HPP_
3
4 /* =========================================================================
5 Copyright (c) 2010-2016, Institute for Microelectronics,
6 Institute for Analysis and Scientific Computing,
7 TU Wien.
8 Portions of this software are copyright by UChicago Argonne, LLC.
9
10 -----------------
11 ViennaCL - The Vienna Computing Library
12 -----------------
13
14 Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15
16 (A list of authors and contributors can be found in the manual)
17
18 License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20
21
30 namespace viennacl
31 {
32 namespace linalg
33 {
34 namespace detail
35 {
36
40 template<class T>
41 #ifdef __CUDACC__
42 __host__ __device__
43 #endif
44 T
45 min(const T &lhs, const T &rhs)
46 {
47
48 return (lhs < rhs) ? lhs : rhs;
49 }
50
54 template<class T>
55 #ifdef __CUDACC__
56 __host__ __device__
57 #endif
58 T
59 max(const T &lhs, const T &rhs)
60 {
61
62 return (lhs < rhs) ? rhs : lhs;
63 }
64
68 #ifdef __CUDACC__
69 __host__ __device__
70 #endif
71 inline float
72 sign_f(const float &val)
73 {
74 return (val < 0.0f) ? -1.0f : 1.0f;
75 }
76
80 #ifdef __CUDACC__
81 __host__ __device__
82 #endif
83 inline double
84 sign_d(const double &val)
85 {
86 return (val < 0.0) ? -1.0 : 1.0;
87 }
88
93 extern "C"
94 inline
95 unsigned int
96 getNumBlocksLinear(const unsigned int num_threads,
97 const unsigned int num_threads_block)
98 {
99 const unsigned int block_rem =
100 ((num_threads % num_threads_block) != 0) ? 1 : 0;
101 return (num_threads / num_threads_block) + block_rem;
102 }
103 } // namespace detail
104 } // namespace linalg
105 } // namespace viennacl
106 #endif // #ifndef VIENNACL_LINALG_DETAIL_UTIL_HPP_
viennacl::linalg::detail::max
T max(const T &lhs, const T &rhs)
Maximum.
Definition: util.hpp:59
viennacl::linalg::detail::sign_d
double sign_d(const double &val)
Sign of number (double)
Definition: util.hpp:84
viennacl::linalg::detail::getNumBlocksLinear
unsigned int getNumBlocksLinear(const unsigned int num_threads, const unsigned int num_threads_block)
Definition: util.hpp:96
viennacl::linalg::detail::sign_f
float sign_f(const float &val)
Sign of number (float)
Definition: util.hpp:72
viennacl::linalg::detail::min
T min(const T &lhs, const T &rhs)
Minimum.
Definition: util.hpp:45