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

SCM Repository

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

Annotation of /trunk/src/include/Diderot/diderot.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1295 - (view) (download) (as text)

1 : jhr 1115 /*! \file diderot.h
2 :     *
3 :     * \author John Reppy
4 :     *
5 :     * This is the interface to the Diderot runtime for the C target. For now,
6 :     * we are targetting single-precision computations.
7 :     */
8 :    
9 :     /*
10 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
11 :     * All rights reserved.
12 :     */
13 :    
14 :     #ifndef _DIDEROT_H_
15 :     #define _DIDEROT_H_
16 :    
17 : jhr 1232 #include "Diderot/config.h"
18 :    
19 : jhr 1115 /* gcc has a bug that breaks code that uses 8-byte vectors (e.g., vec2f_t), but clang
20 :     * handles the code correctly.
21 :     */
22 :     #if defined(__clang__)
23 :     # define VEC2_OK
24 :     #endif
25 :    
26 :     #ifdef NDEBUG
27 : jhr 1295 #define STATIC_INLINE static inline
28 : jhr 1115 #else
29 : jhr 1295 #define STATIC_INLINE static
30 : jhr 1115 #endif
31 :    
32 :     #include <stdint.h>
33 :     #include <stdbool.h>
34 :     #include <stdlib.h>
35 :     #include <math.h>
36 :     #include <stdio.h> // for printing output
37 :    
38 :     #include "types.h"
39 :     #include "strands.h"
40 :    
41 :     /* load image data from Nrrd files */
42 :     extern Status_t Diderot_LoadImage1D (Diderot_string_t name, Diderot_image1D_t **img);
43 :     extern Status_t Diderot_LoadImage2D (Diderot_string_t name, Diderot_image2D_t **img);
44 :     extern Status_t Diderot_LoadImage3D (Diderot_string_t name, Diderot_image3D_t **img);
45 :    
46 :     /* functions to get input-parameter values */
47 :     extern Status_t Diderot_InputString (const char *, const char **, bool);
48 : jhr 1232 extern Status_t Diderot_InputReal (const char *, Diderot_real_t *, bool);
49 :     extern Status_t Diderot_InputVec2 (const char *, Diderot_vec2_t *, bool);
50 :     extern Status_t Diderot_InputVec3 (const char *, Diderot_vec3_t *, bool);
51 : jhr 1115
52 : jhr 1232 /* function to get information about the CPU configuration */
53 :    
54 : jhr 1295 //! Summary information about the CPU configuration.
55 : jhr 1232 typedef struct {
56 : jhr 1295 int numHWNodes; //!< \brief number of (possibly multicore) processors
57 :     int numHWCores; //!< \brief total number of (possibly
58 :     //! mulithreaded) cores
59 :     int numHWThreads; //!< \brief total number of hardware threads
60 :     int numCoresPerNode; //!< \brief number of cores per thread
61 :     int numThdsPerCore; //!< \brief number of threads per core
62 : jhr 1232 } CPUInfo_t;
63 :    
64 : jhr 1295 //! \brief function to get information about the CPU configuration
65 : jhr 1232 bool GetNumCPUs (CPUInfo_t *info);
66 :    
67 :    
68 : jhr 1115 /********** scalar math functions **********/
69 :    
70 :     STATIC_INLINE float minf (float a, float b)
71 :     {
72 : jhr 1295 return (a < b) ? a : b;
73 : jhr 1115 }
74 :    
75 :     STATIC_INLINE float maxf (float a, float b)
76 :     {
77 : jhr 1295 return (a < b) ? b : a;
78 : jhr 1115 }
79 :    
80 : jhr 1295 STATIC_INLINE float clampf (float lo, float hi, float x)
81 :     {
82 :     return minf(maxf(lo, x), hi);
83 :     }
84 :    
85 : jhr 1115 STATIC_INLINE float lerpf (float a, float b, float t)
86 :     {
87 :     return a + t*(b - a);
88 :     }
89 :    
90 :     /********** vector math functions **********/
91 :    
92 :     #include "inline-vec2.h"
93 :     #include "inline-vec3.h"
94 :     #include "inline-vec4.h"
95 :     #include "inline-matrix.h"
96 :    
97 :    
98 :     /********** other Diderot support functions **********/
99 :    
100 :     #include "inline-image.h"
101 :    
102 :     #endif /* !_DIDEROT_H_ */

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