どうも、はむばねです。
一応本日2回目の更新。
Intel Math Kernel Libraryはなんかもう無理くせー臭がプンプンしてやがりましたので、諦めてNAS Parallel Benchmarksを入れることにしたよー\(^o^)/
私に入れられるようなもんの設定方法書いたところで需要はないのでしょうが、まぁ自分用メモということで。
今回はNPB3.3のNPB3.3-MPIを使用。
基本的なところは、ここ あたりに書いてあることそのままです。
しかしmake.defが最終的に例とかなり違ったので、以下とりあえず実際に今回作ったmake.def。
変更箇所は赤太字にしてあります。
基本的に、該当のファイルをlocateして見つかった場所のフルパスを記述していけばおk。
ていうかだいたいmpich周辺をしていしておけばおk。
(11/15追記:
mpichインストール済み前提です。mpichインストール方法はまた別途やるかも)
#---------------------------------------------------------------------------
#
# SITE- AND/OR PLATFORM-SPECIFIC DEFINITIONS.
#
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Items in this file will need to be changed for each platform.
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Parallel Fortran:
#
# For CG, EP, FT, MG, LU, SP and BT, which are in Fortran, the following must
# be defined:
#
# MPIF77 - Fortran compiler
# FFLAGS - Fortran compilation arguments
# FMPI_INC - any -I arguments required for compiling MPI/Fortran
# FLINK - Fortran linker
# FLINKFLAGS - Fortran linker arguments
# FMPI_LIB - any -L and -l arguments required for linking MPI/Fortran
#
# compilations are done with $(MPIF77) $(FMPI_INC) $(FFLAGS) or
# $(MPIF77) $(FFLAGS)
# linking is done with $(FLINK) $(FMPI_LIB) $(FLINKFLAGS)
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# This is the fortran compiler used for MPI programs
#---------------------------------------------------------------------------
MPIF77 = /opt/mpich2/bin/mpif77
# This links MPI fortran programs; usually the same as ${MPIF77}
FLINK = $(MPIF77)
#---------------------------------------------------------------------------
# These macros are passed to the linker to help link with MPI correctly
#---------------------------------------------------------------------------
#FMPI_LIB = -L/usr/local/lib -lmpi
#FMPI_LIB = -L/opt/mpich2/lib -lmpi
#---------------------------------------------------------------------------
# These macros are passed to the compiler to help find 'mpif.h'
#---------------------------------------------------------------------------
#FMPI_INC = -I/usr/local/include
#FMPI_INC = -I/opt/mpich2/include
#---------------------------------------------------------------------------
# Global *compile time* flags for Fortran programs
#---------------------------------------------------------------------------
FFLAGS = -O3
#---------------------------------------------------------------------------
# Global *link time* flags. Flags for increasing maximum executable
# size usually go here.
#---------------------------------------------------------------------------
FLINKFLAGS =
#---------------------------------------------------------------------------
# Parallel C:
#
# For IS, which is in C, the following must be defined:
#
# MPICC - C compiler
# CFLAGS - C compilation arguments
# CMPI_INC - any -I arguments required for compiling MPI/C
# CLINK - C linker
# CLINKFLAGS - C linker flags
# CMPI_LIB - any -L and -l arguments required for linking MPI/C
#
# compilations are done with $(MPICC) $(CMPI_INC) $(CFLAGS) or
# $(MPICC) $(CFLAGS)
# linking is done with $(CLINK) $(CMPI_LIB) $(CLINKFLAGS)
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# This is the C compiler used for MPI programs
#---------------------------------------------------------------------------
#MPICC = cc
MPICC = /opt/mpich2/bin/mpicc
# This links MPI C programs; usually the same as ${MPICC}
CLINK = $(MPICC)
#---------------------------------------------------------------------------
# These macros are passed to the linker to help link with MPI correctly
#---------------------------------------------------------------------------
#CMPI_LIB = -L/opt/mpich2/lib -lmpi
#---------------------------------------------------------------------------
# These macros are passed to the compiler to help find 'mpi.h'
#---------------------------------------------------------------------------
#CMPI_INC = -I/usr/local/include
#CMPI_INC = -I/opt/mpich2/include/
#---------------------------------------------------------------------------
# Global *compile time* flags for C programs
#---------------------------------------------------------------------------
CFLAGS = -O3
#---------------------------------------------------------------------------
# Global *link time* flags. Flags for increasing maximum executable
# size usually go here.
#---------------------------------------------------------------------------
CLINKFLAGS =
#---------------------------------------------------------------------------
# MPI dummy library:
#
# Uncomment if you want to use the MPI dummy library supplied by NAS instead
# of the true message-passing library. The include file redefines several of
# the above macros. It also invokes make in subdirectory MPI_dummy. Make
# sure that no spaces or tabs precede include.
#---------------------------------------------------------------------------
# include ../config/make.dummy
#---------------------------------------------------------------------------
# Utilities C:
#
# This is the C compiler used to compile C utilities. Flags required by
# this compiler go here also; typically there are few flags required; hence
# there are no separate macros provided for such flags.
#---------------------------------------------------------------------------
#CC = /usr/bin/gcc -g
CC = gcc
#---------------------------------------------------------------------------
# Destination of executables, relative to subdirs of the main directory. .
#---------------------------------------------------------------------------
BINDIR = ../bin
#---------------------------------------------------------------------------
# Some machines (e.g. Crays) have 128-bit DOUBLE PRECISION numbers, which
# is twice the precision required for the NPB suite. A compiler flag
# (e.g. -dp) can usually be used to change DOUBLE PRECISION variables to
# 64 bits, but the MPI library may continue to send 128 bits. Short of
# recompiling MPI, the solution is to use MPI_REAL to send these 64-bit
# numbers, and MPI_COMPLEX to send their complex counterparts. Uncomment
# the following line to enable this substitution.
#
# NOTE: IF THE I/O BENCHMARK IS BEING BUILT, WE USE CONVERTFLAG TO
# SPECIFIY THE FORTRAN RECORD LENGTH UNIT. IT IS A SYSTEM-SPECIFIC
# VALUE (USUALLY 1 OR 4). UNCOMMENT THE SECOND LINE AND SUBSTITUTE
# THE CORRECT VALUE FOR "length".
# IF BOTH 128-BIT DOUBLE PRECISION NUMBERS AND I/O ARE TO BE ENABLED,
# UNCOMMENT THE THIRD LINE AND SUBSTITUTE THE CORRECT VALUE FOR
# "length"
#---------------------------------------------------------------------------
# CONVERTFLAG = -DCONVERTDOUBLE
# CONVERTFLAG = -DFORTRAN_REC_SIZE=length
# CONVERTFLAG = -DCONVERTDOUBLE -DFORTRAN_REC_SIZE=length
#---------------------------------------------------------------------------
# The variable RAND controls which random number generator
# is used. It is described in detail in README.install.
# Use "randi8" unless there is a reason to use another one.
# Other allowed values are "randi8_safe", "randdp" and "randdpvec"
#---------------------------------------------------------------------------
#RAND = randi8
# The following is highly reliable but may be slow:
RAND = randdp
個人的に最大の罠は、
#FMPI_LIB = -L/opt/mpich2/lib -lmpi
#FMPI_INC = -I/opt/mpich2/include
こいつら。
ここが残っていると、”/usr/bin/ld: cannot find -lmpi”とかで怒られます。
別に設定する必要はないらしいので、コメントアウト。
(11/15追記:
CMPI_LIB、CMPI_INCもコメントアウト)
あとはMPIF77とかCCのところを普通に/usr/bin/f77とか/usr/bin/ccとか書いてたせいで最後まで残ってたエラーくらいでしょうか。
ここ では「CCの指定はmpiccじゃねーよハゲ」とか言われてますが、私はむしろmpiccにしなければ上手くいきませんでした。
(11/15追記:
別にmpiccでも問題でなかったけど、gccでも問題なかったぽいので一応gccにしておいた)
(11/15追記:
RAND=randi8をRAND=randdpに変更。
対象問題によってはこっちじゃないとコンパイルエラーが出たため。
コメントに書かれている通り、randdpの方が遅いけど信頼性は高いらしい)
こうやって書くとホント簡単ですね。
なんかやってる最中は結構苦労したんですけどね、こんなのでも。
(11/15追記:
やっぱりまだクラスなどによってはコンパイルできない部分多数(特にDクラス以降)
今後解決すればまた追記しますが、たぶん諦める可能性の方が大)
余談ですが、せっかくmakeは成功したのに実行できずに10分くらいてこずってました。
結局mpiexecの存在自体を忘れてたのと、./つけ忘れてたのが原因でした。
テラ初心者wwww
もしかするとまたチューニング編とかやるかもしれません。
やらないかもしれません。
やりました 。
このエントリ以上にクソの役にも立たねぇけどな!