Voxel
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
Classes | Namespaces | Macros | Functions
opencl_converter.h File Reference

Contains OpenCL::Converter class. More...

#include "settings.h"
#include "vector.h"
#include <CL/cl.h>
#include <array>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  OpenCL::Converter< t_Type >
 Converts data for transmission to OpenCL device. More...
struct  OpenCL::Converter< std::array< t_Type, t_Size > >
 Converter specialization for fixed-size arrays. More...

Namespaces

namespace  OpenCL
 Contains State, Program, Converter and Exception classes.

Macros

#define OPENCL_CONVERTER_H
#define OPENCL_COMMA   ,
#define OPENCL_CONVERTER1(ss, dd)
 Generates converter specialization which converts the host type ss to the OpenCL type dd.
#define OPENCL_CONVERTER2(ss, dd)
 Generates converter specialization which converts the host 2D vector type ss to the OpenCL 2D vector type dd.
#define OPENCL_CONVERTER3(ss, dd)
 Generates converter specialization which converts the host 3D vector type ss to the OpenCL 3D vector type dd.
#define OPENCL_CONVERTER4(ss, dd)
 Generates converter specialization which converts the host 4D vector type ss to the OpenCL 4D vector type dd.
#define OPENCL_CONVERTER8(ss, dd)
 Generates converter specialization which converts the host 8D vector type ss to the OpenCL 8D vector type dd.
#define OPENCL_CONVERTER16(ss, dd)
 Generates converter specialization which converts the host 16D vector type ss to the OpenCL 16D vector type dd.
#define OPENCL_CONVERTER(ss, dd)
 Generates converter specializations which convert the host type ss to the OpenCL type dd, and likewise Vector< ss, n > to ddn for $n \in \{ 1, 2, 3, 4, 8, 16 \}$.

Functions

template<typename t_Type >
Converter< t_Type >::Type OpenCL::Convert (t_Type const &source)
 Helper function which calls Converter::Convert for the type of its argument.

Detailed Description

Contains OpenCL::Converter class.

In addition to the Converter default specialization, this file also defines specializations for fixed-size arrays (using std::array for the host type), builtin integer and floating-point types, and vectors (using Vector for the host type, e.g. Vector< float, 3 > maps to cl_float3).

Definition in file opencl_converter.h.

Macro Definition Documentation

#define OPENCL_CONVERTER (   ss,
  dd 
)
Value:
OPENCL_CONVERTER1( ss, dd ) \
OPENCL_CONVERTER2( Vector< ss OPENCL_COMMA 2 >, dd##2 ) \
OPENCL_CONVERTER3( Vector< ss OPENCL_COMMA 3 >, dd##3 ) \
OPENCL_CONVERTER4( Vector< ss OPENCL_COMMA 4 >, dd##4 ) \
OPENCL_CONVERTER8( Vector< ss OPENCL_COMMA 8 >, dd##8 ) \
OPENCL_CONVERTER16( Vector< ss OPENCL_COMMA 16 >, dd##16 )

Generates converter specializations which convert the host type ss to the OpenCL type dd, and likewise Vector< ss, n > to ddn for $n \in \{ 1, 2, 3, 4, 8, 16 \}$.

Definition at line 207 of file opencl_converter.h.

#define OPENCL_CONVERTER1 (   ss,
  dd 
)
Value:
template<> \
struct Converter< ss > { \
typedef dd Type; \
static Type Convert( ss const& source ) { \
return source; \
} \
};

Generates converter specialization which converts the host type ss to the OpenCL type dd.

Definition at line 142 of file opencl_converter.h.

#define OPENCL_CONVERTER16 (   ss,
  dd 
)
Value:
template<> \
struct Converter< ss > { \
typedef dd Type; \
static Type Convert( ss const& source ) { \
Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ], source[ 3 ], source[ 4 ], source[ 5 ], source[ 6 ], source[ 7 ], source[ 8 ], source[ 9 ], source[ 10 ], source[ 11 ], source[ 12 ], source[ 13 ], source[ 14 ], source[ 15 ] } }; \
return result; \
} \
};

Generates converter specialization which converts the host 16D vector type ss to the OpenCL 16D vector type dd.

Definition at line 196 of file opencl_converter.h.

#define OPENCL_CONVERTER2 (   ss,
  dd 
)
Value:
template<> \
struct Converter< ss > { \
typedef dd Type; \
static Type Convert( ss const& source ) { \
Type const result = { { source[ 0 ], source[ 1 ] } }; \
return result; \
} \
};

Generates converter specialization which converts the host 2D vector type ss to the OpenCL 2D vector type dd.

Definition at line 152 of file opencl_converter.h.

#define OPENCL_CONVERTER3 (   ss,
  dd 
)
Value:
template<> \
struct Converter< ss > { \
typedef dd Type; \
static Type Convert( ss const& source ) { \
Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ] } }; \
return result; \
} \
};

Generates converter specialization which converts the host 3D vector type ss to the OpenCL 3D vector type dd.

Definition at line 163 of file opencl_converter.h.

#define OPENCL_CONVERTER4 (   ss,
  dd 
)
Value:
template<> \
struct Converter< ss > { \
typedef dd Type; \
static Type Convert( ss const& source ) { \
Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ], source[ 3 ] } }; \
return result; \
} \
};

Generates converter specialization which converts the host 4D vector type ss to the OpenCL 4D vector type dd.

Definition at line 174 of file opencl_converter.h.

#define OPENCL_CONVERTER8 (   ss,
  dd 
)
Value:
template<> \
struct Converter< ss > { \
typedef dd Type; \
static Type Convert( ss const& source ) { \
Type const result = { { source[ 0 ], source[ 1 ], source[ 2 ], source[ 3 ], source[ 4 ], source[ 5 ], source[ 6 ], source[ 7 ] } }; \
return result; \
} \
};

Generates converter specialization which converts the host 8D vector type ss to the OpenCL 8D vector type dd.

Definition at line 185 of file opencl_converter.h.