Powered by NETWORK.COM  
 Open Source Software for Solaris
An OpenSolaris Community Site
 Current Software Packages
Open Bug Tracking
    · Home of “Community Software for Solaris” ( CSW )
 

Sun Studio 11 is Installed on a Solaris 8 Branded Zone
    With a really modern commercial grade compiler firmly installed we can now do a few basic tests to see if the Solaris 8 Branded Zone will indeed act like a Solaris 8 server. One of the odd things that you can do with Solaris editions previous to Solaris 10 is produce statically linked binaries. Will the solaris8 branded zone allow this?

    A simple bit of code will reveal all :

bash-3.2$ /opt/SUNWspro/bin/cc -V cc: Sun C 5.8 Patch 121015-04 2007/01/10 usage: cc [ options] files. Use 'cc -flags' for details bash-3.2$ isalist sparcv9+vis2 sparcv9+vis sparcv9 sparcv8plus+vis2 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc ------------------------------ code to test with ------------------------- #include <stdio.h> #include <sys/time.h> hrtime_t start_hrt, end_hrt; long long int a, b, c, d; long long int i; int main(int argc, char *argv[]) { start_hrt = gethrtime(); b = ( long long ) 16; for ( i= 0 ; i < 1000000000 ; i++ ) { d = i * b; c = d - b; a = i + ( ( b * c ) - d ); } end_hrt = gethrtime(); printf(" a = %lld\n", a ); printf("time = %lld nsec\n", ( end_hrt - start_hrt ) ); return (0); } ------------------------------ end of code ------------------------------- bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8 -xstrconst -xildoff -xlibmil -Xa -xO2 -c -o add_int.o add_int.c bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8 -xO2 -o add_int add_int.o -lfast bash-3.2$ ptime ./add_int a = 240999999503 time = 124629288500 nsec real 2:04.638 user 2:04.623 sys 0.014 bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8plus -fast -o add_int add_int.c bash-3.2$ ls -l add_int -rwxr-xr-x 1 dclarke csw 6328 Apr 27 14:43 add_int bash-3.2$ strip add_int bash-3.2$ ls -l add_int -rwxr-xr-x 1 dclarke csw 4252 Apr 27 14:43 add_int bash-3.2$ file add_int add_int: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, dynamically linked, stripped bash-3.2$ ptime ./add_int a = 240999999503 time = 6302711800 nsec real 6.312 user 6.305 sys 0.006
    If you were watching closely you would see that I added the silly switch. That would be the “-fast” which, in theory, results in blistering fast binaries. Sometimes it does and in the above example you saw the execution time drop from over 2 minutes down to 6 seconds. Fast enough for you?

    That was still a dynamically linked binary however and thus nothing that I could not do with Solaris 10.
bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8plus -xstrconst -xildoff -xlibmil -fns=no -fsimple=0 -ftrap=%all -xbuiltin=%all -xlibmopt -xmemalign=8s -Xa -xO5 -Qy -xcode=pic32 -xprefetch=no%auto,no%explicit -\# -H -Bstatic -dn -errshort=full -o add_int add_int.c -lfast ### Note: NLSPATH = /opt/SUNWspro/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat: /opt/SUNWspro/prod/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat ### command line files and options (expanded): ### -dn -fsimple=0 -ftrap=%all -H -Xa -xarch=v8plus -xbuiltin=%all -xcode=pic32 -xlibmil -xlibmopt -xmemalign=8s -xO5 -xstrconst -Bstatic add_int.c -lfast -o add_int /opt/SUNWspro/prod/bin/acomp -xintrinsic -xldscope=global -i add_int.c -o /tmp/acompAAA.22839.Zsa4MS -r /tmp/acompBAA.22839.0sa4MS -N /tmp/iroptCAA.22839.1sa4MS -xdbggen=no%stabs+dwarf2+usedonly -strconst -H -errshort=full -xdbggen=incl -2K -xarch=v8plus -fparam_ir -O5 -Qy -D__SunOS_5_8 -D__SUNPRO_C=0x580 -D__SVR4 -D__unix -D__sun -D__sparcv8 -D__sparc -D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__ -Xa -D__PRAGMA_REDEFINE_EXTNAME -Dunix -Dsun -Dsparc -D__RESTRICT -xbuiltin=%all -xc99=%all,no%lib -D__FLT_EVAL_METHOD__=0 -I/opt/SUNWspro/prod/include/cc "-g/opt/SUNWspro/prod/bin/cc -xarch=v8plus -xstrconst -xildoff -xlibmil -fns=no -fsimple=0 -ftrap=%all -xbuiltin=%all -xlibmopt -xmemalign=8s -Xa -xO5 -Qy -xcode=pic32 -xprefetch=no%auto,no%explicit -H -Bstatic -dn -errshort=full -lfast -c " -fsimple=0 -destination_ir=iropt /usr/include/stdio.h /usr/include/iso/stdio_iso.h /usr/include/sys/feature_tests.h /usr/include/sys/isa_defs.h /usr/include/sys/va_list.h /usr/include/stdio_tag.h /usr/include/stdio_impl.h /usr/include/sys/time.h /usr/include/sys/types.h /usr/include/sys/machtypes.h /usr/include/sys/int_types.h /usr/include/sys/select.h /usr/include/sys/time.h /usr/include/time.h /usr/include/iso/time_iso.h /usr/include/sys/time_impl.h /opt/SUNWspro/prod/bin/iropt -F -o /tmp/iroptDAA.22839.2sa4MS -N/tmp/iroptCAA.22839.1sa4MS -is /tmp/acompAAA.22839.Zsa4MS /tmp/acompBAA.22839.0sa4MS -xarch=v8plus -xcache=generic -xchip=generic -ftrap=%all -xlibmopt -fsimple=0 -xvector=no -xbuiltin=%all -k -O5 -Qy /opt/SUNWspro/prod/bin/cg -xcode=pic32 -fsimple=0 -il /opt/SUNWspro/prod/lib/v8plus/libm.il -xthreadvar=dynamic -s -O5 -Qy -comdat -xmemalign=8s -xvector=no -xarch=v8plus -xcache=generic -xchip=generic -ftrap=%all -xlibmopt -oo add_int.o -is /tmp/acompAAA.22839.Zsa4MS -ir /tmp/iroptDAA.22839.2sa4MS -xbuiltin=%all ### Note: LD_LIBRARY_PATH = <null> ### Note: LD_RUN_PATH = <null> /usr/ccs/bin/ld -dn /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/values-xa.o -o add_int -Bstatic add_int.o -lfast -Y "P,/opt/SUNWspro/prod/lib/v8plus:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib" -Qy -lmopt -lc /opt/SUNWspro/prod/lib/crtn.o bash-3.2$ ls -l add_int -rwxr-xr-x 1 dclarke csw 362516 Apr 27 14:46 add_int bash-3.2$ file add_int add_int: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, statically linked, not stripped bash-3.2$ strip add_int bash-3.2$ ls -l add_int -rwxr-xr-x 1 dclarke csw 244656 Apr 27 14:47 add_int bash-3.2$ ptime ./add_int a = 240999999503 time = 11114760400 nsec real 11.122 user 11.115 sys 0.005

    You will note that the final binary was statically linked. It was also a great deal larger because of that and not exactly any faster. Is it possible to emply the dreaded -fast switch as well as static linking?

bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8 -fast -Bstatic -dn -c -o add_int.o add_int.c bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8 -fast -Bstatic -dn -o add_int add_int.o -lfast bash-3.2$ file add_int add_int: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, statically linked, not stripped bash-3.2$ ls -l add_int -rwxr-xr-x 1 dclarke csw 362104 Apr 27 16:23 add_int bash-3.2$ ptime ./add_int a = 240999999503 time = 6672694800 nsec real 6.679 user 6.674 sys 0.004

    So there you have it, a statically linked binary compiled with the fast switch and running just fine.

    I have no idea why you would want to do that, but I am letting you know that you can.

    Now onwards to something a bit more interesting, we will use the MPFR libs to calculate a basic trig function with a high degree of precision.

------------------------------------------------------------------------------- /****************************************************************** * This is a slightly modified code snip that was presented by * * Jonathan Bober <bober@umich.edu> in order to demonstrate the * * less than optimal mpfr_sin call versus mpfr_cos. Please see * * the mpfr maillist for details and follow up by Vincent Lefevre * * and myself. We all agree that a more optimal approach is * * required in mpfr_sin but that is another topic. Here we use * * the high resolution timers in Solaris to get very fine grained * * measurements. Dennis Clarke dclarke@blastwave.org * ******************************************************************/ #include <stdio.h> #include <sys/time.h> #include <mpfr.h> hrtime_t start_hrt, end_hrt; mpfr_t mpfr_pi, mpfr_temp, mpfr_two, mpfr_angle; uint32_t i; int main(int argc, char *argv[]){ start_hrt = gethrtime(); mpfr_init2(mpfr_pi, 200); mpfr_init2(mpfr_temp, 200); mpfr_init2(mpfr_two, 200); mpfr_init2(mpfr_angle, 200); mpfr_const_pi ( mpfr_pi, GMP_RNDN); mpfr_set_str(mpfr_two, "2.00000", 10, GMP_RNDN); /* angle = pi/2 */ mpfr_div(mpfr_angle, mpfr_pi, mpfr_two, GMP_RNDN); /* upon entry into the loop below we do this again to get angle = pi/4 */ for( i = 0; i < 10; i++) { /* calculate half of the angle */ mpfr_div(mpfr_angle, mpfr_angle, mpfr_two, GMP_RNDN); /* calculate cosine of angle */ mpfr_cos(mpfr_temp, mpfr_angle, GMP_RNDN); } end_hrt = gethrtime(); printf(" final angle = "); mpfr_out_str (stdout, 10, 48, mpfr_angle, GMP_RNDN); printf("\n"); printf("final cosine = "); mpfr_out_str (stdout, 10, 48, mpfr_temp, GMP_RNDN); printf("\n"); printf("time = %lld nsec\n", ( end_hrt - start_hrt ) ); return (0); } ------------------------------------------------------------------------------- bash-3.2$ /opt/SUNWspro/bin/cc -I/opt/csw/include -xarch=v8 -xstrconst -xildoff \ > -xlibmil -Xa -xO2 -c -o mpfr_cos.o mpfr_cos.c bash-3.2$ /opt/SUNWspro/bin/cc -xarch=v8 -xO2 -o mpfr_cos mpfr_cos.o -lmpfr bash-3.2$ file mpfr_cos mpfr_cos: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped bash-3.2$ ldd mpfr_cos /usr/lib/secure/s8_preload.so.1 libmpfr.so.1 => /opt/csw/lib/libmpfr.so.1 libc.so.1 => /usr/lib/libc.so.1 libgmp.so.3 => /opt/csw/lib/libgmp.so.3 libdl.so.1 => /usr/lib/libdl.so.1 /usr/platform/SUNW,Sun-Fire-480R/lib/libc_psr.so.1 bash-3.2$ ptime ./mpfr_cos final angle = 1.53398078788564122971808758949194476767439912079e-3 final cosine = 9.99998823451701909929025710171526019048267922890e-1 time = 2362800 nsec real 0.013 user 0.005 sys 0.007
LAST UPDATED : Sun Apr 27 16:28:44 EDT 2008

W3C Quality Assurance
OpenSolaris and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.      UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd.      All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the United States and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc.      All other logos and trademarks are registered through their respective owners.      ©2002-2006 blastwave.org™      See “Terms of Use”      Sun™ Logo and OpenSolaris™ Published with Permission from Sun Microsystems, Inc.
This Page Is Valid HTML 4.01 Transitional
This Page Is Valid CSS