つっても、非公開のを別につけているわけではない。
Copyright 1999-2002. Jun Makino
2002/8 2002/7 2002/6 2002/5 2002/4 2002/3 2002/2 2002/1当面の予定
10/16 10:30 NHK 高間さん冬学期日程: (計算天文学:月曜3限) 授業開始 10月 1日(火) 授業終了 12月20日(金) 冬季休業 12月21日(土)〜1月 5日(日) 授業開始 1月 6日(月) 授業終了 1月27日(月) 補講・試験 1月28日(火)〜2月17日(月)
void transform(long long i,
double * x)
{
double pscale;
int iexp = i;
unsigned long long iscale;
iscale = (((unsigned long long) iexp) & 0x7ff) <<52;
pscale = *((double *)&iscale);
*x = pscale;
}
こんなのを gcc -O4 -S でコンパイルすると
transform:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
movl 16(%ebp), %ecx
andl $2047, %eax
movl %eax, %edx
xorl %eax, %eax
sall $20, %edx
movl %eax, (%ecx)
movl %edx, 4(%ecx)
popl %ebp
ret
こんな感じ。特になんの問題もない。で、
void transform(long long i,
double * x)
{
double pscale;
int iexp = i;
unsigned long long iscale;
iscale = (((unsigned long long) iexp) & 0x7ff) <<52;
pscale = *((double *)&iscale);
iscale = (((unsigned long long) iexp+1) & 0x7ff) <<52;
pscale = *((double *)&iscale);
*x = pscale;
}
と iscale に2回代入すると、あーら不思議
transform:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
movl 16(%ebp), %ecx
andl $2047, %eax
movl %eax, %edx
xorl %eax, %eax
sall $20, %edx
movl %eax, (%ecx)
movl %edx, 4(%ecx)
popl %ebp
ret
と、pscale には最初の値が入ったまま。
volatile unsigned long long iscale;
にすると、
transform:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl %ebx, -4(%ebp)
movl 8(%ebp), %ebx
movl -16(%ebp), %eax
movl %ebx, %edx
andl $2047, %edx
movl %edx, %ecx
xorl %edx, %edx
sall $20, %ecx
addl $1, %ebx
movl %edx, -16(%ebp)
movl %ebx, %edx
andl $2047, %edx
movl %ecx, -12(%ebp)
movl %edx, %ebx
sall $20, %ebx
xorl %edx, %edx
movl -12(%ebp), %ecx
movl %edx, -16(%ebp)
movl %ebx, -12(%ebp)
movl 16(%ebp), %ebx
movl %eax, (%ebx)
movl %ecx, 4(%ebx)
movl -4(%ebp), %ebx
movl %ebp, %esp
popl %ebp
ret
結果は正しいと思うが、いかにも遅そうな感じ。gcc 2.95.3 では
transform:
pushl %ebp
movl %esp,%ebp
subl $24,%esp
movl 16(%ebp),%eax
movl 8(%ebp),%edx
movl %edx,%ecx
sarl $31,%ecx
addl $1,%edx
adcl $0,%ecx
andl $2047,%edx
andl $0,%ecx
movl %edx,%ecx
xorl %edx,%edx
sall $20,%ecx
movl %edx,-8(%ebp)
movl %ecx,-4(%ebp)
fldl -8(%ebp)
leave
fstpl (%eax)
ret
正しいとは思うけど、3.2 のほうが賢いのは確かかも。
ちなみに
void transform2(long long i,
double * x)
{
typedef union{
long long i64;
double d;
}DATAPACK;
DATAPACK pscale;
int iexp = i;
pscale.i64 = (((unsigned long long) iexp) & 0x7ff) <<52;
pscale.i64 = (((unsigned long long) iexp+1) & 0x7ff) <<52;
*x = pscale.d;
}
と union を使うと
transform2:
pushl %ebp
movl %esp, %ebp
pushl %ebx
movl 8(%ebp), %eax
movl %eax, %edx
addl $1, %edx
movl %edx, %ebx
xorl %edx, %edx
andl $2047, %ebx
movl %ebx, %ecx
movl 16(%ebp), %ebx
sall $20, %ecx
movl %edx, (%ebx)
movl %ecx, 4(%ebx)
popl %ebx
popl %ebp
ret
と正しそうなコードがでる。
double pscale;
int iexp;
unsigmed long long iscale;
iexp = ...;
iscale = (((unsigned long long) iexp) & 0x7ff) <<52;
pscale = *((double *)&iscale);
というようなコードが gcc 2.95.x では通るのに 3.x では最適化のレベルに
よっては駄目なのはそういうものなのかしら? union 使うと問題ないみたい。
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! mailserver crashed for the second time in a month with a disk error; hence, will be taken down early Thursday for analysis. NFS server mailhost not responding still tryingはあ、そですか。私は作業はノートでしてるから別にいいんだけど、ファイア ウォールが SMTP を通さないみたいなのでメイルの中継だけメールサーバーに お願いしてるので。sendmail が諦める前にサーバー復帰してほしい。
後者の解析的な結果は普遍的なものであるので、天才であれば数値実験なんか しなくても正しい結果に到達できる。実際、境界条件は全く違うが、ブラック ホールが中心にある時の回りの密度について数学的には同じ結果をゼルドビッ チが30年以上前に出している。が、彼も銀河中心のような自己重力系に自分の 結果が拡張できることまでは気がつかなかったようで、「適用できない」と書 いてあったりする。
まあ、そういうわけで、数値実験は時には天才の頭脳の代わりになることもあるというお話なのでした。ちゃんちゃん。
In case xxx invites you for dinner at yyy (which is likely), it might be a good idea to bring some kind of jacket and maybe a tie but I don't think the latter is essential.(xxx と yyy はなんとなく伏せ字にしてみました)。
Dear Colleagues,
For the third time, the International Max-Planck Research School on
Astrophysics (IMPRS) is soliciting applications for its PhD program.
Located in the beautiful Munich-Garching area in southern Bavaria
(Germany), the school offers a unique environment for graduate students
due to the presence of four internationally renowned institutes which
form the school:
* The Max-Planck Institute for extraterrestrial Physics (MPE)
* The Observatory of the University of Munich (LMU/USM)
* The Max-Planck Institute for Astrophysics (MPA)
* The European Southern Observatory (ESO)
In addition, Astro-particle physics groups at the Technical University
of Munich and at the Werner-Heisenberg Institute for Physics are participating
as associated partners.
IMPRS offers a highly competitive PhD program, including lectures,
seminars, and a research project supervised by scientists at one of the
participating institutions. Course language is English. Students have
access to ground and spaced based observatories and instrumentation
operated by the participating institutes as well as supercomputers for
advanced numerical simulations and theoretical studies. Successful
completion of the 3 year program by meeting the requirements of the
Ludwig-Maximilians University (LMU) leads to a doctoral (PhD)
degree in natural sciences (rerum naturalium) awarded by LMU.
Applications for the program are open to students from all countries.
More details on the IMPRS program and the admission requirements can be
found at the IMPRS website http://www.imprs-astro.mpg.de/
The closing date for applications for the program starting in September
2003 is December 15, 2002. Please apply by using the IMPRS application
form available on-line at http://www.imprs-astro.mpg.de/admission.html
In addition to this announcement we have a small IMPRS-poster available
which we would ask you to print and to display for your students. The
poster is available at
http://www.imprs-astro.mpg.de/images/IMPRS_Poster_2002.pdf
Many thanks for your support.
Dr. Werner Becker
--
Manager of the International Max-Planck Research School
on Astrophysics
at the University of Munich I * M * P * R * S
Giessenbachstrasse 1 becker@imprs-astro.mpg.de
PO BOX 1312 www.imprs-astro.mpg.de
85750 Garching Phone: +49 89 30000 3588
Germany Fax: +49 89 30000 3569
で、この昔の版のプログラムには、ユーザーズガイドのテキストソースと、そ れを整形するための FORTRAN プログラムがついてきたのでした。まさに真の本物の プログラマである。
C
C
parameter ...
common
...
....
....
....
ずーっとメインプログラムが続く
....
....
....
まだまだ続く
....
....
....
どんどん続く
....
....
....
もっと続く
....
....
....
stop
end
長いプログラムでは 600 行くらいあるんだけど、それが全部メインプログラ
ム。いくつかの例では、結果をキャラクタで表示するサブルーチンがついてる
けどそれ以外には一切サブルーチンというものが使われていないという。うーみゅ。