Thursday, January 14, 2016

Publish the source code and optimized reported




            


To honor my commitment

T2050 notebook in the test results of single-precision double precision 0.671 seconds: 0.312 seconds

Other experts want to see code learn! :)

Download the following

http://www.pudn.com/downloads68/sourcecode/windows/other/detail244074.html
Reply:
The landlord, your source to register vip still doing XXX, XXX do to download, too much trouble ~ ~ ~ can send a copy to my mailbox? lanphaday@126.com
Thank you.

My report and code is open, you can download my blog.
Reply:
You should not be able to download it directly
Reply:
Another address

http://download.csdn.net/down/160775
Reply:
----------------- Begin -----------------
Double MODE = 2
0: Potential: 686445.9565352
10: Potential: 280129.9852357
20: Potential: 206437.9449030
30: Potential: 170828.5177899
40: Potential: 147831.4599590
50: Potential: 133650.1392165
60: Potential: 122234.9888389 ----------------->?
70: Potential: 114473.8684963
80: Potential: 106560.9887753 ----------------->?
90: Potential: 99199.0808710
100: Potential: 93318.9772015
110: Potential: 89056.6733336
120: Potential: 85229.7706144
130: Potential: 82200.7831734
140: Potential: 79693.6008187
150: Potential: 77797.8899493
160: Potential: 75235.8488249
170: Potential: 73208.5403272
180: Potential: 71404.9412059
190: Potential: 69980.3005699
200: Potential: 68477.5907029
Seconds = 0.938000000
Double MODE = 2
------------------ End ------------------

Instructions: CodeSpeed [1 | 2]
SSE_FLOAT usage: CodeSpeed 1
SSE_DOUBLE usage: CodeSpeed 2

-------------------------------------- Download reports and procedures, the landlord compilation really Strong!


Reply:
This is lanphaday (love admiral) program
0: Potential: 686445.9565352
10: Potential: 280129.9852357
20: Potential: 206437.9449030
30: Potential: 170828.5177899
40: Potential: 147831.4599590
50: Potential: 133650.1392165
60: Potential: 122234.9888390 -----------
?70: Potential: 114473.8684963
80: Potential: 106560.9887754 -----------
?90: Potential: 99199.0808710
100: Potential: 93318.9772015
110: Potential: 89056.6733336
120: Potential: 85229.7706144
130: Potential: 82200.7831734
140: Potential: 79693.6008187
150: Potential: 77797.8899493
160: Potential: 75235.8488249
170: Potential: 73208.5403272
180: Potential: 71404.9412059
190: Potential: 69980.3005699
200: Potential: 68477.5907029
Seconds = 1.500000000
Press any key to continue...

I do not know the accuracy of which right?
Reply:
He did not pay attention to this problem I have I just compared the first and last of precision
But CodeSpeed inside to ensure the accuracy of algorithms
Reply:
E: \ IntelPro \ XSpeed & gt; xspeed
----------------- Begin -----------------
Double MODE = 2
0: Potential: 686445.9565352
10: Potential: 280129.9852357
20: Potential: 206437.9449030
30: Potential: 170828.5177899
40: Potential: 147831.4599590
50: Potential: 133650.1392165
60: Potential: 122234.9888389 -----------------
?70: Potential: 114473.8684963
80: Potential: 106560.9887754
90: Potential: 99199.0808710
100: Potential: 93318.9772015
110: Potential: 89056.6733336
120: Potential: 85229.7706144
130: Potential: 82200.7831734
140: Potential: 79693.6008187
150: Potential: 77797.8899493
160: Potential: 75235.8488249
170: Potential: 73208.5403272
180: Potential: 71404.9412059
190: Potential: 69980.3005699
200: Potential: 68477.5907029
Seconds = 0.671000000
Double MODE = 2
------------------ End ------------------

Instructions: CodeSpeed [1 | 2]
SSE_FLOAT usage: CodeSpeed 1
SSE_DOUBLE usage: CodeSpeed 2

Finally, I ran this line has only 0.0000001 error
It seems with the Processor For

Reply:
And the CPU is concerned. Documents on Intel also said so.
Reply:
I was using single precision __mm_rsqrt_ps Newton descent method to improve accuracy and increase the accuracy and then double Newton descent method
Reply:
If twice, and then double again to improve the accuracy of Newton descent method can ensure the accuracy

Reply:
200: Potential: 68477.5907029
Seconds = 1.500000000
Press any key to continue...


------------------------------------
I so slow? On my machine it seems not so oh. . . .
Reply:
I see you use 0x5fe6ec85e7de30da this worth it.
But this is only theoretical CHRIS LOMONT mentioned optimal value. After multiple iterations are not optimum. Use this value to be 4 times the Newton iteration to meet accuracy.
Select more magic number multiplied by an offset, you can do three iterations to achieve accuracy.
Use rsqrtps plus Newton iteration 2 iterations can be done to achieve accuracy.
I also use rsqrtps plus Newton iteration to do. I just write directly to a compilation.
Also replaced Newton iteration 0.5 -0.5, the subtraction into addition advantageous speed.

Do not RAND_MAX from division optimized to multiply, to its raised, enabling increased speed and accuracy.

Reply:
to lanphaday (Love admiral)
Many are optimized for the CPU on another CPU performance is not necessarily good.

Your cache optimization method, the Core 2 has the situation under 32K L1 cache may not be effective.
Reply:
Thank flyingdog (flyingdog)
You have to let me recommend another long knowledge
Reply:
Actually used SetPriorityClass (hProcess, REALTIME_PRIORITY_CLASS);

The code did not look carefully. But that the results should be good. CPU performance is probably the reason for it.

Reply:
I learned a lot of knowledge
Reply:
Who to my post up a word ah.
Otherwise, the number of restrictions by the reply, can not paste code.
Reply:
huanyun (no wife imprisonment) xspeed accuracy seems a little problem, because the problem does not seem CPU differences.
On the same computer, we tested the results of different programs.
Reply:
to lanphaday (Love admiral)

My machine is a Celeron D331, relatively poor.
Just opened again BT, so run your program only
1.500s
I mainly look at the data, speed is not accurate!
Sorry!
Reply:
Haha, zidongli not kind, it does not matter, anyway, he had submitted reports. . .
Thank you for all reported separately and code, I learned a lot.
Reply:
Thank landlord

Download look at the first
Reply:
Yesterday checked the accuracy of the reasons

__inline double InvSqrt_Nr (double x)
{
double xhalf = 0.5f * x;
__int64 i = * (__ int64 *) & amp; x;
i = 0x5fe6ec85e7de30da - (i & gt; & gt; 1);
x = * (double *) & amp; i;
x = x * (1.5f-xhalf * x * x);
x = x * (1.5f-xhalf * x * x);
x = x * (1.5f-xhalf * x * x);
return x;
}
Less the first iteration can be changed
__inline double InvSqrt_Nr (double x)
{
double xhalf = 0.5f * x;
__int64 i = * (__ int64 *) & amp; x;
i = 0x5fe6ec85e7de30da - (i & gt; & gt; 1);
x = * (double *) & amp; i;
x = x * (1.5f-xhalf * x * x);
x = x * (1.5f-xhalf * x * x);
x = x * (1.5f-xhalf * x * x);
x = x * (1.5f-xhalf * x * x);
return x;
}

Due to the frequency of use of this function only rarely used in XGetComputePotPoint in
__inline double XGetComputePotPoint (int i, int j)
{
int ii = (i & gt; & gt; 1) & lt; & lt; 1;
int jj = (j & gt; & gt; 1) & lt; & lt; 1;
int mm = i & amp; 1;
int nn = j & amp; 1;
return InvSqrt_Nr ((r [ii] [mm] - r [jj] [nn]) * (r [ii] [mm] - r [jj] [nn]) +
(R [ii] [mm + 2] - r [jj] [nn + 2]) * (r [ii] [mm + 2] - r [jj] [nn + 2]) +
(R [ii] [mm + 4] - r [jj] [nn + 4]) * (r [ii] [mm + 4] - r [jj] [nn + 4]));
}
It does not affect the speed




Reply:
If the value of said CHRIS LOMONT of flyingdog (flyingdog) requires four iterations before they can reach 7 accuracy requirements
Reply:
Can you try to use the value three iterations to achieve the required precision.
0x5fe6d250b0000000

I have not tried your program. I had at the time of measurement accuracy found that if all the estimated initial value that way, it would be better to use 0x5fe6d250b0000000.

Reply:
In fact
return InvSqrt_Nr ((r [ii] [mm] - r [jj] [nn]) * (r [ii] [mm] - r [jj] [nn]) +
(R [ii] [mm + 2] - r [jj] [nn + 2]) * (r [ii] [mm + 2] - r [jj] [nn + 2]) +
(R [ii] [mm + 4] - r [jj] [nn + 4]) * (r [ii] [mm + 4] - r [jj] [nn + 4]));
Can this is
return invsqrt ((r [ii] [mm] - r [jj] [nn]) * (r [ii] [mm] - r [jj] [nn]) +
(R [ii] [mm + 2] - r [jj] [nn + 2]) * (r [ii] [mm + 2] - r [jj] [nn + 2]) +
(R [ii] [mm + 4] - r [jj] [nn + 4]) * (r [ii] [mm + 4] - r [jj] [nn + 4]));

I worry not only compiled instead InvSqrt_Nr

Reply:
----------------- 0x5fe6d250b0000000 -----------------
0: Potential: 686445.9565352
10: Potential: 280129.9852357
20: Potential: 206437.9449030
30: Potential: 170828.5177899
40: Potential: 147831.4599590
50: Potential: 133650.1392165
60: Potential: 122234.9888389 -----
?70: Potential: 114473.8684963
80: Potential: 106560.9887754
90: Potential: 99199.0808710
100: Potential: 93318.9772015
110: Potential: 89056.6733336
120: Potential: 85229.7706144
130: Potential: 82200.7831734
140: Potential: 79693.6008187
150: Potential: 77797.8899493
160: Potential: 75235.8488249
170: Potential: 73208.5403272
180: Potential: 71404.9412059
190: Potential: 69980.3005699
200: Potential: 68477.5907029
Seconds = 0.687000000

Use 0x5fe6d250b0000000 still the same


----------------- Begin -----------------
0: Potential: 686445.9565352
10: Potential: 280129.9852357
20: Potential: 206437.9449030
30: Potential: 170828.5177899
40: Potential: 147831.4599590
50: Potential: 133650.1392165
60: Potential: 122234.9888390
70: Potential: 114473.8684963
80: Potential: 106560.9887754
90: Potential: 99199.0808710
100: Potential: 93318.9772015
110: Potential: 89056.6733336
120: Potential: 85229.7706144
130: Potential: 82200.7831734
140: Potential: 79693.6008187
150: Potential: 77797.8899493
160: Potential: 75235.8488249
170: Potential: 73208.5403272
180: Potential: 71404.9412059
190: Potential: 69980.3005699
200: Potential: 68477.5907029
Seconds = 0.687000000

This is the result of four iterations entirely correct in
Reply:
Aye, it appears that under different circumstances, select the magic number is still not the same.
If you are interested, you can try other values, sure to find the right magic number.
I had wanted to be exhaustive, find the best values. But later found rsqrtps easier to use. To give exhaustive up.

Reply:
99% of my calculation algorithm is used to improve the accuracy __mm_rsqrt_ps Newton descent method with single precision and double-precision to improve the accuracy and then Newton descent method so they do not care about the selection
magic number
You can see the four iterations of time did not increase

Further program
me on my test machine to compile and housisong of flyingdogI used to set compiler options is estimated that compiler option I set a bad

flyingdog
200: Potential: 68477.5907029
Seconds = 0.796000000

housisong
200: Potential: 68477.5907029
Seconds = 0.734000000.

My
200: Potential: 68477.5907029
Seconds = 0.687000000


I guess I used SetPriorityClass (hProcess, REALTIME_PRIORITY_CLASS);
Improve the performance



Reply:
We have joined
SetPriorityClass (hProcess, REALTIME_PRIORITY_CLASS) after
flyingdog
200: Potential: 68477.5907029
Seconds = 0.781000000

housisong
200: Potential: 68477.5907029
Seconds = 0.703000000
Reply:
I also want to find exhaustive way a better magic number, has not been successful;
(But did not rule out that if the range of the contest for the problem to find a better magic number;
From my tests against a specific set of data I still be able to find better than 0x5fe6ec85e7de30da number of)
)

Reply:
Magic need to use at least three times the number of iterations
And __mm_rsqrt_ps only twice a float once double

I was to deal with the corner only to use their own data written InvSqrt_Nr
In fact invsqrt intel library can be a
Reply:
cold.
I used Core 2 core CPU, 2G frequency is running, in-line faster than this.
Is Core 2 Duo T2050 compared to how much is strong?
Either I put to you that running exe see.
But I do not know that exe is compiled for the Core 2 Duo. I do not know where you can run Laval.

Reply:

"0.5 -0.5 replaced, the subtraction into addition advantageous speed"

According to my experience, the internal implementation of the CPU, a floating-point add and sub is the same, not the same as the sum of the absolute value of the data \ absolute value subtraction;
(Guess CPU implementation): (-2.5) + (+ 1.5) = & gt; - (2.5-1.5)
(-2.5) + (- 1.5) = & gt; - (2.5 + 1.5)
(+2.5) + (+ 1.5) = & gt; + (2.5 + 1.5)
(+2.5) + (- 1.5) = & gt; + (2.5-1.5)
(-2.5) - (+ 1.5) = & gt; - (2.5 + 1.5)
(-2.5) - (- 1.5) = & gt; - (2.5-1.5)
(+2.5) - (+ 1.5) = & gt; + (2.5-1.5)
(+2.5) - (- 1.5) = & gt; + (2.5 + 1.5)
So the CPU only needs to implement the absolute value of the number of addition and subtraction circuit between;

The "0.5 -0.5 replace" may still be good, because there are exchangeable addition, easier to organize the code; the code in addition to call more than subtraction; it does not exclude the CPU are willing to make some kind of add specificity optimization;









Reply:
Actually, the addition and subtraction is the same.
The difference is, if it is a subtraction, each time first 1.5 load into the register, after subtract when 1.5 was covered, it must load again.
Reply:
I used to compile the 2005 program I put up trouble you find a core 2 running about
My program has not ran :)
on core2
http://download.csdn.net/source/160802
Reply:
My E6600 and xeno 5130 is borrowed.
Now and then run, there are difficulties ah.

Reply:
Pow my part, it is optimized by icc, no assembly optimization. Compiled by vc2005 disadvantage.
Reply:
Faint you can borrow xeno? I've never used those processors cold
Reply:
I use 2005 + icc compiler
Reply:
In fact, how did xeno kind. E6600 and xeno 5130 based on the same core. E6600 2.4G xeno 5130 2.0G
E6600 result was fast.
The xeno on a little faster front-side bus, for this program useless.


I borrowed or double xeno 5130, but also a specially masked before doing the program.

In fact, the key is to cool the nuclear sharp. Otherwise p4 xeno numerous.
Reply:
It is estimated that you use two arrays
rMy t2050 cache is not big enough
Reply:
t2050? Amazing model.
finding out the intel website.
Online search also did not understand what version.
t2050 The L1 cache is how much?
Reply:
Ah dell 640m laptop wants
Reply:
Collect

No comments:

Post a Comment