youtube で OpenMP

Introduction to OpenMP - Tim Mattson (Intel)

単なる学習記録:

全部でビデオクリップは27本。1つ10分程度。

 

12/28は Introduction to OpenMP: 01 Introduction - YouTube から。

12/29 は Introduction to OpenMP: 05 Module 3 - YouTube から。

12/30は Introduction to OpenMP: 11 part 1 Module 6 - YouTube から予定。

 

- heap

  • memory that you can manage

- interleave:

  • divide (memory or processing power) between a number of tasks by allocating segments of it to each task in turn.

-contrive:  

  1. to arrange a situation or event, or arrange for something to happen, using clever planning
  2. to invent and/or make a device or other object in a clever and possibly unusual way

-in the thick of sth

  • in the most active or dangerous part of a particular situation or activity

並列計算:OpenMP

並列計算を行う必要がありそうなので、OpenMPを勉強することにした。自分に必要なリンクなどをまとめる。

 

[1]教材

C言語によるOpenMP入門(当面はこれ)

http://www.cc.u-tokyo.ac.jp/support/press/news/VOL9/special/9.pdf

Vol.9 特集号(2008年2月) [東京大学情報基盤センタースーパーコンピューティング部門]

・2013年度 計算科学技術特論A 第3回 OpenMPの基礎

http://www.cms-initiative.jp/ja/events/20130425katagiri.pdf

・筑波大の資料。

http://www.hpcs.cs.tsukuba.ac.jp/~taisuke/EXPERIMENT/openmp-txt.pdf

・神戸大の資料。fortran

http://exp.cs.kobe-u.ac.jp/wiki/comp_practice/index.php?plugin=attach&refer=4.OpenMP%A4%F2%CD%D1%A4%A4%A4%BF%CA%C2%CE%F3%B7%D7%BB%BB&openfile=openmp1_yaguchi_2012.pdf

 

 

[2] Macbook Air (OSX 10.7.5) の gcc を切り替える

Macports で gcc 4.7 (GNUコンパイラ) を入手する。

# これなら OpenMP の threadprivate が使えるらしい。

# http://openmp.org/forum/viewtopic.php?f=3&t=698#p2784

 

$ gcc -version
i686-apple-darwin11-llvm-gcc-4.2: no input files

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)


(1) Macports のupdate

$ sudo port selfupdate
$ sudo port sync

(2) 入手可能なgccのリストアップ

$ port search gcc

...

gcc46 @4.6.4_7 (lang)
The GNU compiler collection

gcc47 @4.7.4_3 (lang)
The GNU compiler collection

gcc48 @4.8.3_4 (lang)
The GNU compiler collection

gcc49 @4.9.2_1 (lang)
The GNU compiler collection
...

といろいろ出てくる。

$ port select --list gcc
Warning: Unable to get active selected version: The specified group 'gcc' does not exist.
Error: The 'list' command failed: The specified group 'gcc' does not exist.

↑他のサイトを参考に打ち込んでみたが、なんか怒られた。以下には影響しない。

(3) 新しいgccのインストール

$ sudo port install gcc47

ここまでではgccは切り替わっていない。

$ gcc -version
i686-apple-darwin11-llvm-gcc-4.2: no input files

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)


(4) 新しい gcc への切り替え

まずは、gccのどれが入っているか調べる。

$ sudo port select --list gcc
Password:
Available versions for gcc:
gcc42
llvm-gcc42
mp-gcc47
none (active)

mp-gcc47をgccとして選ぶ。

$ sudo port select gcc mp-gcc47
Selecting 'mp-gcc47' for 'gcc' succeeded. 'mp-gcc47' is now active.

以下のように怒られ、一瞬焦る。

$ gcc -v
gcc-mp-4.7: error trying to exec '/opt/local/bin/i686-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory

$ gcc -version
gcc-mp-4.7: error trying to exec '/opt/local/bin/i686-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory

新たなterminal window を開くと、解決する:

$ gcc -version
gcc: error: unrecognized command line option '-version'
gcc: fatal error: no input files
compilation terminated.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.4/lto-wrapper
Target: x86_64-apple-darwin11
Configured with: /opt/local/var/macports/build/_opt_mports_dports_lang_gcc47/gcc47/work/gcc-4.7.4/configure --prefix=/opt/local --build=x86_64-apple-darwin11 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.4_3'
Thread model: posix
gcc version 4.7.4 (MacPorts gcc47 4.7.4_3)

なお、新たに入れたgccだと、「-version」は使えないようである:

$ gcc -version
gcc: error: unrecognized command line option '-version'
gcc: fatal error: no input files
compilation terminated.

 

 参考

MacPortsでgcc 4.7を。 - udon's blog

mac port で gcc4.8を入れたった - Bye Bye Moore

MacPortsを使ったgfortranインストール方法 : てふこの部屋

OpenMP® Forum • Information

 

Mac mini 初期設定

mac mini (OSX 10.10 Yosemite)を設定。以前macbook airでやったのと似ている。

gcc, gnuplot,  gsl, tex の環境設定 [備忘録]

 

(1) 「Xcode」のインストール

App Store よりXcode をインストール。

バックグラウンドでやられたので所要時間不明。

DLの経過はLaunchpadで観察。

 

(2) 「Command Line Tools」のインストール

Xcodeをインストールしたら、Command Line Toolsはすでに入っていた。

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

これで「make」などのコマンドが打てるようになる。

$ gcc -v
gccがインストールできたことが確認できる。
今回参考にしたページ 


Xcode Command Line Tools · Yosemite · Install

 

(3) 「MacPorts」のインストール

(3-1) MacPorts 本体のインストール

$ cd
$ sudo xcodebuild -license

この部分については下記ページを参考にした:

The MacPorts Project -- Download & Installation

MacPorts、OS X Yosemiteに対応したMacPort v2.3.2をリリース。

 

 

(3-2)環境の設定

パス設定。

$ vi ~/.bash_profile

「i」コマンドを押してから入力し、「:qw」で保存。

----↓ここから

PATH=/opt/local/bin:/opt/local/sbin:$PATH

MANPATH=/opt/local/man:$MANPATH

----↑ここまで

設定したらコマンドラインを再起動。

 

(3-3)  MacPortsツールをインストール。

$ sudo port -d selfupdate 

$ sudo port -d sync

 

参考 http://tama.hatenablog.jp/entry/2012/07/26/200735

参考 http://mewc.to/CGI/howto/unix2.html (viの使い方)

 

 (4) 「gnuplot」インストール

$ sudo port install gnuplot

参考 http://coffee.guhaw.com/Entry/78/

参考 http://co.maxwell.jp/?page=gnuplot+%A4%F2+Mac+OS+X+Lion+%A4%D8%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB

 

(5) 「GSL」 インストール

$ tar zxvf gsl-1.16.tar.gz

$ cd gsl-1.16

$ ./configure

$ make

$ sudo make install



=====ここまで====
以下は以前のエントリコピペ:

 (5) 「mactex 2012」インストール

http://www.tug.org/mactex/

からダウンロード(ファイルは2GB程度)。

(5-1) /Applications/TeX の下にあるTeXShop.appを起動。

(5-2) 環境設定 > 「書類」タブ左下の設定プロファイル > デフォルトのまま。

# 日本語文書を作るときはここをpTex (EUC)にする。

(5-3) エンコーディングUnicode(UTF-8)」

(5-4) フォント > Time

(5-5) 「コンソール」タブ > コンソールのフォントを日本語フォントに。

(5-6) /Applications/TEX にある 「TexShop.app」「LaTeXiT.app」をDockに入れる。

 

参考 http://d.hatena.ne.jp/hrt10/20110514/1305379357 感謝。

# 基本的に英語文章(論文)作成時は初期設定で問題ない模様。

# 日本語の学会予稿とか作成するときまた考えよう。

 

研究で悩んだときの簡単なガイドライン

利根川進が、ある研究所の雰囲気を

「超一流の研究以外は眼中にない」

という表現で描写していた。

 

あるブログで、いい研究室の目安として

「この先伸びそうな分野の研究を精力的にやっている」

という表現が使われていた。

 

自分は博士課程の頃、「自分が"アホでない"ことを認めてもらうための論文」に時間をさいてしまっていた。だから論文の本数にこだわっていたし、他人[同期や若いポスドク]と比較もしていた。

本来は、「自分が"超一流のプレーヤー"であることがわかってしまうような論文」をめざすべきだったんだな。

 

研究者として生き残るためには、「良いビジョン」を持つこと。これに尽きる。

良いビジョンを持っていれば、仕事に夢中になれる。前に進んだ分だけ周囲の評価が上昇する。

誰かの席に座るということ

博士課程3年の頃、仙台に出張する機会があった。天文学の研究グループの前で研究発表をする機会を得たのだ。

その大学には仲のよい友人がいたのだが、ちょうど彼も出張中であったので、数日の滞在中ずっと彼のデスクを使わせてもらった。

彼のデスクは非常に整頓されていた。どれくらいの整頓具合かというと、彼がどんな分野に興味をもっているのか、デスクに座っただけで一目瞭然であった。笑

 

そこでわき上がる疑問は、

「彼の視点で、俺の研究を見たら、どういう反応になるだろうか。」

ということだった。

 

彼のデスクに座ることで、彼の視点を得ることがきたわけだ。

 

ビジネス書に「上司の席に座れ」とある。大学等の学問・研究の世界では、実際のところ、上司の席に座ることは難しい。しかし、空想の中だけでもする価値はある。

名誉教授との語らい

今日のランチは、庭で名誉教授のD先生と食べた。

いろんな昔話をしてくれたが、自分の英語力のなさで理解不能なところもたくさんあった。貴重なことなのでメモしておく。笑

 

メモ:

・first memory: 果樹園の近くで通りに出てみんなが楽器をならしている

イスラエルに行ったときに(2000年ころ)バスで一緒だった同年代のladyのfirst memoryも同じだった。

・父親はarmy カメラをとっていた?

ユダヤ人とシリア人の土地に対する考え方の違い。

 

16:00ころにtea breakが終わって部屋に戻る途中、自転車に乗ったD氏とすれ違い、笑顔を向けたら(両手が塞がっていた)、手を振られてとても嬉しかったのを妙に覚えている。思春期の坊やがあこがれの人と会ったかのような笑

翻訳の翻訳

Google翻訳を使って

英語E1→日本語J1

日本語J1→英語E2

のように「翻訳の翻訳」を行うと、「英語E1」と「英語E2」は必ずしも一致しない。それどころか、さらに

英語E2→日本語J2

日本語J2→英語E3

......

と繰り返すと、だいたいとんでもないことになる。

 

====

友人の公募書類に目を通してコメントをする、という機会がこの4月何度かあった。

公募書類は、自分を全く知らないような人(審査員)に、自分の研究の重要性を効率よく伝えなければいけない。そのため、普段使っている言葉とは違った言葉で文章を書く。あるいは普段は大前提としていることもしっかり明文化する。すなわち、アイデアの翻訳を行う。こうした作業は結構大変なのだが、これは良い経験でもある。翻訳を通じて新たな視点が得られるからだ。

 

同様に、

具体C1→抽象A1

抽象A1→具体C2

といった翻訳も、研究の中で面白い視点を与えてくれることがある。

全く関係のない分野のtalkを聞いたとき、せいぜいできることは、それを自分のコンテクストに生かすように抽象的な概念に翻訳することだ。そうして蓄積した抽象的思考が、自分の問題を解く上で思わぬヒントや戦略を与えてくれることがある。