Hi Jim
What flags did you use to compile the code. Looking at the body of
the code the loop is empty
> startTime = GetCurTime();
> for(i =0; i < LOOP; ++i)
> {
> }
> endTime = GetCurTime();
> printf("(Thread %d)Elapsed time to loop %d times: %f (MS)
> \n",pthread_self(), LOOP, endTime-startTime);
> }
>
The compiler would normally remove this code altogether and so the
cost is most likely
just the two calls to GetCurTime();
You mention 4 cpu - I presume that is 4 HW threads in an LDOM - and
64 threads but give the same
result on T5120. This is more evidence of the loop removal, more
threads should definitely reduce
the elapsed time as there are more HW pipelines to execute n
One option might be to put some code in the loop that cannot be
optimized away, perhaps a sum that is
output in the printf. Then see if the results scales on the T5120
regards
Denis
On Jul 21, 2009, at 6:44 PM, Jim Goh wrote:
> Hi,
>
> We have the following two servers both are running Solaris 10:
>
> V245 - Solaris 10, 8G memory, 8G swap, patch level 118833-24, 2 cpu
> operate at 1504 MHz each
>
> T5120 (guest ldom) - Solaris 10, 2G memory, 1G swap, patch level
> 137111-05, 4 cpu operate at 1165 MHz each
>
> We tested with the following code and the results are very
> different. We even tested with the whole box (T5120) with 32G
> memory and 64 CPUs and results are same. Not sure why T5120 is
> slower than V245.
>
> Are they any settings that we can change in T5120 or ldoms?
>
> Thanks!
>
> // Compile using the following command
> //
> // gcc -O2 -lpthread performance.c
>
> #include <time.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> #define MS_TO_SEC 0.000001 /1/1000000/
>
> double CurrSysTime()
> {
> struct timeval tv;
> double currTime = -1;
>
> if(gettimeofday(&tv, NULL)<0)
> {
> return currTime;
> }
> currTime = tv.tv_sec tv.tv_usec*MS_TO_SEC;
> return(currTime);
> }
>
> double GetCurTime() {
> struct timeval tv;
> gettimeofday(&tv, NULL);
> return (tv.tv_sec*1000000.0 tv.tv_usec);
> }
>
> pthread_t t1 = 0;
> pthread_t t2 = 0;
> pthread_t t3 = 0;
> pthread_t t4 = 0;
> pthread_t t5 = 0;
> pthread_t t6 = 0;
> pthread_t t7 = 0;
> pthread_t t8 = 0;
> pthread_t t9 = 0;
> pthread_t t10 = 0;
>
> #define LOOP 1000000
>
> // Ten of these threads are started
> void *testThread()
> {
> int i,j;
> int num;
> double startTime;
> double endTime;
>
> startTime = GetCurTime();
> for(i =0; i < LOOP; ++i)
> {
> }
> endTime = GetCurTime();
> printf("(Thread %d)Elapsed time to loop %d times: %f (MS)
> \n",pthread_self(), LOOP, endTime-startTime);
> }
>
> // Main Program
> main()
>
> {
> // Start up the test threads
> pthread_create(&t1, NULL, testThread, NULL);
> pthread_create(&t2, NULL, testThread, NULL);
> pthread_create(&t3, NULL, testThread, NULL);
> pthread_create(&t4, NULL, testThread, NULL);
> pthread_create(&t5, NULL, testThread, NULL);
> pthread_create(&t6, NULL, testThread, NULL);
> pthread_create(&t7, NULL, testThread, NULL);
> pthread_create(&t8, NULL, testThread, NULL);
> pthread_create(&t9, NULL, testThread, NULL);
> pthread_create(&t10, NULL, testThread, NULL);
> // Wait for the threads to finish
> sleep(10);
> }
>
> Results are:
>
> T5120
>
> (Thread 2)Elapsed time to loop 1000000 times: 6768.000000 (MS)
> (Thread 5)Elapsed time to loop 1000000 times: 6819.000000 (MS)
> (Thread 6)Elapsed time to loop 1000000 times: 6823.000000 (MS)
> (Thread 7)Elapsed time to loop 1000000 times: 6824.000000 (MS)
> (Thread 4)Elapsed time to loop 1000000 times: 6773.000000 (MS)
> (Thread 8)Elapsed time to loop 1000000 times: 6917.000000 (MS)
> (Thread 3)Elapsed time to loop 1000000 times: 6771.000000 (MS)
> (Thread 9)Elapsed time to loop 1000000 times: 6841.000000 (MS)
> (Thread 11)Elapsed time to loop 1000000 times: 6197.000000 (MS)
> (Thread 10)Elapsed time to loop 1000000 times: 6381.000000 (MS)
>
> V245
>
> (Thread 2)Elapsed time to loop 1000000 times: 1998.000000 (MS)
> (Thread 3)Elapsed time to loop 1000000 times: 1998.000000 (MS)
> (Thread 6)Elapsed time to loop 1000000 times: 2041.000000 (MS)
> (Thread 4)Elapsed time to loop 1000000 times: 2080.000000 (MS)
> (Thread 8)Elapsed time to loop 1000000 times: 1995.000000 (MS)
> (Thread 5)Elapsed time to loop 1000000 times: 1996.000000 (MS)
> (Thread 10)Elapsed time to loop 1000000 times: 2024.000000 (MS)
> (Thread 7)Elapsed time to loop 1000000 times: 1996.000000 (MS)
> (Thread 9)Elapsed time to loop 1000000 times: 1995.000000 (MS)
> (Thread 11)Elapsed time to loop 1000000 times: 1996.000000 (MS)
> --
> This message posted from opensolaris.org
> _______________________________________________
> ldoms-discuss mailing list
> ldoms-discuss at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/ldoms-discuss