gcc (the one we ship) at -O2 seems to really produce a loop (a very 
painful one)
from main +0x8 to main+0x30.

Just compiling the loop...

$ gcc -O2 nj.c
$ dis -F main a.out

disassembly for a.out

main()
    main:                   9d e3 bf 88  save      %sp, -0x78, %sp
    main+0x4:               c0 27 bf ec  clr       [%fp - 0x14]
    main+0x8:               c2 07 bf ec  ld        [%fp - 0x14], %g1
    main+0xc:               3b 00 03 d0  sethi     %hi(0xf4000), %i5
    main+0x10:              ba 17 62 3f  or        %i5, 0x23f, %i5
    main+0x14:              80 a0 40 1d  cmp       %g1, %i5
    main+0x18:              14 80 00 07  bg        +0x1c         <main+0x34>
    main+0x1c:              01 00 00 00  nop
    main+0x20:              c2 07 bf ec  ld        [%fp - 0x14], %g1
    main+0x24:              82 00 60 01  add       %g1, 0x1, %g1
    main+0x28:              c2 27 bf ec  st        %g1, [%fp - 0x14]
    main+0x2c:              10 bf ff f7  ba        -0x24         <main+0x8>
    main+0x30:              01 00 00 00  nop
    main+0x34:              b0 10 00 01  mov       %g1, %i0
    main+0x38:              81 c7 e0 08  ret
    main+0x3c:              81 e8 00 00  restore


Jim
----
Denis Sheahan wrote:
>
> 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
>
> _______________________________________________
> ldoms-discuss mailing list
> ldoms-discuss at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/ldoms-discuss
>


Reply via email to