[TriLUG] Perl and SMP

Andrew C. Oliver acoliver at buni.org
Tue Jun 5 10:20:10 EDT 2007


As Tanner alludes to.  Some things are inherently single threaded.  On 
the other hand some things CAN be auto-parallelize.  One efficiency of 
the Java Virtual Machine, for instance, is that it can parallelize the 
cleaning of memory onto n -1 native threads (n = number of cores).  However:

int x=1;
int y=2;
int n=x+y;
n=n*n-y;
printf("the result is %d",n);

Nothing can be threaded really.  Moreover even if we make x = n and 
stick it in a for loop and count the iterations until x = 1000, it 
probably would take longer to parallelize to to processor scheduling. 
Furthermore, if I/O happens or devices are read or written to then the 
compiler or interpreter has no way of knowing how timing effects the 
solution.  Meaning if I'm writing to the screen from what I code as one 
thread and print two messages, I expect them in the sequence in which 
they are written.

Compilers (see any book on dependence theory) can take things apart and 
parallelize them or schedule them on a single processor (minimizing wait 
states and cycles), and indeed there are structures that can be 
parallelized across processors, but it isn't as much as you imagine -- 
automatically or otherwise.

Intel et al are trying to sell us increasing numbers of cores for our 
desktops, but in truth relatively few desktop apps are going to scale 
beyond 4 cores.  Serverside apps often benefit in terms of the number of 
users, but even then other constraints limit us (memory, I/O, bandwidth, 
etc).

-Andy

Tanner Lovelace wrote:
> On 6/4/07, Andrew Perrin <clists at perrin.socsci.unc.edu> wrote:
>> Well, definitely *not* being a computer science type, I could imagine a
>> "smart" interpreter that would open as many threads as there were
>> processors, then assign particular tasks to each process and return them
>> to the main, thereby making the threading transparent to the user/process.
>> I assume this has been thought of and either implemented or rejected for a
>> good reason, but that's what I was thinking about.
>>
>> Andy
> 
> Andy,
> 
> That assumes there is more than one task.  What if there
> is only one?  Or what if there are several, but there are dependencies
> among them?  How is the computer supposed to know without
> someone telling it that?
> 
> If it's a standard perl program, though, chances are that there is
> only one task and it goes from beginning to end.  It may happen
> over and over but once again, how is the computer supposed to
> know that without anyone telling it.
> 
> Cheers,
> Tanner


-- 
Buni Meldware Communication Suite
http://buni.org
Multi-platform and extensible Email,
Calendaring (including freebusy),
Rich Webmail, Web-calendaring, ease
of installation/administration.



More information about the TriLUG mailing list