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.2 by greg, Sat Feb 9 00:17:51 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 >        if (nproc > 1)
32 >                error(WARNING, "Only single process supported");
33 >        ray_pdone(0);
34 >        ray_init(otnm);
35 >        ray_popen(nproc);
36   }
37  
38  
# Line 33 | Line 41 | ray_psend(                     /* add a ray to our send queue */
41          RAY     *r
42   )
43   {
44 <        error(CONSISTENCY, "parallel ray processing unimplemented");
44 >        if (r == NULL)
45 >                return;
46 >        if (ray_pnidle <= 0)
47 >                error(INTERNAL, "illegal call to ray_psend");
48 >        queued_ray = *r;
49 >        ray_pnidle = 0;
50   }
51  
52  
# Line 42 | Line 55 | ray_pqueue(                    /* queue a ray for computation */
55          RAY     *r
56   )
57   {
58 <        return(0);
58 >        if (r == NULL)
59 >                return(0);
60 >        ray_value(r);
61 >        return(1);
62   }
63  
64  
# Line 52 | Line 68 | ray_presult(           /* check for a completed ray */
68          int     poll
69   )
70   {
71 <        return(-1);
71 >        if (r == NULL)
72 >                return(0);
73 >        if (!poll & (ray_pnidle <= 0)) {
74 >                ray_value(&queued_ray);
75 >                *r = queued_ray;
76 >                ray_pnidle = 1;
77 >                return(1);
78 >        }
79 >        return(0);
80   }
81  
82  
# Line 61 | Line 85 | ray_pdone(             /* reap children and free data */
85          int     freall
86   )
87   {
88 +        ray_done(freall);
89 +        ray_pnprocs = ray_pnidle = 0;
90   }
91  
92  
# Line 69 | Line 95 | ray_popen(                     /* open the specified # processes */
95          int     nadd
96   )
97   {
98 <        error(CONSISTENCY, "parallel ray processing unimplemented");
98 >        if (ray_pnprocs + nadd > 1) {
99 >                error(WARNING, "Only single process supported");
100 >                nadd = 1 - ray_pnprocs;
101 >        }
102 >        ray_pnprocs += nadd;
103 >        ray_pnidle += nadd;
104   }
105  
106  
# Line 78 | Line 109 | ray_pclose(            /* close one or more child processes */
109          int     nsub
110   )
111   {
112 +        if (nsub > ray_pnprocs)
113 +                nsub = ray_pnprocs;
114 +        ray_pnprocs -= nsub;
115 +        if ((ray_pnidle -= nsub) < 0)
116 +                ray_pnidle = 0;
117   }
118  
119  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines