All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.hpp
Go to the documentation of this file.
#ifndef VIENNACL_LINALG_DETAIL_BISECT_UTIL_HPP_
#define VIENNACL_LINALG_DETAIL_BISECT_UTIL_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
namespace viennacl
{
namespace linalg
{
namespace detail
{
template<class T>
#ifdef __CUDACC__
__host__ __device__
#endif
T
min(const T &lhs, const T &rhs)
{
return (lhs < rhs) ? lhs : rhs;
}
template<class T>
#ifdef __CUDACC__
__host__ __device__
#endif
T
max(const T &lhs, const T &rhs)
{
return (lhs < rhs) ? rhs : lhs;
}
#ifdef __CUDACC__
__host__ __device__
#endif
inline float
sign_f(const float &val)
{
return (val < 0.0f) ? -1.0f : 1.0f;
}
#ifdef __CUDACC__
__host__ __device__
#endif
inline double
sign_d(const double &val)
{
return (val < 0.0) ? -1.0 : 1.0;
}
extern "C"
inline
unsigned int
getNumBlocksLinear(const unsigned int num_threads,
const unsigned int num_threads_block)
{
const unsigned int block_rem =
((num_threads % num_threads_block) != 0) ? 1 : 0;
return (num_threads / num_threads_block) + block_rem;
}
} // namespace detail
} // namespace linalg
} // namespace viennacl
#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