Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Concurrency recommendations

Date2010-08-19 15:40
FromTim Blechmann
SubjectRe: [Cs-dev] Concurrency recommendations
hi,

> Check to see if GCC has a multi-threaded allocator, if it has one use it.

google provides a thread-caching memory allocator, that is optimized for 
concurrent programs [1]. for real-time audio synthesis, i would suggest not 
to allocate any memory from the audio thread, unless you are using a pre-
allocate memory pool ...

> Check to see if GCC supports processor affinity, if it does use it.

it is actually os-dependent. on linux, i am using this code [2] ... 


> We probably have an issue with false sharing in output opcodes,
> busses, etc. False sharing occurs when updates from different threads
> within same cache line, even if to different locations within that
> line, invalidate the line and cause a reload. On Intel Core processors
> the cache line size is 64 bytes, that is 16 float mono sample frames
> or 4 double stereo sample frames. False sharing is common and hard to
> deal with. One possible solution is to to pad the opcode buffers so
> each element is sure to span an entire cache line, i.e. each sample in
> the buffer array is actually 128 bytes in size. Then the driver
> routines can collect data from the padded buffers. But it would be
> nice to know if we really do have this problem before trying to solve
> it. I am searching for ways to find out.

faust is using a work-stealing scheduler to reduce the contention of the 
scheduler queues ... this may be interesting as well ...

tim

[1] http://goog-perftools.sourceforge.net/doc/tcmalloc.html
[2] http://tim.klingt.org/git?p=nova-tt.git;a=blob;f=nova-
tt/thread_affinity.hpp;hb=HEAD
[3] http://lac.linuxaudio.org/2010/download/faust-LAC-2010.pdf

-- 
tim@klingt.org
http://tim.klingt.org

A paranoid is a man who knows a little of what's going on.
  William S. Burroughs



------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net