ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raypwin.c
(Generate patch)

Comparing ray/src/rt/raypwin.c (file contents):
Revision 2.1 by greg, Fri Feb 8 18:27:31 2008 UTC vs.
Revision 2.5 by greg, Thu Apr 17 18:48:09 2008 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   * See raypcalls.c for an explanation of these routines.
14   */
15  
16 < /***** XXX CURRENTLY, THIS IS JUST A COLLECTION OF FATAL STUBS XXX *****/
16 > /***** XXX CURRENTLY, THIS IS JUST A COLLECTION OF IMPOTENT STUBS XXX *****/
17  
18   #include  "ray.h"
19  
20 + int             ray_pnprocs = 0;        /* number of child processes */
21 + int             ray_pnidle = 0;         /* number of idle children */
22  
23 + static RAY      queued_ray;
24 +
25   extern void
26   ray_pinit(              /* initialize ray-tracing processes */
27          char    *otnm,
28          int     nproc
29   )
30   {
31 <        error(CONSISTENCY, "parallel ray processing unimplemented");
31 >        ray_pdone(0);
32 >        ray_init(otnm);
33 >        ray_popen(nproc);
34   }
35  
36  
# Line 33 | Line 39 | ray_psend(                     /* add a ray to our send queue */
39          RAY     *r
40   )
41   {
42 <        error(CONSISTENCY, "parallel ray processing unimplemented");
42 >        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   }
49  
50  
# Line 42 | Line 53 | ray_pqueue(                    /* queue a ray for computation */
53          RAY     *r
54   )
55   {
56 <        return(0);
56 >        if (r == NULL)
57 >                return(0);
58 >        if (ray_pnidle <= 0) {
59 >                RAY     new_ray = *r;
60 >                *r = queued_ray;
61 >                queued_ray = new_ray;
62 >        }
63 >        samplendx++;
64 >        rayvalue(r);
65 >        return(1);
66   }
67  
68  
# Line 52 | Line 72 | ray_presult(           /* check for a completed ray */
72          int     poll
73   )
74   {
75 <        return(-1);
75 >        if (r == NULL)
76 >                return(0);
77 >        if (ray_pnidle <= 0) {
78 >                *r = queued_ray;
79 >                samplendx++;
80 >                rayvalue(r);
81 >                ray_pnidle = 1;
82 >                return(1);
83 >        }
84 >        return(0);
85   }
86  
87  
# Line 61 | Line 90 | ray_pdone(             /* reap children and free data */
90          int     freall
91   )
92   {
93 +        ray_done(freall);
94 +        ray_pnprocs = ray_pnidle = 0;
95   }
96  
97  
# Line 69 | Line 100 | ray_popen(                     /* open the specified # processes */
100          int     nadd
101   )
102   {
103 <        error(CONSISTENCY, "parallel ray processing unimplemented");
103 >        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   }
110  
111  
# Line 78 | Line 114 | ray_pclose(            /* close one or more child processes */
114          int     nsub
115   )
116   {
117 +        if (nsub > ray_pnprocs)
118 +                nsub = ray_pnprocs;
119 +        ray_pnprocs -= nsub;
120 +        if ((ray_pnidle -= nsub) < 0)
121 +                ray_pnidle = 0;
122   }
123  
124  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines