c++ - How to increase speed of code in VS 2008 -
I have a piece of code that is called a lot of time, how can I increase it?
#define SUM_ (p0, p1, p2, p3, offset) ((p0) [offset] - (p1) [offset] - (p2) [offset] + (p 3) [Offset]) Inline at Calc :: Compute (int offset) const {int b = SUM (p [5], p [6], p [9], p [10] offset); Int a1 = SUM (...); Int a2 = SUM (...); .... return (uchar) (((a1> = b) = b) = B) & lt; 5) | ((a4> = b) & lt; 4) | ((a5> = b) & lt; 3) | ((a6> = B) & lt; & lt; 2) | ((A7 = B =) = B)); }
Thanks.
I get 3 possible opportunities here:
Code> # defined SUM_ (array, offset) - array [offset + 1] - array [Offset + 2] + array [offset + 3]) .... make sure all p0, p1, ... in pArray value int a1 = SUM (pRR, offset);
uint8_t bitmask = 0; If (A1> = B) bitmask. = 0x80; If (A2> = B) bitmask = 0x40; ...
Try to make sure that the SIMD instructions are being used in it involving dumping the assembly and see if these instructions continue Whether or not they are being done.
Revolves to reach. One problem with your original code is that you solve the offset with your P-variables.
Then you have something like:
int b = SUM (p [5], p [6], p [9], p [10], _offet ); Int a1 = SUM (p [0], p [1], p [4], p [5], _offet); Int a2 = SUM (p [1], p [2], p [5], p [6], _offet);
You can create an array that keeps these values in use in that order.
So I try to create an array that has a fixed offset:
p [5], p [6], p [9], p [10] ], P [0], p [1], p [4], p [5]], p [1], p [2], p [5], p [6]
And now you can define your yoga function like this:
array [offset + calculation offset * 4 + 2] + array [offset + count offset] [code offset + count obsolete * 4 + 3])
Your calls may change in:
int b = sum (pArray, offset, 0); Int a1 = SUM (PRR, offset, 1); Int a2 = SUM (PARRA, Offset, 2);
There is only one problem with this: if you create an array and copy all the data to each function call, it can remove any benefit we have made, but Before you use this function, create such an array and pass it as argument.
Comments
Post a Comment