Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

stream routing matrix in dsp code!?

DSP related issues, mathematics, processing and techniques

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Mon Dec 15, 2014 12:24 pm

thank you martin, the 16 byte alignment is a good thing, it can be used for the connections too..

i just found out that the zero initialising for the targets is needed! could a loop be used for this?

i still think it should be possible to to use KG's methode for int inputs for the ASM module to getting rid of the conversion to int?

just couldn't figure it out
Last edited by Nubeat7 on Sun Aug 02, 2015 6:53 am, edited 1 time in total.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Mon Dec 15, 2014 4:47 pm

well, tested this in "reallife" and performance is very good, no difference to the bussystem! :) and ways faster on presetchanges.. thank you very much martin and KG!

without the conversion to int for the connection indexes there could still be saved 6-8 cycles for each connection! which is a lot when having more connections...
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby martinvicanek » Mon Dec 15, 2014 5:32 pm

Can't you do the int conversion in Ruby? I mean you probably won't be changing connections at 44 kHz. :mrgreen:
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Mon Dec 15, 2014 6:29 pm

yes thats what i want to do but i dont know how? in the last example above i tried to do this but with no success.. i think it is becasue KG's code saves 2 16byte integers on one 32byte place, but then when i split the converted int array inside ruby to the single outputs i get wrong values.. or i'm doing something else in a wrong way...

i also tried to use a loop to assign the targets to zerobut i don't know if a loop would be faster then writing down each line?
Last edited by Nubeat7 on Sun Aug 02, 2015 6:55 am, edited 1 time in total.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby Tronic » Mon Dec 15, 2014 11:46 pm

in your module "int 16 byte alignment"
Code: Select all
def event i,v
  @in.each_with_index {|x,id|
  output id, [x*16].pack('L').unpack('F')[0]
  }
end

Now the Float is an Integer(float) value

in your ASM code
replace every cvtps2dq with simple movaps xmm0, yourVAR;
Code: Select all
...
// connection 0
//cvtps2dq xmm0,idxs0; // ** replaced
movaps xmm0,idxs0;     // ** with this line
movd eax,xmm0;
movaps xmm2,s[eax];
...
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Tue Dec 16, 2014 10:03 am

thank youu very much tronic, thats what i was looking for :)
Last edited by Nubeat7 on Sun Aug 02, 2015 6:56 am, edited 1 time in total.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby martinvicanek » Tue Dec 16, 2014 1:44 pm

Nubeat7 wrote:[...]now i think it is optimized to the absolute limit :)
Sorry if I am being pedantic, but you could still squeeze out a few cycles by rearranging the initialisation (reusing eax):
Code: Select all
streamin source0; streamin source1;
streamin idxs0;   streamin idxs1;
streamin idxt0;   streamin idxt1;

streamout target0;streamout target1;
streamout target2;streamout target3;

float t[4];float s[2];float F0=0;
int I0=0;  int I1=16;   // 16 Bytes alignment already in
int I2=32; int I3=48;

//init source and target arrays
movaps xmm0,F0; mov eax,I0[0]; movaps t[eax],xmm0;
movaps xmm0,source0; movaps s[eax],xmm0;
mov eax,I1[0]; movaps t[eax],xmm0;
movaps xmm1,source1; movaps s[eax],xmm1;
mov eax,I2[0]; movaps t[eax],xmm0;
mov eax,I3[0]; movaps t[eax],xmm0;
               
// connection 0
mov eax,idxs0[0]; movaps xmm2,s[eax];
mov eax,idxt0[0]; movaps t[eax],xmm2;

// connection 1
mov eax,idxs1[0]; movaps xmm2,s[eax];
mov eax,idxt1[0]; movaps xmm3,t[eax];
addps xmm2,xmm3; movaps t[eax],xmm2;

//assign outputs
mov eax,I0[0]; movaps xmm0,t[eax]; movaps target0,xmm0;
mov eax,I1[0]; movaps xmm1,t[eax]; movaps target1,xmm1;
mov eax,I2[0]; movaps xmm2,t[eax]; movaps target2,xmm2;
mov eax,I3[0]; movaps xmm3,t[eax]; movaps target3,xmm3;

Using a koop wold be slightly worse on CPU because of the index processing overhead. So if you know the loop length, it is faster to unroll the loops.
How are you going to treat unused connections?
One more thought: have you considered index boundery checking the user inputs I0 through I4? Maybe in the Ruby module so it doesn't affect efficiency?
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Wed Dec 17, 2014 1:23 am

martinvicanek wrote:Sorry if I am being pedantic, but you could still squeeze out a few cycles by rearranging the initialisation (reusing eax):

that is is one important charactaristics you need to have when its about optimizing :)

about the index boundery checking, yes it needs to be done in ruby, when using the cablepatcher you cannot be outside anyway as long you listed all sources, targets and connections and when you have set the arrays to the right size, but sure like it is atm it could be dangerous to use it when you don't know what you are doing..
i will update the cablepatcher with the asm matrix soon, also the cablepatcher needs to be modified a little bit to fit well for the asm matrix

unused connections are set to source0 and target0 which is just a dummy at the target and with zero at the source, you think this is a good solution?

Ps.: thank for the clarification about the loop.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Previous

Return to DSP

Who is online

Users browsing this forum: No registered users and 46 guests