Public Types | Public Member Functions

scalar< TYPE > Class Template Reference

This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type like float or double. More...

#include <scalar.hpp>

Public Types

typedef
viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT
< TYPE >::ResultType 
value_type
 Returns the underlying host scalar type.

Public Member Functions

 scalar ()
 Allocates the memory for the scalar, but does not set it to zero.
 scalar (TYPE val)
 Allocates the memory for the scalar and sets it to the supplied value.
 scalar (cl_mem mem, size_t size)
 Wraps an existing memory entry into a scalar.
template<typename T1 , typename T2 , typename OP >
 scalar (scalar_expression< T1, T2, OP > const &proxy)
 Allocates memory for the scalar and sets it to the result of supplied expression.
 scalar (const scalar &other)
 Copy constructor. Allocates new memory for the scalar and copies the value of the supplied scalar.
 operator TYPE () const
 Reads the value of the scalar from the GPU and returns the float or double value.
scalar< TYPE > & operator= (entry_proxy< TYPE > const &other)
 Assigns a vector entry.
scalar< TYPE > & operator= (scalar< TYPE > const &other)
 Assigns the value from another scalar.
scalar< TYPE > & operator= (float cpu_other)
scalar< TYPE > & operator= (double cpu_other)
scalar< TYPE > & operator= (long cpu_other)
scalar< TYPE > & operator= (unsigned long cpu_other)
scalar< TYPE > & operator= (int cpu_other)
scalar< TYPE > & operator= (unsigned int cpu_other)
template<typename T1 , typename T2 >
scalar< TYPE > & operator= (scalar_expression< T1, T2, op_inner_prod > const &proxy)
 Sets the scalar to the result of supplied inner product expression.
template<typename T1 , typename T2 >
scalar< TYPE > & operator= (scalar_expression< T1, T2, op_norm_1 > const &proxy)
 Sets the scalar to the result of supplied norm_1 expression.
template<typename T1 , typename T2 >
scalar< TYPE > & operator= (scalar_expression< T1, T2, op_norm_2 > const &proxy)
 Sets the scalar to the result of supplied norm_2 expression.
template<typename T1 , typename T2 >
scalar< TYPE > & operator= (scalar_expression< T1, T2, op_norm_inf > const &proxy)
 Sets the scalar to the result of supplied norm_inf expression.
scalar< TYPE > & operator+= (scalar< TYPE > const &other)
 Inplace addition of a ViennaCL scalar.
scalar< TYPE > & operator+= (TYPE other)
 Inplace addition of a host scalar (float or double).
scalar< TYPE > & operator-= (scalar< TYPE > const &other)
 Inplace subtraction of a ViennaCL scalar.
scalar< TYPE > & operator-= (TYPE other)
 Inplace subtraction of a host scalar (float or double).
scalar< TYPE > & operator*= (scalar< TYPE > const &other)
 Inplace multiplication with a ViennaCL scalar.
scalar< TYPE > & operator*= (TYPE other)
 Inplace multiplication with a host scalar (float or double).
scalar< TYPE > & operator/= (scalar< TYPE > const &other)
 Inplace division with a ViennaCL scalar.
scalar< TYPE > & operator/= (TYPE other)
 Inplace division with a host scalar (float or double).
scalar< TYPE > operator+ (scalar< TYPE > const &other)
 Addition of two ViennaCL scalars.
template<typename T1 , typename T2 , typename OP >
scalar< TYPE > operator+ (scalar_expression< T1, T2, OP > const &proxy) const
 Addition of a ViennaCL scalar with a scalar expression.
scalar< TYPE > operator+ (TYPE other)
 Addition of a ViennaCL scalar with a host scalar (float, double).
scalar< TYPE > operator- (scalar< TYPE > const &other) const
 Subtraction of two ViennaCL scalars.
template<typename T1 , typename T2 , typename OP >
scalar< TYPE > operator- (scalar_expression< T1, T2, OP > const &proxy) const
 Subtraction of a ViennaCL scalar from a scalar expression.
scalar< TYPE > operator- (TYPE other) const
 Subtraction of a host scalar (float, double) from a ViennaCL scalar.
scalar< TYPE > operator* (scalar< TYPE > const &other) const
 Multiplication of two ViennaCL scalars.
template<typename T1 , typename T2 , typename OP >
scalar< TYPE > operator* (scalar_expression< T1, T2, OP > const &proxy) const
 Multiplication of a ViennaCL scalar with a scalar expression.
scalar< TYPE > operator* (TYPE other) const
 Multiplication of a host scalar (float, double) with a ViennaCL scalar.
scalar< TYPE > operator/ (scalar< TYPE > const &other) const
 Division of two ViennaCL scalars.
template<typename T1 , typename T2 , typename OP >
scalar< TYPE > operator/ (scalar_expression< T1, T2, OP > const &proxy) const
 Division of a ViennaCL scalar by a scalar expression.
scalar< TYPE > operator/ (TYPE other) const
 Division of a ViennaCL scalar by a host scalar (float, double).
const viennacl::ocl::handle
< cl_mem > & 
handle () const
 Returns the OpenCL handle.

Detailed Description

template<class TYPE>
class viennacl::scalar< TYPE >

This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type like float or double.

Since every read and write operation requires a CPU->GPU or GPU->CPU transfer, this type should be used with care. The advantage of this type is that the GPU command queue can be filled without blocking read operations.

Template Parameters:
TYPE Either float or double. Checked at compile time.

Member Typedef Documentation

Returns the underlying host scalar type.


Constructor & Destructor Documentation

scalar (  )  [inline]

Allocates the memory for the scalar, but does not set it to zero.

scalar ( TYPE  val  )  [inline]

Allocates the memory for the scalar and sets it to the supplied value.

scalar ( cl_mem  mem,
size_t  size 
) [inline, explicit]

Wraps an existing memory entry into a scalar.

Parameters:
mem The OpenCL memory handle
size Ignored - Only necessary to avoid ambiguities. Users are advised to set this parameter to '1'.
scalar ( scalar_expression< T1, T2, OP > const &  proxy  )  [inline]

Allocates memory for the scalar and sets it to the result of supplied expression.

scalar ( const scalar< TYPE > &  other  )  [inline]

Copy constructor. Allocates new memory for the scalar and copies the value of the supplied scalar.


Member Function Documentation

const viennacl::ocl::handle<cl_mem>& handle (  )  const [inline]

Returns the OpenCL handle.

operator TYPE (  )  const [inline]

Reads the value of the scalar from the GPU and returns the float or double value.

scalar<TYPE> operator* ( scalar< TYPE > const &  other  )  const [inline]

Multiplication of two ViennaCL scalars.

scalar<TYPE> operator* ( scalar_expression< T1, T2, OP > const &  proxy  )  const [inline]

Multiplication of a ViennaCL scalar with a scalar expression.

scalar<TYPE> operator* ( TYPE  other  )  const [inline]

Multiplication of a host scalar (float, double) with a ViennaCL scalar.

scalar<TYPE>& operator*= ( scalar< TYPE > const &  other  )  [inline]

Inplace multiplication with a ViennaCL scalar.

scalar<TYPE>& operator*= ( TYPE  other  )  [inline]

Inplace multiplication with a host scalar (float or double).

scalar<TYPE> operator+ ( scalar< TYPE > const &  other  )  [inline]

Addition of two ViennaCL scalars.

scalar<TYPE> operator+ ( scalar_expression< T1, T2, OP > const &  proxy  )  const [inline]

Addition of a ViennaCL scalar with a scalar expression.

scalar<TYPE> operator+ ( TYPE  other  )  [inline]

Addition of a ViennaCL scalar with a host scalar (float, double).

scalar<TYPE>& operator+= ( scalar< TYPE > const &  other  )  [inline]

Inplace addition of a ViennaCL scalar.

scalar<TYPE>& operator+= ( TYPE  other  )  [inline]

Inplace addition of a host scalar (float or double).

scalar<TYPE> operator- ( TYPE  other  )  const [inline]

Subtraction of a host scalar (float, double) from a ViennaCL scalar.

scalar<TYPE> operator- ( scalar< TYPE > const &  other  )  const [inline]

Subtraction of two ViennaCL scalars.

scalar<TYPE> operator- ( scalar_expression< T1, T2, OP > const &  proxy  )  const [inline]

Subtraction of a ViennaCL scalar from a scalar expression.

scalar<TYPE>& operator-= ( scalar< TYPE > const &  other  )  [inline]

Inplace subtraction of a ViennaCL scalar.

scalar<TYPE>& operator-= ( TYPE  other  )  [inline]

Inplace subtraction of a host scalar (float or double).

scalar<TYPE> operator/ ( TYPE  other  )  const [inline]

Division of a ViennaCL scalar by a host scalar (float, double).

scalar<TYPE> operator/ ( scalar_expression< T1, T2, OP > const &  proxy  )  const [inline]

Division of a ViennaCL scalar by a scalar expression.

scalar<TYPE> operator/ ( scalar< TYPE > const &  other  )  const [inline]

Division of two ViennaCL scalars.

scalar<TYPE>& operator/= ( TYPE  other  )  [inline]

Inplace division with a host scalar (float or double).

scalar<TYPE>& operator/= ( scalar< TYPE > const &  other  )  [inline]

Inplace division with a ViennaCL scalar.

scalar<TYPE>& operator= ( scalar_expression< T1, T2, op_norm_2 > const &  proxy  )  [inline]

Sets the scalar to the result of supplied norm_2 expression.

scalar<TYPE>& operator= ( scalar_expression< T1, T2, op_norm_inf > const &  proxy  )  [inline]

Sets the scalar to the result of supplied norm_inf expression.

scalar<TYPE>& operator= ( scalar_expression< T1, T2, op_inner_prod > const &  proxy  )  [inline]

Sets the scalar to the result of supplied inner product expression.

scalar<TYPE>& operator= ( unsigned long  cpu_other  )  [inline]
scalar<TYPE>& operator= ( int  cpu_other  )  [inline]
scalar<TYPE>& operator= ( scalar< TYPE > const &  other  )  [inline]

Assigns the value from another scalar.

scalar<TYPE>& operator= ( double  cpu_other  )  [inline]
scalar<TYPE>& operator= ( scalar_expression< T1, T2, op_norm_1 > const &  proxy  )  [inline]

Sets the scalar to the result of supplied norm_1 expression.

scalar<TYPE>& operator= ( long  cpu_other  )  [inline]
scalar<TYPE>& operator= ( unsigned int  cpu_other  )  [inline]
scalar<TYPE>& operator= ( float  cpu_other  )  [inline]
scalar<TYPE>& operator= ( entry_proxy< TYPE > const &  other  )  [inline]

Assigns a vector entry.


The documentation for this class was generated from the following file: