免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1380 | 回复: 0
打印 上一主题 下一主题

Solaris ABC for Linux/UnixDevelopers(II) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-11 10:13 |只看该作者 |倒序浏览
Guide for developers
. Sun Studio 11
> Free!
> Download
http://developers.sun.com/prodtech/cc/downloads/index.jsp

> High performance C/C++/Fortran compiler
> More optimization options than gcc
> Full IDE environment for debugging and performance
analyzing
> Available on Solaris sparc, Solaris x86 and Linux
> Default in /opt/SUNWspro/bin
> cc (c compiler), CC (C++ comiler)
> dmake (distributed make tool)
> dbx (debugger that supports multi-threading programs well)
> cc -flags (show all flags help)
> Compiler options for different target
– -xarch=v9 (64-bit application solaris sparc)
– -xarch=v8 (32-bit application solaris sparc)
– -xarch=amd64 (64-bit application solaris x64 on AMD Opteron)
> cc -xdryrun (show compiler commands and options to be used
but no compilation)
> Performance analyzer
> Profiling tool that allows you to drill down into source codes and
assembly codes and quickly find the application bottle-neck.
> Run the user process using "collect" to collect the profiling
data
– % /opt/SUNWspro/bin/collect -L unlimited -A copy -F on -d
/export/home/analyze  
> Then run analyzer GUI tool
– % cd /export/home/analyze
– % /opt/SUNWspro/bin/analyzer test.3.er
. Sun Studio 11
> Some C/C++ compiler optimizations
> -xarch=xxx (specify the cpu architecture)
> -xO4 (optimization level is 4)
> -fast (a combination of multiple optimizations, be careful for
float-pointing codes)
> -lsunperf (using Sun performance library)
> -xipo (cross-file optimization)
> -xlinkopt (optimization during linkage)
> -xautopar -xloopinfo (find and parallel loops)
> -xprefetch_level=3
> Profiling feedback based optimization
> compile with
– -xprofile=collect -xO4
> run test and generate profiling data in ./mycode.xxxx
> recompile with profileing feedback
– -xprofile=use:./mycode -xO4
> Re-run test and see performance improvements!
. Sun Gcc
> Feature compatible with gcc 4.0.2
> Debuggable with gdb and dbx
> Through advanced optimizations tuned to Sun systems
> Extra optimizations such as -xipo, -xprefetch, -xprofile
> Free!
>
http://www.sun.com/download/products.xml?id=43fb4c75

> By default, installed in /opt/sfw/bin
. ATS (Automatic Tuning)
> Imagine you don't have 3rd party source codes, how do
you optimize it?
> ATS can recompile and optimize the binaries directly.
> Can also be used for
> Find the object file and the optimization flag that is causing a
runtime problem
> A simple example for ATS
> % ats -i '-xO3' a.out
> Try it !
>
http://cooltools.sunsource.net/ats/index.html

>
http://cooltools.sunsource.net/ats/ATS_users_guide.html

. Java
> Java runs best on Solaris!
> There're more optimization JVM settings on Solaris
>
http://java.sun.com/docs/hotspot/VMOptions.html

> -XX:+UseParallelGC is often needed for multi-cpus
system
> Use latest JVM version as possible
> JVM performance is improved version by version!
. C/C++ porting to Solaris
> 4 possible target environments
> Solaris x86 32-bit
> Solaris x86 64-bit (i.e. Solaris x64)
> Solaris sparc 32-bit
> Solaris sparc 64-bit
> Which porting is easier?
> 32-bit -> 32-bit or 64-bit -> 64-bit (Easy)
> 32-bit  64-bit (Difficult)
> Little Endian -> Little Endian (e.g. DEC Alpha  x86) or
Big Endian -> Big Endian (Easy)
> Little Endian  Big Endian (Difficult)
> 32-bit  64-bit
> Be careful of different size for pointer type and long type
between ILP32 and LP64 data models.
> LP64
– pointer: 8 byte, long: 8 byte
> ILP32
– Pointer: 4 byte, long: 4 byte
> x86sparc
> Be careful of Little-endian (x86) and Big-endian (sparc)
problem on byte-operations in source codes.
> Be careful of word-alignment issue: (see next pages)
> x86sparc
> Be careful of word-alignment issue:
1 #include  
2 #include  
3 main(int argc, char *argv[])
4 {
5 void *p = malloc(10);
6 p++;
7 int *i;
8 i= (int *)p;
9 *i=3;
10 }
> x86sparc
> Using gcc to compile and run this code on both x86 and sparc
> You'll see core dump on Solaris sparc with gcc compilation
– Why? Because Line 8: i= (int *)p; the address of “i" is not aligned
(the address cannot be divided by sizeof(int))
> Try to use Sun compiler to compile and run this code on sparc
– Not core dump because the default -xmemalign=8i is used for 32-bit
application (use cc -xdryrun can show this), and the compiler inserts
interpret codes.
– If you compile with -xmemalign=8s (default for 64-bit application), the
code will core dump
> Misalignment will cause performance penalty because trap
handling is slow.
> C++ templates
> Different compilers have different supports on C++ templates
> If you use some advanced features of template, you might have porting problem.
> Platform-dependent libraries/system calls/signals
> You have to read documents for both source platform and
target platform to understand the differences and workarounds.
. Resources for developers
>
http://developers.sun.com/prodtech/solaris/index.html

> Linux 到SolarisTM 10 操作系统迁移指南
>
http://gceclub.sun.com.cn/download/Solaris_10/Linux_Solaris_Migration_Guide.pdf

> Sun 的studio 及编译器文档
>
http://docs.sun.com/app/docs/coll/1199.3
( 中文文档)
>
http://docs.sun.com/app/docs/coll/771.7
( 英文文档)
> Solaris 开发文档,如,多线程开发,链接库指南,64 位指南等
>
http://docs.sun.com/app/docs/coll/45.20

> Sparc 处理器文档
>
http://www.sun.com/processors/documentation.html
>
http://developers.sun.com/solaris/articles/sparcv9.pdf


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4448/showart_275383.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP