Performance comparison

136 views
Skip to first unread message

Vladimir Grinbaum

unread,
Oct 12, 2014, 11:46:43 PM10/12/14
to yeppp-...@googlegroups.com
Hi to all!

My system is -

AMD E-450 APU with Radeon (tm) HD Graphics 1.65 GHz,
2 Cores, 2 Logical,
4.00 GB (3.8 GB usable),
64-bit Operating System,
Win 7 Home Premium SP1,
MSVS Express 2013,
.NET Framework 4.5.50938,
C# 2013

Question -
Why performance of Yeppp less then simple search ?

using System;
using System.Collections.Generic;
namespace ArrayFastCmp
{       class Program
       
{       static  void    Main    (       string[] args   )
               
{       TimeSpan t;             string T;
                       
int     Counter =       1000000,        K=0;
                       
byte[]  a       =       {       1,1,1,1,1,1,1,1,1,1     };
                       
byte[]  b       =       {       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
                       
ushort[]        c       =       new ushort[10];

                        t              
=       DateTime.Now.TimeOfDay;
                       
for             (       int j=0;j<Counter;j++)
                       
{       for     (       int i=0;i<10;i++                )
                               
{       Yeppp.Core.Subtract_V8uV8u_V16u ( b, i, a, 0, c, 0, 10 );
                       
}       }
                        T      
=       (       DateTime.Now.TimeOfDay - t ).TotalSeconds.ToString ("F2");
                       
Console.WriteLine(      "1 - " + T );                                   //  2.16 сек.

                        t      
=       DateTime.Now.TimeOfDay;
                       
for     (       int k=0;k<Counter;k++   )
                       
{       for     (       int i=0;i<10;i++)
//                              {       for(    int j=0;j<10;j++) { if (a[j] != b[j+1]) K++; }  // 1.78 sec
                               
{       for(    int j=0;j<10;j++) { if (a[j] != b[j+1]) K++; }  // 1.51 sec
                       
}       }
                        T      
=       (       DateTime.Now.TimeOfDay - t ).TotalSeconds.ToString ("F2");
                       
Console.WriteLine(      "2 - " + T );                                   // ???
                       
Console.ReadKey();
}       }       }      

Vladimir Grinbaum

unread,
Oct 12, 2014, 11:54:00 PM10/12/14
to yeppp-...@googlegroups.com
Sorry - change


                                {       for(    int j=0;j<10;j++) { if (a[j] != b[j+1]) K++; }  // 1.51 sec
                                {       for(    int j=0;j<10;j++) { K = a[j] - b[j+1]; }         // 1.51 sec


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:

Marat Dukhan

unread,
Oct 13, 2014, 12:11:32 AM10/13/14
to Vladimir Grinbaum, yeppp-...@googlegroups.com
Yeppp! is optimized for processing arrays of at least several hundred elements.
The array size you use (10 elements) is too small to benefit from vector instructions.

Regards,
Marat

--
You received this message because you are subscribed to the Google Groups "yeppp-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yeppp-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vladimir Grinbaum

unread,
Oct 13, 2014, 12:19:48 AM10/13/14
to yeppp-...@googlegroups.com
Thanks!


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 13, 2014, 12:34:57 AM10/13/14
to yeppp-...@googlegroups.com
What your recommendations for small arrays?


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Marat Dukhan

unread,
Oct 13, 2014, 12:40:19 AM10/13/14
to Vladimir Grinbaum, yeppp-...@googlegroups.com
You may try Mono.SIMD or the new-and-shiny RyuJIT SIMD.
Native libraries (like Yeppp!) are out-of-question because the cost of PInvoke call will eat all performance benefits.

Regards,
Marat

Vladimir Grinbaum

unread,
Oct 13, 2014, 1:08:06 AM10/13/14
to yeppp-...@googlegroups.com
Thanks!


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 15, 2014, 1:41:20 AM10/15/14
to yeppp-...@googlegroups.com
Very needed compare arrays -

bool Yeppp.Core.Compare_V8uV8u ( byte [] x,   int xOffset, byte [] y,   int yOffset, int Length )
bool Yeppp.Core.Compare_V8sV8s ( sbyte [] x, int xOffset, sbyte [] y, int yOffset, int Length )


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 15, 2014, 2:14:45 AM10/15/14
to yeppp-...@googlegroups.com
and / or  best -
Yeppp.Core.Compare_V8uV8u ( byte [] x, int xOffset, byte [] y, int yOffset, int Length, (out) int CountOfNonCoinciedeElements )


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 15, 2014, 2:20:33 AM10/15/14
to yeppp-...@googlegroups.com
Sorry - 
Yeppp.Core.Compare_V8uV8u ( byte [] x, int xOffset, byte [] y, int yOffset, int Length, (out) int CountOfNoMatchElements )


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 15, 2014, 2:49:55 AM10/15/14
to yeppp-...@googlegroups.com
or variant -

bool Yeppp.Core.Equals_V8sV8s ( sbyte [] x, int xOffset, sbyte [] y, int yOffset, int Length )


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 22, 2014, 12:58:39 PM10/22/14
to yeppp-...@googlegroups.com
Hi, Marat!

Core.Subtract_V8sV8s_V8s, CS,
this function in my test program is normal,
but in real program this function hangs.

The program hang occurs when accessing method
which contains CS call 

What could be the reasons?


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Marat Dukhan

unread,
Oct 22, 2014, 8:45:28 PM10/22/14
to Vladimir Grinbaum, yeppp-...@googlegroups.com
I wouldn't expect the problem to be caused by Yeppp!: the computational functions in Yeppp! do not perform any blocking operations.
I suggest that you connect to the hanged process with a debugger, pause execution, and look at the backtrace to find what is stalling the process.

Regards,
Marat

Vladimir Grinbaum

unread,
Oct 23, 2014, 1:38:49 AM10/23/14
to yeppp-...@googlegroups.com
Thanks! 
I will try.


понедельник, 13 октября 2014 г., 9:46:43 UTC+6 пользователь Vladimir Grinbaum написал:
Hi to all!

Vladimir Grinbaum

unread,
Oct 24, 2014, 11:12:14 AM10/24/14
to yeppp-...@googlegroups.com
Hi,Marat!

All are OK!
recreates of my project and all are works. Thanks!

Vladimir Grinbaum

unread,
Nov 9, 2014, 2:53:55 PM11/9/14
to yeppp-...@googlegroups.com
Hi!


double Min=0,Max=0;
double [] a = {1,2,3,4,5};
Yeppp.Core.Max_IV64fS64f_IV64f ( a,0,Max,5);   // I'm waiting Max = 5, but I'm receiving Max = 0;
Yeppp.Core.Min_IV64fS64f_IV64f ( a,0,Min,5);    // I'm waiting Min = 1, but I'm receiving Min = 0;

Why? 

Marat Dukhan

unread,
Nov 11, 2014, 4:18:38 AM11/11/14
to Vladimir Grinbaum, yeppp-...@googlegroups.com
It is not well-documented, but the names of computational functions in Yeppp! follow the convention
Yeppp.<ModuleName>.<OperatioName>_<AbbreviatedInputArguments>_<AbbreviatedOutputArguments>
Abbreviated lists of arguments consists of entries like
  • S<TypeName> for scalar arguments, e.g. S64f for double precision (64-bit) floating-point scalar
  • V<TypeName> for vector arguments, e.g. V32f for single precision (32-bit) floating-point vector
  • IV<TypeName> for vector arguments that are modified in-place by this operation (i.e. vector is both input and output). In this case abbreviations for both the input and the output arguments have IV prefix.
Thus, Yeppp.Core.Max_IV64fS64f_IV64f computes the pair wise maximum between vector elements and a scalar and writes the resulting value back to the vector. It seems, that instead you wanted Yeppp.Core_Max_V64f_S64f which computes the maximum of all vector elements and returns a scalar (input arguments: V64f = vector of 64-bit floating-point numbers; output arguments: S64f = 64-bit floating-point scalar).

Regards,
Marat

--

Vladimir Grinbaum

unread,
Nov 11, 2014, 7:04:52 AM11/11/14
to yeppp-...@googlegroups.com
Thanks! I understand!
 
My program of Pirson - correlation coefficient works good! Thanks!

public class rShift { public rShift ( int shift, double r ) { Shift = shift; R = r; } public int Shift; public double R; }
public rShift CorrelatePirson ( double [] F, double [] f ) // Расчет коэффициента корреляции Пирсона
{ double A,a,Q,q,R, RMax = 0; double [] G = (double[]) F.Clone(), g; rShift RShift; int NShiftMax = 30, Count = G.Length - NShiftMax, i, I = 0;
A = Yeppp.Core.Sum_V64f_S64f ( G, 0, Count ) / Count; // Ave ( X )
Yeppp.Core.Subtract_IV64fS64f_IV64f ( G, 0, A, Count ); // G <== Arr ( Xi - Ave ( X ) )
Q = Yeppp.Core.SumSquares_V64f_S64f ( G, 0, Count ); // Sum ( ( Xi - Ave ( X ) ) **2 )
for(i = 0;i<NShiftMax;i++)
{ g = (double[])f.Clone();
a = Yeppp.Core.Sum_V64f_S64f ( g, i, Count ) / Count; // Ave ( Y )
Yeppp.Core.Subtract_IV64fS64f_IV64f ( g, i, a, Count ); // g <== Arr ( Yi - Ave ( Y ) )
q = Yeppp.Core.SumSquares_V64f_S64f ( g, i, Count ); // Sum ( ( Yi - Ave ( Y ) ) **2 )
Yeppp.Core.Multiply_IV64fV64f_IV64f ( g, i, G, 0, Count ); // Arr { [ Xi - Ave ( Xi ) ] * [ Yi - Ave ( Y ) ] }
a = Yeppp.Core.Sum_V64f_S64f ( g, i, Count ); // Sum { Arr [ Xi - Ave ( Xi ) ] * [ Yi - Ave ( Y ) ] }
if ( Q == 0 || q == 0 ) return RShift = new rShift (0,0);
R = a / Math.Sqrt ( Q * q ); if ( Math.Abs (RMax) < Math.Abs (R) ){ RMax = R; I = i; } // R <== Sum { Arr [ Xi - Ave ( Xi ) ] * [ Yi - Ave ( Y ) ] } / Sqrt { Sum ( ( Xi - Ave ( X ) ) **2 ) * Sum ( ( Yi - Ave ( Y ) ) **2 ) }
} return RShift = new rShift (I,RMax);
}



Vladimir Grinbaum

unread,
Jan 10, 2015, 11:47:57 AM1/10/15
to yeppp-...@googlegroups.com
New year!

What is the maximum available size of the arrays and
what is the optimum size of the arrays?
 

Marat Dukhan

unread,
Jan 10, 2015, 5:45:15 PM1/10/15
to Vladimir Grinbaum, yeppp-...@googlegroups.com
The maximum array size is limited only by address space (4 GB on 32-bit systems, practically unlimited on 64-bit systems).

The optimum array size depends on possible data reuse. If your program calls multiple Yeppp! functions to process the same arrays, it is optimal to do all calls for a small slice of the arrays (such that all data in the slices fits into L1 cache) and then proceed to the next slice. If data is not reused, it is best to process entire arrays in one call.

Regards,
Marat

--

Vladimir Grinbaum

unread,
Jan 10, 2015, 10:33:53 PM1/10/15
to yeppp-...@googlegroups.com, gw...@yahoo.com
Thanks!

воскресенье, 11 января 2015 г., 4:45:15 UTC+6 пользователь Marat Dukhan написал:
Reply all
Reply to author
Forward
0 new messages