Need for speed: Java overtakes C++?

Someone did an experiment here about the comparison of java and c++ performance.

In this experiment, I will test the wall clock time of computing a multiplication of a 2000 by 2000 matrix  with a 2000 vector.

Java is much faster than plain g++ compiler, comparable with O2 optimization, and only tiny slower than O3.

=======Result=========

+ javac jmatrix.java
+ java jmatrix
java allsum=1.8658666E16
real 15.03
user 17.30
sys 8.69
+ g++ cmatrix.cpp -o cmatrix
+ ./cmatrix
c++ allsum=1.86587e+16
real 57.28
user 57.25
sys 0.02
+ g++ -O2 cmatrix.cpp -o cmatrix2
+ ./cmatrix2
c++ allsum=1.86587e+16
real 15.34
user 15.33
sys 0.02
+ g++ -O3 cmatrix.cpp -o cmatrix3
+ ./cmatrix3
c++ allsum=1.86587e+16
real 14.86
user 14.85
sys 0.02

======Specification of the machine===============

ubuntu 10.04 64 bit Linux 2.6.32-37-generic

g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.04.2)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

6 CPU

8G memory

发表在 未分类 | 发表评论

匹郊和伯镇犯罪率比较

Comparison of crime rate between Pittsburgh (near CMU) and Berkeley (near UCB)

The following maps show total crimes reported during 2011/11/09  - 2011/12/09, for about the same size of area covered.

Pittsburgh: ~ 25

Berkeley: ~ 255

发表在 未分类 | 1条评论

installing “fascilitized” ubuntu 10.10 in SCS

Today I installed a “fascilitized” ubuntu 10.10 on a group machine, alongside the original fedora 7. I choose to use the original partition of disks and install ubuntu on a new logic volume.

Description: 4 disks, each with 500GB. Fedora is already installed on disk1.

Steps:

1. first check the disk partitions and logic volumes. (have to be root)

#fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       60801   488279610   8e  Linux LVM

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       60801   488384001   83  Linux

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1       60802   488386528+  83  Linux

Disk /dev/sdd: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1       60801   488384001   83  Linux

We see a logic partition in /dev/sda2.

2. find out the mount point of fedora and boot partition

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       24G   16G  6.7G  71% /
/dev/sdb1             459G  377G   59G  87% /usr1
/dev/sdc1             459G   85G  351G  20% /usr2
/dev/sdd1             459G  254G  182G  59% /usr3
/dev/mapper/VolGroup00-LogVol02
                      992M  379M  563M  41% /var
/dev/mapper/VolGroup00-LogVol03
                      992M  761M  180M  81% /var/cache/openafs
/dev/sda1              99M   45M   49M  48% /boot
tmpfs                 7.8G     0  7.8G   0% /dev/shm
none                  7.8G   32K  7.8G   1% /tkt
/dev/mapper/VolGroup00-LogVol01
                      402G  199M  382G   1% /usr0
AFS                   8.6G     0  8.6G   0% /afs

3. Resizethe logic volumes and create one volume for ubuntu. This must be done outside fedore system on disk. One easy way is to get a usb disk with Fedora 14 live (or any latest fedora). Those distribution includes LVM (logical volume manager).

Resize the /dev/VolGroup00/LogVol01, and add a new volume of 25GB. After the resize the volumes will be:

# /usr/sbin/lvscan
  ACTIVE            '/dev/VolGroup00/LogVol00' [24.44 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol02' [1.00 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol03' [1.00 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol01' [408.41 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol04' [7.59 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol05' [23.22 GB] inherit

Note /dev/VolGroup00/LogVol05 is the one we will be installing ubuntu on.

4. Install the ubuntu onto the virtual partition /dev/VolGroup00/LogVol05

5. Copy the content from ubuntu’s boot partition to fedora’s boot partition

vmlinuz-2.6.35-22-generic
vmcoreinfo-2.6.35-22-generic 
abi-2.6.35-22-generic 
initrd.img-2.6.35-22-generic 
System.map-2.6.35-22-generic

6. Modify the startup file /boot/grub/grub.conf

# grub.conf generated by kernelmgr 2.89
#
# Note that you do not have to rerun grub after making changes to this file
#boot=/dev/sda
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
default=2
title Fedora (2.6.23.1-001-PSC) * PRIMARY * LKG
        root (hd0,0)
        kernel /vmlinuz-2.6.23.1-001-PSC ro root=/dev/VolGroup00/LogVol00 rhgb quiet _scs_tag_=2.6.23.1-001-PSC:*LKG,*PRIMARY,PSC
        initrd /initrd-2.6.23.1-001-PSC.img
title Fedora (2.6.23.1-001-GENERIC64)
        root (hd0,0)
        kernel /vmlinuz-2.6.23.1-001-GENERIC64 ro root=/dev/VolGroup00/LogVol00 rhgb quiet _scs_tag_=2.6.23.1-001-GENERIC64:*GENERIC,GENERIC64
        initrd /initrd-2.6.23.1-001-GENERIC64.img
title Ubuntu 10.10
        root (hd0,0)
        kernel /vmlinuz-2.6.35-22-generic ro root=/dev/mapper/VolGroup00-LogVol05 quiet
        initrd /initrd.img-2.6.35-22-generic

Note we add the entry for ubuntu, and set the default boot will be ubuntu

7. Mount the all other partitions to ubuntu

sudo cp /etc/fstab /etc/fstab_backup
sudo nano /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/VolGroup00-LogVol05 /               ext3    errors=remount-ro 0       1
/dev/mapper/VolGroup00-LogVol01 /usr0           ext3    defaults        0       2
/dev/mapper/VolGroup00-LogVol00 /fedora7-root   ext3    defaults        0       2
/dev/VolGroup00/LogVol02 /fedora7-root/var                    ext3    defaults        0 2
/dev/VolGroup00/LogVol03 /fedora7-root/var/cache/openafs      ext2    defaults        0 2
/dev/mapper/VolGroup00-LogVol04 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
UUID=9cbeae77-8fb1-4a04-a570-2a03f5e6df86       /boot                   ext3    defaults        0 2
UUID=2c835369-fd37-4ef7-ba87-0ee2aca8da48               /usr1ext3     defaults        1 2
UUID=0a0f672f-242c-44db-b12a-ca4a75b2cf4c               /usr2ext3     defaults        1 2
UUID=e047ea3f-3a64-4e38-9e43-48aff2e5859d               /usr3ext3     defaults        1 2

8. Install support for afs and kerberos

9. Find and install printers

发表在 未分类 | 发表评论

US national debts and gross domestic product

Continue the previous, the following figure shows US gross debts against gross domestic product (GDP) in current dollars. 

The same figure in log scale, better showing the trend. Since the great depression, The US GDP increases exponentially at a almost constant rate over the past eighty years. Over the short course, the US gross debts overwhelms GDP at one time around 1945-1947, perhaps due to the war. However, it was fortunate that the debts increased (or even decreased in some years) much slower. The question to ask today is, do we still have the same driving force for the GDP growth while resisting the temptation of more borrowings.

Here shows the percentage of US debts to GDP. The historical highs are during the world war II and post war period. The ratio drops gradually and stables at national lows around 31% in 1970′s. It grows again in 1980′s and drops at 1995. After 2001, it soars again.References:

[1] GDP data is from Department of Commerce,  http://www.bea.gov/national/index.htm#gdp

[2] United States Department of the Treasury, http://www.treasurydirect.gov/govt/reports/pd/histdebt/histdebt.htm

发表在 economy | 1条评论

numbers speak, us debts

Over the past decades, the us total debts (including public debts and intragovernmental debts) soar exponentially.

The following figure shows the gross debts in dollar amount from 1946 to 2010.

The same figure in log scale, you will clearly see the exponential increase over the period 1970-1995, and 2001-2010.

next post I will show some figures about US GDP for your comparison.

发表在 economy | 发表评论

Pittsburgh ranked #1 livable city in US

according to Economist 2011. A small comparison.



check the original post at http://discover.news.163.com/special/liveability/

发表在 Travel | 发表评论

写在慈善大赛结束的前夜–一个OCEF义工的回忆和感言 转载 from mitbbs

非常感动。
——
发信人: plead (PNG), 信区: Donation
标 题: 写在慈善大赛结束的前夜–一个OCEF义工的回忆和感言
发信站: BBS 未名空间站 (Fri Nov 6 02:04:11 2009, 美东)

(以下言论只代表我个人,一个渺小的个体所看之世界,匆匆而就,如有疏漏或不周之处,请原谅)

在America’s Giving
Challenge刚开始时,我就想写一些在OCEF做监察工作中的所见所闻。但在过去的半个月中,实在太多慈善大赛的事需要follow-up。不单是
我,而是每个参与OCEF Challenge组织工作的义工每天需要看一百多封email,并做出comments。
在慈善大赛结束前的今晚,我无法抑制住写下一个甚至不能称之为故事的场景,一个萦绕我心多年,而未能忘怀的场景。

2006年初秋的一个傍晚,我置身于暮色渐浓的皖中乡村,除了远处依稀可见的几颗星星和若隐若显的灯光,四周宛如黑幕。这不是我第一次做OCEF的乡村监
察,所以我自然戴有监察必需品—头灯。我也知道,似乎四周灯火渺渺,但实际远近都有人烟。只不过,因为农村用电贵,所以在贫困地区的村民都尽量少开灯。

这是OCEF设在安徽舒城的一个资助点,当年该资助点共有受助学生25~27人(sorry,
今晚没时间查准确数据了。)我正去往当天最后4个学生家探访的途中,之后就可以结束这次6天的安徽监察之旅了。在村民指引下,我来到L同学的家门。这是一
座土坌房,换言之,用泥土坌实成墙,上面搭上大梁和屋顶建成的房子。说实在,这样的房屋在监察过程中已经见得太多,再也无法引发我的好奇。无论是东北,华
中还是西南,土坌房的差别只在于建筑的年份和大小,以及,坍塌度。L同学的房屋虽然有些倾斜破损,但还算“高大安全”—相比起我以前见过的只有2米高的土
坌房来说。大多数住土坌房的人都不会舍得经常开灯,所以里面即便是漆黑一片,也必然有人在。因此,我是带着轻松的心情敲开那扇大门(不要骂我凉薄,太易动
情的监察员恐怕会有抑郁症)。

果然,一个男人的声音在门后传出来。我连忙回答是基金会派来探访的人,陪我来的老师也帮忙翻译解释(我普通话一般般,对方更只会讲安徽话)。于是门打开
了,我得以进入这间漆黑的屋子,一个小姑娘应声从里屋的烛光中走出。我正要开腔,却发现在微弱的烛光中,又走出两个女人,两个衣衫不整的女人。我愣了一
下,正寻思该做如何反应才算得体。只听L的父亲咕哝了几句,于是小姑娘带着那两个女人又退回里屋。L父一边摸索着开灯,一边比划着请我们往屋里再走几步。
灯亮了,我终于看清了L父,一个矮小黝黑,左手有残疾的独眼中年男人。

我开始例行程序观察屋内摆设和家电。其实在屋外我就知道没什么可看,家电不过是电灯一盏,家具不过是破旧方桌一个,加上一条板凳,全家最新的就是帖在墙上的年画。一切都在意料之中。

监察家访的第二步是问话。按照OCEF监察规定,陪同来的老师或local
coordinator应站在远处,不能参与对话。于是我和L父开始艰辛的沟通工作,询问L家的主业是什么,家里有几口人,有多少地,种了什么农作物,有
多少家畜家禽,过去一年收了多少粮食,买了多少化肥,交了多少税费,纯收入是多少,可有外债……
在我和L父的对答期间,里屋窸窸窣窣的衣物声一直未停。等我和LF讲得七七八八,小姑娘一边帮另外两人整理仪容,一边微笑着走出来。借助昏暗的灯光,我终
于看清L妹妹,一个13,4岁清清秀秀的姑娘,也同时看清站在身边的两个女人,似乎不算年长,但她们的神情却明确地告诉我,这是两位重度智障人士… …
L妹妹和我打过招呼,接着告诉我旁边那两位是她的母亲和姐姐。回想到刚进门看到的场景,我了然于心。

在中国农村,残疾和疾病是贫穷的两大因素。OCEF资助的孩子有超过大半都是这样的家境。贫困-疾病-残疾-贫困-失学-贫困,这几乎已经成为一个恶性循
环,甚至是一个可以将人置于无望困境的死结,从而产生更多的贫困人口。而贫困地区的残疾人口则是整个社会最底层,底到贴着泥土爬行。一个贫困的农村残障人
士,如果他们希望嫁/娶一位身体健全的人,往往只能在智障的健全人中婚配,由此组成天残地缺的家庭。一定会有人说,这样的人根本不应婚嫁。但谁能撚灭生活
在最最底层的人寻觅一线可能的家庭幸福呢,即便这种幸福或不幸各人看来不同。

按OCEF监察程序第三步,监察员要询问学生的学习兴趣,核对申请表和收款表上的签名,询问收款数额和收款时间地点,款项用途,local
coordinator是否对她做过家访,她身边还有哪些同学得到资助,是否还有其他基金会资助她(们)等等。OCEF的宗旨是,资助希望读书的孩子,而
不以孩子的学习成绩作为评判。因为我们相信,虽然人的智力有高下之分,但每个人生来都有接受教育的权利,而这个权利不因出生,民族,家境,成绩而灭失。所
以,OCE发放的是助学金,而非奖学金,我们要提供给孩子一个学习的机会,一个选择去改变人生的机会。

我貌似一切如常地询问L妹妹的学习情况,收款情况。L妹妹对答有条有理,态度自然,不卑不亢。我忽然觉得眼前的这位小姑娘有着与其他受助孩子不同的气质,
甚至,她的落落大方让我有一种出众的感觉。这真的令我很惊讶,在我以往探访过的孩子中,绝大多数乡村儿童因为家贫,很少接触外面的人事,面对生人时会不自
觉的紧张。我见过因为因家境悲凉而潸然落泪的少年,也见过紧张得手心流汗说不出话的孩子,见过懵懂的娃娃,也见过不忿的学生。
而眼前这位L妹妹,一家4口,只有她一人拥有健全的智力和身体,她最远的地方只去过47公里以外的合肥,她需要从小帮助残障的父亲照料智障的母亲和姐姐,
承受外人的各式各样的目光。就是这么一个生活在社会底层,受人歧视的家庭里的小姑娘,却居然让我想到“大气”二字。

该到监察家访的最后一个环节–拍照了。我要拍两张相片,一张室内一张房屋外观,学生本人需要出现在相片中。说实在,安徽之行前,考虑到要进大别山,想轻
装上阵,于是我没有用单反相机,只带了个傻瓜机。结果这个选择让我后悔了一路。因为即便位于中原地区,安徽贫困村民仍不舍得用瓦数高一点的灯胆,昏暗灯光
下傻瓜机拍出的相片实在有负重任。

听到说要拍照,L妹妹连忙帮母亲和姐姐整理衣服头发,之后,她把父母和姐姐推到中间,自己却站在母亲和姐姐身后,经我要求她才站在中间。看到这,我真是很
感慨,换做是我,我会坦然地在镜头前展现自己家庭的“缺陷”,还是会选择尽量掩盖来维护自己的脸面呢?我想,如果我处于这样的家庭中,也许我会消极自卑,
也许我会怨天尤人,愤愤不平,至少,我无法象L妹妹那么坦然而乐观。

我很想多了解一下这个小姑娘,因为她是那么与众不同。但无奈后面还有3户学生需要走访,只好在逗留她家半个多小时后离去。但她那不卑不亢,乐观自然的神情,在3年后的今天,仍让我想起,甚至是尊敬,尊敬这积极向上,不言放弃的生命力。

每次见到受助学生和他们的家长,我都会和他们握手,无论伸过来的手是冷是热,是沾满泥土还是污垢。因为我们都是平等的,这种平等不因金钱施受而改变。钱真
的不多,一年三百多人民币不过50美金。我每每对连声道谢的受助学生和家长说,人需要互相帮助,我们带给你们的只是一个机会,真正的希望,改变命运的希望
在你们自己手中。

在中国广袤的农村,也许还有许多象L妹妹这样的孩子,他们的存在映射出中国的现状,也映射出中华民族的希望。

自从两个华人charity在各华人论坛发起募捐以来,有令人感动的众志成城,也有不同的声音出现。我,仅仅作为一个走访过受助学生的人,想对纷争的人
说,希望在民。无论你对中国的政府和制度是什么看法,真正能决定中华民族走向的,不是一个政党,不是一群精英,而是千千万万的大众。在网络上赞美或谩骂制
度,都不能从根本上改变什么。只有当这个民族有足够多受到教育,可以独立思考判断的公民时,这个民族才无惧于挑战。知易行难,坐言起行,何不从你我做起?

少年智则中国智, 少年强则中国强。强健中华,捐资助学。浩浩中华,希望在我!

贫困离我们并不遥远。
不必去到塞北边陲,不必入深山老林,就在霓光幻彩的城墙之下,就有亟待我们伸出援助之手的孩子。广袤土地上的人民不因我们在此高谈阔论口舌之争而受惠,不
会因发表几句民主宣言和谐盛世而得到幸福。 那些流离失所的孩子,无法获得教育的孩子,他们是无辜的。
你可以为黑暗中的孩子点燃一盏烛光,也可以视若无睹。

你,会是那只为黑暗中的孩子带来光亮的萤火虫吗? 我们,可以汇聚成一片萤光,照亮前路的希望吗?

发表在 未分类 | 1条评论