Experiment
As one hour of machine time to turn into one second
index.htm - Russian text
eksperiment.zip - archived directory
Production of the task. Here there is a combination of two previous examples: solve and scp2int.
1. The program scp3int.java - decides the system of simple equations. The specialization happens on a matrix of coefficients. In the given example the concrete example - generalized sequence of Fibonacci is considered. If the size of a matrix dim=n, each successor is peer to the sum n previous. For example, at dim=3 the matrix is those
( 1 1 1) ( 1 0 0) ( 0 1 0)
At multiplying her on a column
( a ) ( b ) ( c )
The column is received
( a + b + c ) ( a ) ( b )
The program scp3int.java on given second column finds a unknown first column.
2. In the program scp3int.java usual arithmetic operations add, sub, mul, div are exchanged with the operation addKorl, subKorl, mulKorl, divKorl, each of which converts the real arguments into complex numbers and accesses to the appropriate function of the package Complex, and then keeps only real part of outcome.
3. The package Complex is converted into the package ComplexKorl - there at execution of arithmetic operations above complex numbers at first arguments are conversed to matrixes 2 on 2, then there is a call to the appropriate function of the package Jama, the matrix of outcome is conversed to a complex number.
The given example wears experimental character. Certainly, anybody so to not make begins. I attempt to simulate a quite actual situation at usage of ready Java-packages, when one packages access by the operation to other packages.
Now I conduct experiment of step-by-step supercompilation of this task. Direct supercompilation transited successfully, but occupied more time.
We suppose dim=10.
The initial program scp3int in the head directory, dim=10. iters=1000, run time - 18.4 seconds.
Supercompilation a method addKorl also I exchange it in the source program,
Supercompilation a method subKorl also I exchange it in the source program,
Supercompilation a method mulKorl also I exchange it in the source program,
Supercompilation a method divKorl also I exchange it in the source program,
The obtained program scp3int is in a subdirectory Result.
I add zero in iters, the run time - 0.57 seconds (means - 0.057 seconds). Acceleration - 263 times.
Now supercompilation the obtained program in the directory Result (method test) also I seat it in a subdirectory Result2. I add two zero in iters (only three zero), the run time - 0.9 seconds (means - 0.0009 seconds).
If now to divide 18.4 seconds into 0.0009 seconds, the acceleration 20440 times (20 thousand) will be received.
The first four supercompilations went fast and occupied shares of second. Last has taken supercompilations 19 seconds.
Let's reduce the residual program for dim=5
//-------------------------------------- 2 sec - postprocessing... public static void test () { final double scp3Int_b_0_22 = Scp3Int.b[0]; final double bb_1_312 = Scp3Int.b[1] - scp3Int_b_0_22; final double bb_2_550 = Scp3Int.b[2] - -1D * bb_1_312; final double bb_3_787 = Scp3Int.b[3] - -1D * bb_2_550; final double bb_4_1024 = Scp3Int.b[4] - -1D * bb_3_787; final double bb_1_1243 = (bb_1_312 - bb_2_550) * -1D; final double bb_2_1249 = (bb_2_550 - bb_3_787) * -1D; final double bb_3_1255 = (bb_3_787 - bb_4_1024) * -1D; final double bb_4_1261 = bb_4_1024 * -1D; Scp3Int.b[0] = scp3Int_b_0_22 - -1D * bb_1_312; Scp3Int.b[1] = bb_1_1243; Scp3Int.b[2] = bb_2_1249; Scp3Int.b[3] = bb_3_1255; Scp3Int.b[4] = bb_4_1261; return; } //-------------------------------------- 3 sec - JScp version 0.0.77