Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-15-2010, 02:41 PM
blmille2
Sarnak
 
Join Date: Apr 2007
Location: Austin, TX
Posts: 64
Default Potential speed increase

Hello, guys.
I was thinking about the following:
stat += 100 * stat * modifier / 100

Now, I know why it's being used -- it's integer multiplication and division, which is way faster than floating point calculations.

Here's my idea:
stat += ((stat << 7) * modifier) >> 7

With this, you have only one integer multiplication instead two multiplications and one division.

I used to TA an assembly course at UIUC and we learned that integer shifts can be done in one clock cycle and integer multiplication can take quite a few clock cycles.

When I did verification simulations at AMD, I also verified that it takes multiple clock cycles on integer math (except for addition/subtraction) and AMD had the fastest ALU at the time.

However, shifts have always been able to be done in one clock cycle, guaranteed.

I know that 100 is a nice number to multiply by, but since its only use is to do a somewhat accurate integer percent calculation, I recommend doing a shift left (or right) by 7, which is multiplying by 128 and dividing my 128, only loads faster.

In the end, you're multiplying the whole equation by 1.

What is your opinion on this?

Thanks!
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:19 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3