Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Multi-threading

Date2008-06-22 12:31
FromMichael Gogins
SubjectRe: [Cs-dev] Multi-threading
OK, I will look at the other Csound API threading functions and see if there are more re-implementations that can be replaced by native calls.

Thanks,
Mike


-----Original Message-----
>From: Felipe Sateler 
>Sent: Jun 21, 2008 4:25 PM
>To: Developer discussions 
>Subject: Re: [Cs-dev] Multi-threading
>
>Now I get this:
>
>Elapsed time at end of score sort: real: 0.050s, CPU: 0.010s
>Multithread performance: insno:  -1  thread -1 of 2 starting.
>Multithread performance: insno:  -1  thread -1 of 2 starting.
>
>Attached is the full log. The Csound tidy up: Interrupt lines are when I kill 
>the process via ctrl+c
>
>El 21/06/08 15:19 Michael Gogins escribió:
>> I also tested on Windows with 2 threads, but got no deadlock.
>>
>> My trace shows:
>>
>> Multithread performance: insno:  -1  thread 1 of 2 starting.
>> Multithread performance: insno:  -1  thread 0 of 2 starting.
>>
>> Your trace shows:
>>
>> Multithread performance: insno:  -1  thread -1 of 2 starting.
>> Multithread performance: insno:  -1  thread 0 of 2 starting.
>>
>> I think this is a clue to the problem. I have attached my test csd. Try it
>> and see if you still get the "thread -1". We already know that the
>> partitioning arithmetic is no good for odd numbers of instances. That
>> should be easy to fix, but I haven't done it yet.
>>
>> Thanks for looking at this,
>>
>> Mike
>>
>>
>>
>>
>> -----Original Message-----
>>
>> >From: Felipe Sateler 
>> >Sent: Jun 21, 2008 4:42 AM
>> >To: Developer discussions 
>> >Subject: Re: [Cs-dev] Multi-threading
>> >
>> >I'm still getting a deadlock. Scons said that the pthread_barrier_*
>> > functions are available. This is the output:
>> >
>> >% OPCODEDIR=. ./csound -o/dev/null -v --num-threads=2 examples/am.csd
>> >time resolution is 1000.000 ns
>> >PortAudio real-time audio module for Csound
>> >0dBFS level = 32768.0
>> >Csound version 5.08.91 beta (float samples) Jun 21 2008
>> >libsndfile-1.0.17
>> >decode_long num-threads=2
>> >Reading options from $HOME/.csoundrc
>> >UnifiedCSD:  examples/am.csd
>> >Environment variable 'SADIR' has been set
>> >to '/home/felipe/src/deb/csound/cvs/csound5/examples'
>> >Environment variable 'SSDIR' has been set
>> >to '/home/felipe/src/deb/csound/cvs/csound5/examples'
>> >Environment variable 'INCDIR' has been set
>> >to '/home/felipe/src/deb/csound/cvs/csound5/examples'
>> >Environment variable 'MFDIR' has been set
>> >to '/home/felipe/src/deb/csound/cvs/csound5/examples'
>> >STARTING FILE
>> >Creating options
>> >Creating orchestra
>> >Creating score
>> >decode_long num-threads=2
>> >orchname:  /tmp/fileuDdaTd.orc
>> >scorename: /tmp/fileXx5eNw.sco
>> >rtaudio: PortAudio module enabled ... using blocking interface
>> >orch compiler:
>> >8 lines read
>> >LINE 7:
>> >LINE 8:
>> >groups: instr 1
>> >        endin
>> >pmax 3, kcnt 0, wcnt 0, acnt 0, pcnt 0, scnt 0
>> >        instr   1
>> >LINE 9:
>> >groups: k2 oscil 10000 1 1
>> >modified opcod: oscil.kk
>> >treqd o, tfound c
>> >treqd i, tfound c
>> >treqd k, tfound c
>> >treqd k, tfound c
>> >xincod = 0
>> >treqd s, tfound k
>> >k2      oscil.kk        10000   1       1       0
>> >LINE 10:
>> >groups: a1 oscil 10000+k2 120 1
>> >10000   +       k2
>> >10000   k2      +
>> >treqd k, tfound k
>> >treqd k, tfound c
>> >xincod = 0
>> >treqd k, tfound k
>> >#k0     add.kk  10000   k2
>> >modified opcod: oscil.kk
>> >treqd o, tfound c
>> >treqd i, tfound c
>> >treqd k, tfound c
>> >treqd k, tfound k
>> >xincod = 0
>> >treqd s, tfound a
>> >a1      oscil.kk        #k0     120     1       0
>> >LINE 11:
>> >groups: chano a1 1
>> >modified opcod: chano.a
>> >treqd k, tfound c
>> >treqd a, tfound a
>> >xincod = 1
>> >        chano.a a1      1
>> >LINE 12:
>> >groups: out a1
>> >treqd a, tfound a
>> >xincod = 1
>> >        out     a1
>> >LINE 13:
>> >groups: endin
>> >        endin
>> >pmax 3, kcnt 2, wcnt 0, acnt 1, pcnt 0, scnt 0
>> >LINE 14:
>> >poolcount = 4, strpool_cnt = 1
>> >pool:   0       1       10000   120
>> >strpool:        ""
>> >oscil.kk argndxs:       -4      3       2       2       1
>> >add.kk argndxs: -5      3       -4
>> >oscil.kk argndxs:       -6      -5      4       2       1
>> >chano.a argndxs:        -6      2
>> >out argndxs:    -6
>> >argoff array:
>> >        0       1       -4      4       3       2       2       1
>> >1      -5       2       3       -4      1       -6      4       -5      4
>> >2      12       -6      2       1       -6
>> >Elapsed time at end of orchestra compile: real: 0.010s, CPU: 0.010s
>> >sorting score ...
>> >        ... done
>> >Elapsed time at end of score sort: real: 0.010s, CPU: 0.010s
>> >Multithread performance: insno:  -1  thread -1 of 2 starting.
>> >Multithread performance: insno:  -1  thread 0 of 2 starting.
>> >Csound version 5.08.91 beta (float samples) Jun 21 2008
>> >Creating search path cache for 'SNAPDIR':
>> >Creating search path cache for 'SFDIR;SSDIR;INCDIR':
>> >    1: "/home/felipe/src/deb/csound/cvs/csound5/examples/"
>> >Creating search path cache for 'SFDIR':
>> >Creating search path cache for 'SADIR':
>> >    1: "/home/felipe/src/deb/csound/cvs/csound5/examples/"
>> >Creating search path cache for 'SFDIR;SSDIR':
>> >    1: "/home/felipe/src/deb/csound/cvs/csound5/examples/"
>> >displays suppressed
>> >esr = 44100.0, ekr =  4410.0, ksmps = 10, nchnls = 1 0dbfs = 32768.0
>> >lclabeg 4, lclsbeg 4
>> >lclabeg 6, lclsbeg 7
>> >0dBFS level = 32768.0
>> >instr 0 allocated at 0x1f21b30
>> >        lclbas 0x1f21be8, opds 0x1f21be8
>> >orch now loaded
>> >audio buffered in 1024 sample-frame blocks
>> >writing 2048-byte blks of shorts to /dev/null (WAV)
>> >SECTION 1:
>> >ftable 1:
>> >activating instr 1
>> >new alloc for instr 1:
>> >instr 1 allocated at 0x1f46de0
>> >        lclbas 0x1f46e98, opds 0x1f46ec8
>> >op 247 (oscil.kk) allocated at 0x1f46ec8
>> >opadr = 0x498f71
>> >argptrs:        0x1f46e98       0x1ef80f8       0x1ef80f4       0x1ef80f4
>> >0x1ef80f0
>> >op 74 (add.kk) allocated at 0x1f46f30
>> >opadr = 0x455250
>> >argptrs:        0x1f46e9c       0x1ef80f8       0x1f46e98
>> >op 247 (oscil.kk) allocated at 0x1f46f78
>> >opadr = 0x499062
>> >argptrs:        0x1f46ea0       0x1f46e9c       0x1ef80fc       0x1ef80f4
>> >0x1ef80f0
>> >op 658 (chano.a) allocated at 0x1f46fe0
>> >opadr = 0x45c546
>> >argptrs:        0x1f46ea0       0x1ef80f4
>> >op 293 (out) allocated at 0x1f47020
>> >opadr = 0x4597c8
>> >argptrs:        0x1f46ea0
>> >psave beg at 0x1f46e8c
>> >   ending at 0x1f46e98
>> >init oscil.kk:
>> >init oscil.kk:
>> >instr 1 now active:
>> >insno   instanc nxtinst prvinst nxtact  prvact  nxtoff  actflg  offtim
>> >0       0x1f21b30       (nil)   (nil)   (nil)   (nil)   (nil)   1      
>> > 0.0 1       0x1f46de0       (nil)   (nil)   (nil)   0x1eef8c8       (nil)
>> >   1 30.0
>> >kperf:            insno:   1                        start: 0x0x1f46de0 
>> > end: 0x(nil)
>> >
>> >El 21/06/08 04:37 Michael Gogins escribió:
>> >> I've got this sort of working, or at least not crashing, on Windows with
>> >> the following changes, which are booked in:
>> >>
>> >> -- Use of native pthread_barrier_* functions, where they exist on the
>> >> build system.
>> >>
>> >> -- Much improved diagnostic messages (visible with -v command-line
>> >> option).
>> >>
>> >> Performance completes and the code, which I now understand, seems
>> >> somewhat correct. But there are still problems:
>> >>
>> >> -- Multi-threaded performance still takes somewhat longer than
>> >> single-threaded performance. It may be that this is due to the overhead
>> >> of barrier calls and threads not being outweighed by the actual savings
>> >> on instrument computations in my test csds. Or it may be that there are
>> >> subtle bugs in the multi-threading code such that things are not
>> >> actually proceeding concurrently, or are doubling, or something (see
>> >> below).
>> >>
>> >> -- Multi-threaded soundfiles show odd increases in amplitude in places,
>> >> suggesting that too many instances are computing audio at the same time
>> >> in some places, but not in other places.
>> >>
>> >> -- The partitioning is not correct. If I have 5 active instances, I get
>> >> 2 partitions with 2 instances each. It should be 2 instances in one
>> >> partition, and 3 instances in another partition.
>> >>
>> >> -- As I noted before, we will need to protect writes to shared buffers,
>> >> especially spout in OOps/aops.c.
>> >>
>> >> Regards,
>> >> Mike
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------
>> >>- Check out the new SourceForge.net Marketplace.
>> >> It's the best place to buy or sell services for
>> >> just about anything Open Source.
>> >> http://sourceforge.net/services/buy/index.php
>> >> _______________________________________________
>> >> Csound-devel mailing list
>> >> Csound-devel@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >Saludos,
>> >Felipe Sateler
>
>
>
>Saludos,
>Felipe Sateler




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound