Thoughts on parallel programming?

sybrandy sybrandy at gmail.com
Thu Nov 11 12:35:40 PST 2010


On 11/11/2010 02:41 PM, Sean Kelly wrote:
> Tobias Pfaff Wrote:
>
>> On 11/11/2010 03:24 AM, jfd wrote:
>>> Any thoughts on parallel programming.  I was looking at something about Chapel
>>> and X10 languages etc. for parallelism, and it looks interesting.  I know that
>>> it is still an area of active research, and it is not yet (far from?) done,
>>> but anyone have thoughts on this as future direction?  Thank you.
>>
>> Unfortunately I only know about the standard stuff, OpenMP/OpenCL...
>> Speaking of which: Are there any attempts to support lightweight
>> multithreading in D, that is, something like OpenMP ?
>
> I've considered backing spawn() calls by fibers multiplexed by a thread pool (receive() calls would cause the fiber to yield) instead of having each call generate a new kernel thread.  The only issue is that TLS (ie. non-shared static storage) is thread-local, not fiber-local.  One idea, however, is to do OSX-style manual TLS inside Fiber, so each fiber would have its own automatic local storage.  Perhaps as an experiment I'll create a new derivative of Fiber that does this and see how it works.

I actually did something similar for a very simple web server I was 
experimenting with.  It is similar to how Erlang works in that the 
Erlang processes are, at least to me, similar to fibers and they are run 
in one of several threads in the interpreter.

The only problem I had was ensuring that my logging was thread-safe.  If 
you could implement a TLS-like system for Fibers, I think that would 
help prevent that issue.

Casey


More information about the Digitalmars-d mailing list