Sun Studio 12 Update 1 Compiler and IDE
by admin on Aug.11, 2009, under IT Adventures, Linux, Sago Labs
Cool News: This post was a blogging contest winner!
Thank you Sun!
Update: What a pleasant surprise to find that my entry for the Sun Studio blogging contest was selected as one of the winners, and announced on the Sun Studio Developers Site. As promised, Sun sent along $500, marking the first money I’ve made with this blog, and while my purpose in blogging is not focused on making money, it nonetheless was a nice side effect. I certainly enjoyed writing about my initial experience with using Sun Studio 12, and to have been selected as one of the contest winners was certainly a bonus. Thank you Sun Microsystems for holding the contest, and of course for making Sun Studio available to the community.
Every now and again I get emails from Sun Microsystems for guides or other promotions for this or that product: ZFS, Solaris containers, DTrace, etc. Some of them are actually quite interesting and it is a list I like being on.
The other day I received an announcement for the release of Sun Studio 12 Update 1. Well, this was perfect as I have been wanting to test drive Sun Studio for a while, and have been meaning to get to it – but it gets even better: they are having a blogging contest and will actually be paying 10 lucky winners who blog about their experience with it!
Well, let’s see: try out and write about a product which I had intended to do anyway, and perhaps win some cash too – how can one possibly go wrong?
Why Try It?
I’m neither a developer nor programmer. If that fits you as well, you might be thinking “So why bother?” Well, like a lot of folks out there who are Linux guys, sysadmin types, etc. I think it is always good to be familiar with available tools. The IDE I’ve used most is vim, and I’ve rarely even used Eclipse. But I, being an adventure loving soul, of course love checking out new things and was particularly interested in the Sun compiler as I wanted to compare its optimizations and the performance of binaries it compiles against the Intel (icc) and GNU (gcc) compilers. I previously wrote on comparing Intel Linux C complier and gcc binaries using the Crafty chess engine and was quite surprised at the benchmark differences, and have since then wanted to see how a Sun compiled binary would compare. So what a perfect opportunity to try it and find out.
Isn’t that a bit nebulous? One could even dare say Geeky?
While benching chess engine binaries might seem somewhat esoteric, it really gives a good idea of the possibilities. Translate this over to compiling your MySQL server or other performance critical app and it starts to get more interesting. In fact you can get MySQL binaries compiled with the Intel compiler for just this reason directly on the MySQL download page. One can’t help but wonder one MySQL binaries compiled with the Sun compiler might perform.
Install Experience
I tested out Sun Studio 12 on both Solaris 10 (2009.06 Nevada) and Linux (Suse 11.1) platforms. In both cases the install was seamless. On Solaris 10 it was simply a matter of using the new IPS packaging system and by running
$ pfexec pkg install sunstudio12u1
it was up and running in minutes.
On the Linux side I downloaded the SunStudio12u1-Linux-x86-rpms.tar.gz package and simply run the install wrapper script, which by default places everything in /opt/sun and the full path to the binary is then /opt/sun/sunstudio12.1/bin/sunstudio (you will need to add that to you PATH environmental.)
The GUI installer which ran in Linux went smoothly and gave basic options for which components to select, etc. You can also install install in non-interactively. The displayed warning was simply saying there was no guarantee it would work on this system (Suse 11.1) – but there were in fact no issues.
The full install (C and Fortran compilers, performance libs and IDE) comes to about 755MB on Linux and about 830Mb on Solaris – a bit larger than I expected.
Sun Studio IDE
Launching Sun Studio presents a clean and easy to navigate environment. Though never having used it before, it was pretty obvious where to find things. Several sample projects are available so you can test drive it right away, and there are links to guides presented on the main page. (There is also a comprehensive quick start guide here.)
I did have to play about a bit with adding existing directories of source code into a new project. It is easy enough once you do it. Once you import your source, you can click the build button and you are more or less off.
Of course, you will need to define the full path to the compiler you want to use in the CC= variable in the make file, or have this environmental defined and exported already. If you want to compile with gcc instead, it is no problem – just set cc=gcc In the Crafty make file you can simply set the $(MAKE) linux or $(MAKE) linux-icc to use gcc or icc compilers. I had no difficulty compiling Crafty with gcc this way.
Using the Sun Compiler
As I am utterly unfamiliar with CFlags for the Sun compiler I found it nice that just running the compiler with no arguments immediately tells you how to discover them easily enough with /opt/sun/sunstudio12.1/bin/suncc -flags
I had to figure out the CFLAGS still though, and found this site to be helpful for that.
One I had the correct options set in the Crafty Makefile, the Sun compiler launched into action for me. I used a basic set of CFLAGS:
solaris:
$(MAKE) target=SUN \
CC=/opt/sun/sunstudio12.1/bin/cc CXX='$(CC)' \
CFLAGS='$(CFLAGS) -fast -xO5 -xunroll=20' \
CXFLAGS=$(CFLAGS) \
LDFLAGS='$(LDFLAGS) -lpthread' \
opt='$(opt)' \
crafty-make
Compile Benchmark Results
So how did it go? How did the Sun compiler perform? Well come back in a day or so and see the benchmarks. Meanwhile, you might enjoy reading about how the previous comparison between Intel icc and gcc tests went, which you can find here.
Leave a Reply
You must be logged in to post a comment.