ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raypwin.c
Revision: 2.5
Committed: Thu Apr 17 18:48:09 2008 UTC (16 years ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R9
Changes since 2.4: +7 -2 lines
Log Message:
Bug fixes

File Contents

# User Rev Content
1 greg 2.1 #ifndef lint
2 greg 2.5 static const char RCSid[] = "$Id: raypwin.c,v 2.4 2008/02/13 01:06:10 greg Exp $";
3 greg 2.1 #endif
4     /*
5     * raypwin.c - interface for parallel rendering using Radiance (Windows ver)
6     *
7     * External symbols declared in ray.h
8     */
9    
10     #include "copyright.h"
11    
12     /*
13     * See raypcalls.c for an explanation of these routines.
14     */
15    
16 greg 2.2 /***** XXX CURRENTLY, THIS IS JUST A COLLECTION OF IMPOTENT STUBS XXX *****/
17 greg 2.1
18     #include "ray.h"
19    
20 greg 2.2 int ray_pnprocs = 0; /* number of child processes */
21     int ray_pnidle = 0; /* number of idle children */
22    
23     static RAY queued_ray;
24 greg 2.1
25     extern void
26     ray_pinit( /* initialize ray-tracing processes */
27     char *otnm,
28     int nproc
29     )
30     {
31 greg 2.2 ray_pdone(0);
32     ray_init(otnm);
33     ray_popen(nproc);
34 greg 2.1 }
35    
36    
37     extern void
38     ray_psend( /* add a ray to our send queue */
39     RAY *r
40     )
41     {
42 greg 2.2 if (r == NULL)
43     return;
44     if (ray_pnidle <= 0)
45     error(INTERNAL, "illegal call to ray_psend");
46     queued_ray = *r;
47     ray_pnidle = 0;
48 greg 2.1 }
49    
50    
51     extern int
52     ray_pqueue( /* queue a ray for computation */
53     RAY *r
54     )
55     {
56 greg 2.2 if (r == NULL)
57     return(0);
58 greg 2.5 if (ray_pnidle <= 0) {
59     RAY new_ray = *r;
60     *r = queued_ray;
61     queued_ray = new_ray;
62     }
63 greg 2.4 samplendx++;
64     rayvalue(r);
65 greg 2.2 return(1);
66 greg 2.1 }
67    
68    
69     extern int
70     ray_presult( /* check for a completed ray */
71     RAY *r,
72     int poll
73     )
74     {
75 greg 2.2 if (r == NULL)
76     return(0);
77 greg 2.3 if (ray_pnidle <= 0) {
78 greg 2.5 *r = queued_ray;
79 greg 2.4 samplendx++;
80     rayvalue(r);
81 greg 2.2 ray_pnidle = 1;
82     return(1);
83     }
84     return(0);
85 greg 2.1 }
86    
87    
88     extern void
89     ray_pdone( /* reap children and free data */
90     int freall
91     )
92     {
93 greg 2.2 ray_done(freall);
94     ray_pnprocs = ray_pnidle = 0;
95 greg 2.1 }
96    
97    
98     extern void
99     ray_popen( /* open the specified # processes */
100     int nadd
101     )
102     {
103 greg 2.2 if (ray_pnprocs + nadd > 1) {
104     error(WARNING, "Only single process supported");
105     nadd = 1 - ray_pnprocs;
106     }
107     ray_pnprocs += nadd;
108     ray_pnidle += nadd;
109 greg 2.1 }
110    
111    
112     extern void
113     ray_pclose( /* close one or more child processes */
114     int nsub
115     )
116     {
117 greg 2.2 if (nsub > ray_pnprocs)
118     nsub = ray_pnprocs;
119     ray_pnprocs -= nsub;
120     if ((ray_pnidle -= nsub) < 0)
121     ray_pnidle = 0;
122 greg 2.1 }
123    
124    
125     void
126     quit(ec) /* make sure exit is called */
127     int ec;
128     {
129     exit(ec);
130     }