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 1301 - (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 1301 // include OpenCL headers when the target is OpenCL
20 :     #if defined(DIDEROT_TARGET_CL)
21 :     # ifdef HAVE_CL_CL_H
22 :     # include <CL/cl.h>
23 :     # elif defined(HAVE_OPENCL_CL_H)
24 :     # include <OpenCL/cl.h>
25 :     # else
26 :     # error no cl.h
27 :     # endif
28 :     #endif
29 :    
30 : jhr 1115 /* gcc has a bug that breaks code that uses 8-byte vectors (e.g., vec2f_t), but clang
31 :     * handles the code correctly.
32 :     */
33 :     #if defined(__clang__)
34 :     # define VEC2_OK
35 :     #endif
36 :    
37 :     #ifdef NDEBUG
38 : jhr 1295 #define STATIC_INLINE static inline
39 : jhr 1115 #else
40 : jhr 1295 #define STATIC_INLINE static
41 : jhr 1115 #endif
42 :    
43 :     #include <stdint.h>
44 :     #include <stdbool.h>
45 :     #include <stdlib.h>
46 :     #include <math.h>
47 :     #include <stdio.h> // for printing output
48 :    
49 :     #include "types.h"
50 :     #include "strands.h"
51 : jhr 1301 #include "options.h"
52 : jhr 1115
53 :     /* load image data from Nrrd files */
54 :     extern Status_t Diderot_LoadImage1D (Diderot_string_t name, Diderot_image1D_t **img);
55 :     extern Status_t Diderot_LoadImage2D (Diderot_string_t name, Diderot_image2D_t **img);
56 :     extern Status_t Diderot_LoadImage3D (Diderot_string_t name, Diderot_image3D_t **img);
57 :    
58 : jhr 1232 /* function to get information about the CPU configuration */
59 :    
60 : jhr 1295 //! Summary information about the CPU configuration.
61 : jhr 1232 typedef struct {
62 : jhr 1295 int numHWNodes; //!< \brief number of (possibly multicore) processors
63 :     int numHWCores; //!< \brief total number of (possibly
64 :     //! mulithreaded) cores
65 :     int numHWThreads; //!< \brief total number of hardware threads
66 :     int numCoresPerNode; //!< \brief number of cores per thread
67 :     int numThdsPerCore; //!< \brief number of threads per core
68 : jhr 1232 } CPUInfo_t;
69 :    
70 : jhr 1295 //! \brief function to get information about the CPU configuration
71 : jhr 1232 bool GetNumCPUs (CPUInfo_t *info);
72 :    
73 : jhr 1301 //! get the current time in seconds
74 :     double GetTime ();
75 : jhr 1232
76 : jhr 1301
77 : jhr 1115 /********** scalar math functions **********/
78 :    
79 :     STATIC_INLINE float minf (float a, float b)
80 :     {
81 : jhr 1295 return (a < b) ? a : b;
82 : jhr 1115 }
83 :    
84 :     STATIC_INLINE float maxf (float a, float b)
85 :     {
86 : jhr 1295 return (a < b) ? b : a;
87 : jhr 1115 }
88 :    
89 : jhr 1295 STATIC_INLINE float clampf (float lo, float hi, float x)
90 :     {
91 :     return minf(maxf(lo, x), hi);
92 :     }
93 :    
94 : jhr 1115 STATIC_INLINE float lerpf (float a, float b, float t)
95 :     {
96 :     return a + t*(b - a);
97 :     }
98 :    
99 :     /********** vector math functions **********/
100 :    
101 :     #include "inline-vec2.h"
102 :     #include "inline-vec3.h"
103 :     #include "inline-vec4.h"
104 :     #include "inline-matrix.h"
105 :    
106 :    
107 :     /********** other Diderot support functions **********/
108 :    
109 :     #include "inline-image.h"
110 :    
111 :     #endif /* !_DIDEROT_H_ */

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