dynamic hopping

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2009
Posts: 6
Reputation: lukhash is an unknown quantity at this point 
Solved Threads: 0
lukhash lukhash is offline Offline
Newbie Poster

dynamic hopping

 
0
  #1
Jun 17th, 2009
Hi, I was wondering how to dynammicly hop a stream, as opposed to this static hop.

streamin hopwiththis;
streamin in;
streamout out;

mov eax,ecx;

and eax,1023;
cmp eax,0;
jnz end0;

movaps xmm0,in;
movaps out,xmm0;

end0:
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: dynamic hopping

 
0
  #2
Jun 17th, 2009
I'm not exactly sure what you're asking for as in reference to static vs dynamic hop, but in your assembly you don't need the compare instruction as the and operation will result in the zero flag set!

You only show the code snippet but you can combine your code even more easily!

;
test ecx,(1024-1);
jnz end0;

Note that test is a read-only and operation. And AND is performed but the result is not written to the register. You also don't have to use only the eax register unless you're using a very old 80x86 processor. this also means the function is faster as there is no stall waiting for the value to be written back into the register before that register is read again for the compare.

In this particular case you used an immediate value bit mask of (2^N)-1 which is typically used for rolling over back to the origin again.

You can also TEST to a register so that the masking value is contained within a register such as

test ecx,edx
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: lukhash is an unknown quantity at this point 
Solved Threads: 0
lukhash lukhash is offline Offline
Newbie Poster

Re: dynamic hopping

 
0
  #3
Jun 17th, 2009
The purpose was to convert a stream to mem, to be used for the hop size. Thisway I can use the null or a bigger hop to adjust the cycles. Wich would block streams out of processing/slow them down.
Excuse me for asking newby questions btw.
This is my 2nd day assembling.

If I understand correctly the way described above has the same functionality, with less cycles.
But.. How do I get the stream linked to the hopsize?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: lukhash is an unknown quantity at this point 
Solved Threads: 0
lukhash lukhash is offline Offline
Newbie Poster

Re: dynamic hopping

 
0
  #4
Jun 18th, 2009
my programmer, demands I do it like the initial example.
I think Yust Oldstyle. How could i make the hopsize vary, and how do I set it to null.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: dynamic hopping

 
0
  #5
Jun 18th, 2009
Then to help you I need clarity. Stream can mean many things. A disk file that is read N bytes at a time. Or a file in memory acting similar to a virtual file where blocks of memory are skipped such as parsing a TIFF file, reading a header, and ignoring a chunk so skipping over a block of memory by advancing the memory pointer the number of bytes wished to skip. But you keep using plural indicating there are multiple of these 'files' but I really don't understand what you keep referring to as 'hop' other then skipping (seeking) over N bytes of memory. If this is the case you can pass the number of bytes to skip in, then adjust your pointer by those bytes. You used a mask of 2^10 - 1 = 1023 which implies you're reading from a cache? or is that your block size?

There are two ways to jump to set block size! If the size trying to jump is 2^N then you can use an AND operation.

#define ALIGN1024( len ) (( len + 1023 ) & ~1023 ) // round up to 1024
And the following where N is 2^N
#define ALIGN_N( len, N ) (( len + (N-1) ) & ~(N-1) ) // round up to 128bits

But if not 2^N then you have to use a modulo method!

Essentially a remainer, but I don't know if this is what you really are requesting!

y = (( (x + (R-1)) / R ) * R);

You can also do this with a modulo instead of relying on the integer result of the division to round up?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: lukhash is an unknown quantity at this point 
Solved Threads: 0
lukhash lukhash is offline Offline
Newbie Poster

Re: dynamic hopping

 
0
  #6
Jun 18th, 2009
The streams coming in are audio streams at samplerate.
typically44100 or 88200 Hz.
I was trying to reduce the processing, by taking the code out of processing when the result of "some comparrison" ==0.

basicly becouse I have two sepperate halves of sound switching back and forth.

The hop refers to the speed at wich processing is done.
My other thought would be to have it at 1(normal speed) when active.
And 4096 when not active.
So it should be more efficient.

But if the option exists, to skip processing untill called uppon again.
That would be my main objective.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: lukhash is an unknown quantity at this point 
Solved Threads: 0
lukhash lukhash is offline Offline
Newbie Poster

Re: dynamic hopping

 
0
  #7
Jun 19th, 2009
  1. movaps WTME=xmm1;
  2.  
  3. */ WTME is a float, that I have availabile.
  4. jump from null should be on (WTIME!= 0), "is not zero"
  5. /*
  6. ////////////////////////////////////////// I have this..
  7.  
  8. mov eax, "MY FUNCTION" [0];
  9. shl eax,1;jz end;
  10.  
  11. "MY CODE"
  12.  
  13. end:
  14.  
  15. //////////////////////////////////////////// Or this..
  16.  
  17. float temp=0;
  18.  
  19. push eax;
  20. movaps xmm7,MY FUNCTION;
  21. movaps temp,xmm7;
  22. fld temp[0];
  23. fistp temp[0];
  24. mov eax,temp[0];
  25. cmp eax,0;
  26. jnz end0;
  27.  
  28. "MY CODE"
  29.  
  30. end0:
  31. pop eax;
  32.  
  33. /////////////////////////////////////////////////


To clarify what I have here, WTME is a float.
Somehow, i`d like (prefferably the 2nd code) to detect when WTME
is zero, to set the hop to zero.
I`ve managed to do this but it didn`t work nicely at all.
It did save cpu.
So.. what would be the right way to go about retrofitting this peice of code to my float?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: dynamic hopping

 
0
  #8
Jun 19th, 2009
You only show a snippet of single stream logic?
But here are a few things to come to mind!

Is your memory 128-bit aligned? You are using the MOVAPS instruction which requires memory to be aligned. If unsure or if not aligned use the slower MOVUPS instead.

Note, you aren't using the register to look at the data so you can use any load instruction!

Also interlace those load-save instructions. You're stalling the processor waiting for the load to complete!

You're burning time converting the near 0.0 to integer 0. Can you do this another way or are you intentionally trying to find where a wave form passes through the zero amplitude. (Of course, if you're cropping the wave at that point, don't forget to change the data value to pure zero or you'll get a popping sound!

Just a thought. To save some speed try to use a pre-mask on the data.

mov eax, Source Memory

TEST eax,07ffff00
jnz continuework

Note I loaded memory from the source memory not the destination memory. This way I don't have to wait for the data to be written first so no instruction stall!

Also I used an integer mask so if I'm obviously not near zero, other bits exist, then no need to spend time tasking the FPU with push pop work.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: dynamic hopping

 
0
  #9
Jun 19th, 2009
Of course don't forget to do your really close zero logic.

And alternatively you're using a SIMD operation thus loading 128 bits. (4 32-bit SPFP values) So why not clear the sign bit, and then compare all four simultaneously to a near floating point zero? 4 flags will be set/clear. If one is set indicating less then, then do the extra work to figure which one!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: lukhash is an unknown quantity at this point 
Solved Threads: 0
lukhash lukhash is offline Offline
Newbie Poster

Re: dynamic hopping

 
0
  #10
Jun 20th, 2009
Funny I never Knew where that came from.
In this case I use the 128bit registers sequentially.
(It`s pre assembled from other code so no harm done here).
In another case i don`t. That means i can cut that patch
by three quarters. including mask it again.
Im going to check this out for now.. trying to get it assembled.
I`ll get back to it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC