I have been trying to compare these two functions as I have been told that ipp are much faster then C string functions.
However, I really could write a single example where ippsCompare_8u is -at least- as fast as strcmp(). There's only one note about ippsCompare that says: "for long strings" (whatever it means).
My example is really simple. I'm dynamically allocating the two strings to compare so in this way -I guess- the compiler shouldn't replace strcmp()/strlen() with simple constants.
Compilation: icpc -O3 ipp.cpp -I /opt/apps/intel/ipp/include/ -L /opt/apps/intel/ipp/lib/intel64/ -lippch_l -lippcore_l
I have the ipp version bundled with composer_xe_2013 and my hardware is RedHat Linux 64 with 4 Intel(R) Xeon(R) CPU X5690 @ 3.47GHz (6 cores for each CPU) with 200GB of RAM.
I'm misuring the execution time with "time" command on Linux. The strings I considered during my tests had a 100000000-char length.
My questions are:
- Am I wrongly using ippsCompare?
- Is my assumption correct? (ippsCompare should -for some "long" string be faster then strcmp()). if yes, what's the meaning of "long string"?
7 int main(int argc, char **argv)
11 size_t first_length = atoi(argv);
12 char *first = new char[first_length+1];
13 for (size_t i=0; i<first_length; ++i)
16 size_t second_length = atoi(argv);
17 char *second = new char[second_length+1];
18 for (size_t i=0; i<second_length; ++i)
23 //std::string ff=first;
24 //std::string ss=second;
25 //std::string ff(first), ss(second);
26 size_t hmt = atol(argv);
27 long long final_result = 0;
28 size_t counter = 0;
29 for (size_t i=0; i<hmt; ++i)
32 * [first test]
34 * Ipp8u *f = (Ipp8u*)first, *s = (Ipp8u*)second;
35 * size_t max_length = std::max(strlen(first), strlen(second));
36 * int result = 0;
37 * IppStatus rc = ippsCompare_8u(f, s, max_length, &result);
41 * [second test]
43 int result = strcmp(first, second);
45 final_result += result;
48 std::cout <<final_result <<std::endl;
49 delete first;
50 delete second;
51 return 0;