SCM Repository
View of /trunk/src/lib/diderot.h
Parent Directory
|
Revision Log
Revision 448 -
(download)
(as text)
(annotate)
Thu Oct 21 15:23:02 2010 UTC (11 years, 8 months ago) by jhr
File size: 3962 byte(s)
Thu Oct 21 15:23:02 2010 UTC (11 years, 8 months ago) by jhr
File size: 3962 byte(s)
Working on C version of MIP
/*! \file diderot.h * * \author John Reppy * * This is the interface to the Diderot runtime for the C target. For now, * we are targetting single-precision computations. */ /* * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. */ #ifndef _DIDEROT_H_ #define _DIDEROT_H_ #define STATIC_INLINE static inline #include <stdint.h> #include <stdbool.h> /* library-call status */ typedef enum { DIDEROT_OK = 0, DIDEROT_FAIL = -1 } Status_t; /* SSE vector types */ typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); typedef float float4 __attribute__ ((__vector_size__ (16))); //typedef double double2 __attribute__ ((__vector_size__ (16))); /* union types for converting extracting vector data */ typedef union { float f[4]; float4 v; } f4union; typedef union { double d[2]; double2 v; } d2union; /* typedefs for Diderot types */ typedef int32_t Diderot_int_t; typedef float Diderot_real_t; typedef f4union Diderot_vec3_t; // padded to fit in SSE register typedef f4union Diderot_vec4_t; typedef const char *Diderot_string_t; typedef struct { // wrapper for 1D image data uint32_t dim; // dimension (== 1) uint32_t size[1]; void *data; Diderot_Mat2x2_t m; // image to world-space transform Diderot_Mat2x2_t mInv; // world to image-space transform (m inverse) } 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_Mat3x3_t m; // image to world-space transform Diderot_Mat3x3_t mInv; // world to image-space transform (m inverse) Diderot_Mat3x3_t mInvT; // image to world-space transform for gradients // (m inverse transpose) } 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_Mat4x4_t m; // image to world-space transform Diderot_Mat4x4_t mInv; // world to image-space transform (m inverse) Diderot_Mat4x4_t mInvT; // image to world-space transform for gradients // (m inverse transpose) } Diderot_image3D_t; /* Diderot library functions */ /* load image data from Nrrd files */ extern Status_t Diderot_LoadImage1D (Diderot_string_t name, Diderot_image1D_t *img); extern Status_t Diderot_LoadImage2D (Diderot_string_t name, Diderot_image2D_t *img); extern Status_t Diderot_LoadImage3D (Diderot_string_t name, Diderot_image3D_t *img); /* functions to get input-parameter values */ extern Status_t Diderot_InputString (const char *, const char **, bool); extern Status_t Diderot_InputReal (const char *, Diderot_real_t *, bool); extern Status_t Diderot_InputVec3 (const char *, Diderot_vec3_t *v); /* inline vector arithmetic functions */ STATIC_INLINE float4 Diderot_Vec3 (Diderot_real_t a, Diderot_real_t b, Diderot_real_t c) { return __extension__ (float4){ a, b, c, 0.0f }; } STATIC_INLINE float4 Diderot_Vec4 (Diderot_real_t a, Diderot_real_t b, Diderot_real_t c, Diderot_real_t d) { return __extension__ (float4){ a, b, c, d }; } STATIC_INLINE float4 Diderot_ScaleV3 (float4 dstV, Diderot_real_t s, float4 v) { return Diderot_Vec3(s, s, s) * v; } STATIC_INLINE float4 Diderot_AddV3 (float4 a, float4 b) { return a + b; } STATIC_INLINE float4 Diderot_SubV3 (float4 a, float4 b) { return a - b; } STATIC_INLINE float4 Diderot_MulV3 (float4 a, float4 b) { return a * b; } // check if pos is inside the img, assuming that we have a border of width s. // STATIC_INLINE bool Diderot_Inside3D (Diderot_vec3_t pos, Diderot_image3D_t *img, int s) { // NOTE: there might be a vectorized way to do this compare! return ((s <= pos.f[0]) && (pos.f[0] < (img->size[0] - s)) && (s <= pos.f[1]) && (pos.f[1] < (img->size[1] - s)) && (s <= pos.f[2]) && (pos.f[2] < (img->size[2] - s))); } #endif /* !_DIDEROT_H_ */
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |