ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raypwin.c
Revision: 2.8
Committed: Tue Oct 26 03:45:35 2010 UTC (13 years, 6 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R2P1
Changes since 2.7: +8 -1 lines
Log Message:
Bug fix in l+ option of mkillum under Windows

File Contents

# User Rev Content
1 greg 2.1 #ifndef lint
2 greg 2.8 static const char RCSid[] = "$Id: raypwin.c,v 2.7 2010/05/27 19:32:13 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 greg 2.6 void
26 greg 2.1 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 greg 2.6 int
38 greg 2.1 ray_psend( /* add a ray to our send queue */
39     RAY *r
40     )
41     {
42 greg 2.2 if (r == NULL)
43 greg 2.6 return(0);
44 greg 2.2 if (ray_pnidle <= 0)
45 greg 2.6 return(0);
46 greg 2.2 queued_ray = *r;
47     ray_pnidle = 0;
48 greg 2.6 return(1);
49 greg 2.1 }
50    
51    
52 greg 2.6 int
53 greg 2.1 ray_pqueue( /* queue a ray for computation */
54     RAY *r
55     )
56     {
57 greg 2.8 RNUMBER rno;
58    
59 greg 2.2 if (r == NULL)
60     return(0);
61 greg 2.5 if (ray_pnidle <= 0) {
62     RAY new_ray = *r;
63     *r = queued_ray;
64     queued_ray = new_ray;
65     }
66 greg 2.8 rno = r->rno;
67     r->rno = raynum++;
68 greg 2.4 samplendx++;
69     rayvalue(r);
70 greg 2.8 r->rno = rno;
71 greg 2.2 return(1);
72 greg 2.1 }
73    
74    
75 greg 2.6 int
76 greg 2.1 ray_presult( /* check for a completed ray */
77     RAY *r,
78     int poll
79     )
80     {
81 greg 2.2 if (r == NULL)
82     return(0);
83 greg 2.3 if (ray_pnidle <= 0) {
84 greg 2.5 *r = queued_ray;
85 greg 2.8 r->rno = raynum++;
86 greg 2.4 samplendx++;
87     rayvalue(r);
88 greg 2.8 r->rno = queued_ray.rno;
89 greg 2.2 ray_pnidle = 1;
90     return(1);
91     }
92     return(0);
93 greg 2.1 }
94    
95    
96 greg 2.6 void
97 greg 2.1 ray_pdone( /* reap children and free data */
98     int freall
99     )
100     {
101 greg 2.2 ray_done(freall);
102     ray_pnprocs = ray_pnidle = 0;
103 greg 2.1 }
104    
105    
106 greg 2.6 void
107 greg 2.1 ray_popen( /* open the specified # processes */
108     int nadd
109     )
110     {
111 greg 2.2 if (ray_pnprocs + nadd > 1) {
112 greg 2.6 error(WARNING, "only single process supported");
113 greg 2.2 nadd = 1 - ray_pnprocs;
114     }
115     ray_pnprocs += nadd;
116     ray_pnidle += nadd;
117 greg 2.1 }
118    
119    
120 greg 2.6 void
121 greg 2.1 ray_pclose( /* close one or more child processes */
122     int nsub
123     )
124     {
125 greg 2.2 if (nsub > ray_pnprocs)
126     nsub = ray_pnprocs;
127     ray_pnprocs -= nsub;
128     if ((ray_pnidle -= nsub) < 0)
129     ray_pnidle = 0;
130 greg 2.1 }