Tech and Academic things for Chianshin

Monday, October 29, 2007

Heap Consistency Checking - The GNU C Library

Heap Consistency Checking - The GNU C Library
Another possibility to check for and guard against bugs in the use of malloc, realloc and free is to set the environment variable MALLOC_CHECK_. When MALLOC_CHECK_ is set, a special (less efficient) implementation is used which is designed to be tolerant against simple errors, such as double calls of free with the same argument, or overruns of a single byte (off-by-one bugs). Not all such errors can be protected against, however, and memory leaks can result. If MALLOC_CHECK_ is set to 0, any detected heap corruption is silently ignored; if set to 1, a diagnostic is printed on stderr; if set to 2, abort is called immediately. This can be useful because otherwise a crash may happen much later, and the true cause for the problem is then very hard to track down.

There is one problem with MALLOC_CHECK_: in SUID or SGID binaries it could possibly be exploited since diverging from the normal programs behavior it now writes something to the standard error descriptor. Therefore the use of MALLOC_CHECK_ is disabled by default for SUID and SGID binaries. It can be enabled again by the system administrator by adding a file /etc/suid-debug (the content is not important it could be empty).

Friday, October 12, 2007

Timing and Profiling on Cobalt, an Overview

Timing and Profiling on Cobalt, an Overview: "called"
An undocumented GMON environment variable is GMON_OUT_PREFIX. When profiling a threaded or MPI code, each process will generate a gmon file called $GMON_OUT_PREFIX.pid. Each gmon file can then be analyzed seperately or the aggregate sum can be produced by gmon and examined as a whole:
% gprof -s $GMON_OUT_PREFIX.*
% gprof a.out gmon.sum

===============================================================
ohar Levi wrote:

> when I run test it generates the gmon.out, but gprof
> complains:
>
> gprof: gmon.out file is missing call-graph data

It's complaining because there is no call-graph info because your
trivial testcase only has a single function. If you run it on a
non-trivial testcase, or if you ask for a flat profile (-p) it will work
fine.

The following thread explains the problem and includes a patch which
changes the default behavior in this situation to -p. Note that gprof
is part of binutils and not part of gcc and questions about it are
better suited for the binutils list.

OProfile

OProfile

Intel的C++编译器及VTune - Linux编程与内核 - 红联Linux论坛 Linux/Unix技术讨论 - linuxdiyf.com/bbs

Intel的C++编译器及VTune - Linux编程与内核 - 红联Linux论坛 Linux/Unix技术讨论 - linuxdiyf.com/bbs
ntel的C++编译器及VTune

  Intel的C++和Fotran编译器被广泛认为是IA-32平台上最好的编译器。我最早试用Intel C++编译器是在2001年初,当时Intel刚刚收购Kai C++,Intel C++编译器的的版本号是5.0。那个时候我不太清楚Intel做编译器用意何在,也不知道他们会不会坚持下去,所以没太在意。结果证明,Intel对这个领域是很认真的,在不到7年时间里从5.0做到10.0,这样的力度在整个业界可以说是绝无仅有。Intel为啥要玩命地做优化编译器呢?今年4月 Intel的高级副总裁Renee James来访时,提到这个问题,她没说得很详细,但是大意是说,要对Intel自己的CPU提供有力的支持。

  这些年来Intel在CPU的设计上花费了大量的心血,增加了很多新的功能,多核且不必说,矢量化操作也是很值得一提的。当初P4 NetBurst架构主要是对访存密集性应用比较有效,比如网络文件服务器之类,在CPU密集型计算任务中,P4表现很一般。所以到了Pentium M和 Core Duo,比较重视计算密集型任务的支持,主要改进集中在矢量化操作上。由于采用了SIMD,对于某些类型的应用(比如矩阵运算、图形图像、信号处理之类),性能可以获得大幅度提升。但是主要的编译器软件提供商们对于支持这些最新CPU技术的热情并不高,现有的IA-32编译器基本上还是产生古典的 i386代码。长期积累下来,用户花大价钱买的先进CPU有很多能力都被闲置。这种情况损害了用户的利益,最终也会损害Intel等芯片厂商的利益。也难怪Intel实在按捺不住,撸袖子亲自上阵做compiler了。不过这件事情对我们用户来说绝对是好事。Intel在这上头真是做了不少好东西,C/C ++和Fortran编译器,VTune程序性能分析器,高性能数学库MKL,主要用于信号处理的IPP库,简化多线程开发的TBB(Threading Building Blocks)和ThreadChecker等,对于性能要求比较高的开发工作来说,都是很好的工具。

  Intel的编译器是收费的,虽然价格并不算太高,也就几百美刀,不过对于学习和自由软件的开发者来说,还是一个负担。前两天去Intel软件的网站上看到了他们的一个新的program,提供Linux平台上非商业软件开发者免费的软件工具,包括全套C/C++/Fortran编译器、VTune、 MKL、IPP、ThreadChecker和TBB。我下载了C++ compiler。尽管我的Ubuntu 7.04不在直接支持的OS之列,但是运行install.sh还是很顺利地安装了。Linux版的icc与gcc命令行格式基本兼容,我编译了几个C程序,对比了一下产生出来的汇编代码。因为对icc产生的汇编格式和风格不熟悉,现在还没法给出一个客观的对比评价。不过icc的汇编输出显然是比gcc多不少内容。ICC有一些很有意思的功能,比如自动并行化、自动矢量化等,很值得玩味一把。

  遗憾的是,VTune的安装不顺利,安装脚本报错,说发现一个非法替换(bad substitution)。不知道是怎么回事。我对bash不熟,网上也找不到有关的解决方案。希望不久这个问题能被解决。

Intel® Math Kernel Library (Intel® MKL) for Linux* - Debian* and Ubuntu* installation

Intel® Math Kernel Library (Intel® MKL) for Linux* - Debian* and Ubuntu* installation
Below are 2 methods for installing the Intel® Math Kernel Library (Intel® MKL) 9.1 on various Linux* distributions. The methods may work for some unsupported Linux operating systems and are only recommendations. Please check the ;Intel MKL system requirements for more information on Linux support.

How to install Intel MKL 9.1 on Debian

To install Intel MKL on Debian, invoke the installation directly with particular command line options.

1. Extract the Intel MKL package.
2. Run the installation with options.
* /install/install --nonrpm


How to install Intel MKL 9.1 on Ubuntu

To install Intel MKL on Ubuntu, set up a /bin/sh link to the /bin/bash interpreter and then run the installation.

1. Remove the default link.
* rm /bin/sh
2. Reassign the link to the bash interpreter.
* ln –s /bin/bash /bin/sh
3. Run the installation with options.
* /install/install --nonrpm --dash-fix
4. Rollback to the default dash interpreter.
* rm /bin/sh
* ln –s /bin/dash /bin/sh

Operating System:
Linux*

This applies to: