Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /trunk/src/include/Diderot/types.h
ViewVC logotype

View of /trunk/src/include/Diderot/types.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1115 - (download) (as text) (annotate)
Thu May 5 04:42:18 2011 UTC (8 years, 1 month ago) by jhr
File size: 4297 byte(s)
  More merging of pure-cfg back into trunk
/*! \file types.h
 *
 * \author John Reppy
 */

/*
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 */

#ifndef _DIDEROT_TYPES_H_
#define _DIDEROT_TYPES_H_

/* library-call status */
typedef enum { DIDEROT_OK = 0, DIDEROT_FAIL = -1 } Status_t;

/* update method return type */
typedef enum { DIDEROT_DIE, DIDEROT_ACTIVE, DIDEROT_STABILIZE } StrandStatus_t;

/* SSE vector types */
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
#ifdef VEC2_OK
typedef float vec2f_t __attribute__ ((vector_size (8)));
#else
typedef float vec2f_t __attribute__ ((vector_size (16)));  // pad so that gcc aligns correctly
#endif
typedef float vec4f_t __attribute__ ((vector_size (16)));
typedef float vec8f_t __attribute__ ((vector_size (32)));

#ifdef VEC2_OK
typedef int32_t vec2i_t __attribute__ ((vector_size (8)));
#else
typedef int32_t vec2i_t __attribute__ ((vector_size (16)));  // pad so that gcc aligns correctly
#endif
typedef int32_t vec4i_t __attribute__ ((vector_size (16)));
typedef int32_t vec8i_t __attribute__ ((vector_size (32)));

typedef float vec2d_t __attribute__ ((vector_size (16)));
typedef float vec4d_t __attribute__ ((vector_size (32)));
typedef float vec8d_t __attribute__ ((vector_size (64)));

typedef int64_t vec2l_t __attribute__ ((vector_size (16)));
typedef int64_t vec4l_t __attribute__ ((vector_size (32)));
typedef int64_t vec8l_t __attribute__ ((vector_size (64)));

typedef union { float r[2]; vec2f_t v; } union2f_t;
typedef union { float r[4]; vec4f_t v; } union4f_t;
typedef union { float r[8]; vec8f_t v; } union8f_t;

typedef union { int32_t i[2]; vec2i_t v; } union2i_t;
typedef union { int32_t i[4]; vec4i_t v; } union4i_t;
typedef union { int32_t i[8]; vec8i_t v; } union8i_t;

typedef union { double r[2]; vec2d_t v; } union2d_t;
typedef union { double r[4]; vec4d_t v; } union4d_t;
typedef union { double r[8]; vec8d_t v; } union8d_t;

typedef union { int64_t r[2]; vec2l_t v; } union2l_t;
typedef union { int64_t r[4]; vec4l_t v; } union4l_t;
typedef union { int64_t r[8]; vec8l_t v; } union8l_t;

/* vector lengths must be power of 2, but vec3 is useful, so we pad to 4 */
typedef vec4f_t vec3f_t;
typedef union4f_t union3f_t;
typedef vec4d_t vec3d_t;
typedef union4d_t union3d_t;
typedef vec4i_t vec3i_t;
typedef union4i_t union3i_t;
typedef vec4l_t vec3l_t;
typedef union4l_t union3l_t;

/* typedefs for Diderot types */
#if defined(DIDEROT_SINGLE_PRECISION)
typedef int32_t Diderot_int_t;
typedef float Diderot_real_t;
typedef union4f_t Diderot_vec3_t;	// padded to fit in SSE register
typedef union4f_t Diderot_vec4_t;
#else
typedef int64_t Diderot_int_t;
typedef double Diderot_real_t;
typedef union4d_t Diderot_vec3_t;	// padded to fit in SSE register
typedef union4d_t Diderot_vec4_t;
#endif
typedef const char *Diderot_string_t;

typedef union2f_t Diderot_Mat2x2_t[2];	// represented as row vectors
typedef union3f_t Diderot_Mat3x3_t[3];	// represented as row vectors
typedef union4f_t Diderot_Mat4x4_t[4];	// represented as row vectors

typedef struct {		// wrapper for 1D image data
    uint32_t	dim;		// dimension (== 1)
    uint32_t	size[1];
    void	*data;
    float	s;		// scaling from world-space to image-space
    float	t;		// translation from world-space to image-space
} Diderot_image1D_t;

typedef struct {		// wrapper for 2D image data
    uint32_t	dim;		// dimension (== 2)
    uint32_t	size[2];	// sizes (fast to slow)
    void	*data;
    Diderot_Mat2x2_t w2i;	// affine tranform from world space to index space.  This is the
				// inverse of the index to world-space transform that is loaded from
				// the Nrrd file.
    vec2f_t	tVec;		// translation part of world to index transform
    Diderot_Mat2x2_t w2iT;	// transpose w3i
} Diderot_image2D_t;

typedef struct {		// wrapper for 3D image data
    uint32_t	dim;		// dimension (== 3)
    uint32_t	size[3];	// sizes (fast to slow)
    void	*data;
    Diderot_Mat3x3_t w2i;	// affine tranform from world space to index space.  This is the
				// inverse of the index to world-space transform that is loaded from
				// the Nrrd file.
    vec3f_t	tVec;		// translation part of world to index transform
    Diderot_Mat3x3_t w2iT;	// transpose w3i
} Diderot_image3D_t;

#endif /* !_DIDEROT_TYPES_H_ */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0