All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
common.hpp
Go to the documentation of this file.
#ifndef VIENNACL_LINALG_OPENCL_COMMON_HPP_
#define VIENNACL_LINALG_OPENCL_COMMON_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
============================================================================= */
#include <cmath>
#include "viennacl/forwards.h"
#include "viennacl/ocl/platform.hpp"
#include "viennacl/traits/handle.hpp"
namespace viennacl
{
namespace linalg
{
namespace opencl
{
namespace detail
{
inline cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
{
return static_cast<cl_uint>( ((length > 1) ? (cl_uint(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
}
inline std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
{
if (B_transposed)
{
if (B_row_major && C_row_major)
return "trans_mat_mult_row_row";
if (B_row_major && !C_row_major)
return "trans_mat_mult_row_col";
if (!B_row_major && C_row_major)
return "trans_mat_mult_col_row";
return "trans_mat_mult_col_col";
}
if (B_row_major && C_row_major)
return "mat_mult_row_row";
if (B_row_major && !C_row_major)
return "mat_mult_row_col";
if (!B_row_major && C_row_major)
return "mat_mult_col_row";
return "mat_mult_col_col";
}
template<typename SomeT>
ocl::device const & current_device(SomeT const & obj) { return traits::opencl_handle(obj).context().current_device(); }
inline std::string op_to_string(op_abs) { return "abs"; }
inline std::string op_to_string(op_acos) { return "acos"; }
inline std::string op_to_string(op_asin) { return "asin"; }
inline std::string op_to_string(op_atan) { return "atan"; }
inline std::string op_to_string(op_ceil) { return "ceil"; }
inline std::string op_to_string(op_cos) { return "cos"; }
inline std::string op_to_string(op_cosh) { return "cosh"; }
inline std::string op_to_string(op_exp) { return "exp"; }
inline std::string op_to_string(op_fabs) { return "fabs"; }
inline std::string op_to_string(op_floor) { return "floor"; }
inline std::string op_to_string(op_log) { return "log"; }
inline std::string op_to_string(op_log10) { return "log10"; }
inline std::string op_to_string(op_sin) { return "sin"; }
inline std::string op_to_string(op_sinh) { return "sinh"; }
inline std::string op_to_string(op_sqrt) { return "sqrt"; }
inline std::string op_to_string(op_tan) { return "tan"; }
inline std::string op_to_string(op_tanh) { return "tanh"; }
} //namespace detail
} //namespace opencl
} //namespace linalg
} //namespace viennacl
#endif
viennacl::op_cosh
A tag class representing the cosh() function.
Definition: forwards.h:155
viennacl::op_tan
A tag class representing the tan() function.
Definition: forwards.h:181
platform.hpp
Implements a OpenCL platform within ViennaCL.
viennacl::linalg::opencl::detail::sparse_dense_matmult_kernel_name
std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
Returns the OpenCL kernel string for the operation C = A * B with A sparse, B, C dense matrices...
Definition: common.hpp:49
viennacl::op_abs
A tag class representing the modulus function for integers.
Definition: forwards.h:137
viennacl::op_ceil
A tag class representing the ceil() function.
Definition: forwards.h:151
viennacl::ocl::device
A class representing a compute device (e.g. a GPU)
Definition: device.hpp:49
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::op_log
A tag class representing the log() function.
Definition: forwards.h:171
viennacl::op_tanh
A tag class representing the tanh() function.
Definition: forwards.h:183
viennacl::op_fabs
A tag class representing the fabs() function.
Definition: forwards.h:159
viennacl::op_atan
A tag class representing the atan() function.
Definition: forwards.h:147
viennacl::op_sinh
A tag class representing the sinh() function.
Definition: forwards.h:177
viennacl::op_exp
A tag class representing the exp() function.
Definition: forwards.h:157
viennacl::linalg::host_based::detail::flip_sign
NumericT flip_sign(NumericT val)
Definition: vector_operations.hpp:57
viennacl::linalg::opencl::detail::make_options
cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
Definition: common.hpp:42
viennacl::linalg::opencl::detail::current_device
ocl::device const & current_device(SomeT const &obj)
Definition: common.hpp:76
viennacl::op_sqrt
A tag class representing the sqrt() function.
Definition: forwards.h:179
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::op_sin
A tag class representing the sin() function.
Definition: forwards.h:175
viennacl::op_floor
A tag class representing the floor() function.
Definition: forwards.h:163
viennacl::op_asin
A tag class representing the asin() function.
Definition: forwards.h:141
handle.hpp
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
viennacl::op_acos
A tag class representing the acos() function.
Definition: forwards.h:139
viennacl::linalg::opencl::detail::op_to_string
std::string op_to_string(op_abs)
Definition: common.hpp:78
viennacl::op_log10
A tag class representing the log10() function.
Definition: forwards.h:173
viennacl::op_cos
A tag class representing the cos() function.
Definition: forwards.h:153