Linpack的编译和安装

使用的是openmpi + Gotoblas + HPL
此间过程结合参考了如下地址的相关信息:
1. http://www.ithao123.cn/content-782997.html
2. http://wenku.baidu.com/link?url=Geex2oLJQnJYh2S0alPeqO2TGbQoZ_6GPbsdX-41NTBFFMIT_oANCDgThFI8I3lhTaiFU2PBRhJcItNtCyEq3zM2glfqVKUgCClCbvj2H3K
3. http://james23dier.iteye.com/blog/780098

分别下载
这里写图片描述
中的前两个,因为网上大部分人用的是mpich,而本人以前一直用的openmpi,所以就直接用其代替,效果是一样的。
Gotoblas,BLAS库(Basic Linear Algebra Subprograms)是执行向量和矩阵运算的子程序集合。
HPL,linpack测试的软件,可在http://www.netlib.org/benchmark/hpl/下载最新版本。

Linpack的编译和安装_第1张图片
1. 安装openmpi,这里要注意openmpi 的安装路径,因为后面使用其include路径以及其中的lib路径需要用到。安装过程不再赘述。
2. 建立linpack文件夹路径,其下为解压后的
这里写图片描述
3. 进入Gotoblas文件夹,在终端下执行./ quickbuild.64bit(如果你是32位系统,则执行./ quickbuild.31bit)进行快速安装,当然,你也可以依据README里的介绍自定义安装。如果安装正常,在本目录下就会生成libgoto2.a和libgoto2.so两个文件。
期间会遇到问题,是由于CPU太新,配置文件无法识别引起的
参考:http://blog.sina.com.cn/s/blog_733912170100snnh.html
修改的Makefile.rule文件如下:
1 #
2 # Beginning of user configuration
3 #
4
5 # This library’s version
6 VERSION = 1.13
7
8 # You can specify the target architecture, otherwise it’s
9 # automatically detected.
10 # TARGET = PENRYN
11
12 # If you want to support multiple architecture in one binary
13 # DYNAMIC_ARCH = 1
14
15 # C compiler including binary type(32bit / 64bit). Default is gcc.
16 # Don’t use Intel Compiler or PGI, it won’t generate right codes as I expect.
17 CC = gcc
18
19 # Fortran compiler. Default is g77.
20 FC = gfortran
21
22 # Even you can specify cross compiler
23 # CC = x86_64-w64-mingw32-gcc
24 # FC = x86_64-w64-mingw32-gfortran
25
26 # If you need 32bit binary, define BINARY=32, otherwise define BINARY=64
27 BINARY=64
28
29 # About threaded BLAS. It will be automatically detected if you don’t
30 # specify it.
31 # For force setting for single threaded, specify USE_THREAD = 0
32 # For force setting for multi threaded, specify USE_THREAD = 1
33 # USE_THREAD = 0
34
35 # If you’re going to use this library with OpenMP, please comment it in.
36 # USE_OPENMP = 1
37
38 # You can define maximum number of threads. Basically it should be
39 # less than actual number of cores. If you don’t specify one, it’s
40 # automatically detected by the the script.
41 # NUM_THREADS = 24
42
43 # If you don’t need CBLAS interface, please comment it in.
44 # NO_CBLAS = 1
45
46 # If you want to use legacy threaded Level 3 implementation.
47 # USE_SIMPLE_THREADED_LEVEL3 = 1
48
49 # If you want to drive whole 64bit region by BLAS. Not all Fortran
50 # compiler supports this. It’s safe to keep comment it out if you
51 # are not sure(equivalent to “-i8” option).
52 # INTERFACE64 = 1
53
54 # Unfortunately most of kernel won’t give us high quality buffer.
55 # BLAS tries to find the best region before entering main function,
56 # but it will consume time. If you don’t like it, you can disable one.
57 # NO_WARMUP = 1
58
59 # If you want to disable CPU/Memory affinity on Linux.
60 # NO_AFFINITY = 1
61
62 # If you would like to know minute performance report of GotoBLAS.
63 # FUNCTION_PROFILE = 1
64
65 # Support for IEEE quad precision(it’s real REAL*16)( under testing)
66 # QUAD_PRECISION = 1
67
68 # Theads are still working for a while after finishing BLAS operation
69 # to reduce thread activate/deactivate overhead. You can determine
70 # time out to improve performance. This number should be from 4 to 30
71 # which corresponds to (1 << n) cycles. For example, if you set to 26,
72 # thread will be running for (1 << 26) cycles(about 25ms on 3.0GHz
73 # system). Also you can control this mumber by GOTO_THREAD_TIMEOUT
74 # CCOMMON_OPT += -DTHREAD_TIMEOUT=26
75
76 # Using special device driver for mapping physically contigous memory
77 # to the user space. If bigphysarea is enabled, it will use it.
78 # DEVICEDRIVER_ALLOCATION = 1
79
80 # If you need to synchronize FP CSR between threads (for x86/x86_64 only).
81 # CONSISTENT_FPCSR = 1
82
83 # If you need santy check by comparing reference BLAS. It’ll be very
84 # slow (Not implemented yet).
85 # SANITY_CHECK = 1
86
87 # Common Optimization Flag; -O2 is enough.
88 COMMON_OPT += -O2
89
90 # Profiling flags
91 COMMON_PROF = -pg
92
93 #
94 # End of user configuration
95 #
Linpack的编译和安装_第2张图片
如上操作后,问题解决。
(4)安装HPL。
进入hpl文件夹从setup文件夹下提取与自己平台相近的Make.文件,复制到hpl文件夹内,比如我们的平台为Intel xeon,所以就选择了Make.Linux_PII_FBLAS,它代表Linux操作系统、PII平台、采用FBLAS库。
编辑刚刚复制的文件,根据说明修改各个选项,使之符合自己的系统,比如我们系统的详细情况为,Intel xeon平台,mpich2安装目录为/usr/local/mipch2,hpl和gotoblas安装目录为/root/linpack,下面是我们的配置文件Make.Linux_xeon,对需要修改的部分我们做了注解,大家可以参考修改:
1. # - shell ————————————————————–
2. # ———————————————————————-
3. #
4. SHELL = /bin/sh
5. #
6. CD = cd
7. CP = cp
8. LN_S = ln -s
9. MKDIR = mkdir
10. RM = /bin/rm -f
11. TOUCH = touch
12. #
13. # ———————————————————————-
14. # - Platform identifier ————————————————
15. # ———————————————————————-
16. #
17. ARCH = Linux_xeon //设置平台类型
18. #
19. # ———————————————————————-
20. # - HPL Directory Structure / HPL library ——————————
21. # ———————————————————————-
22. #
23. TOPdir = (HOME)/linpack/hpl//24.INCdir= (TOPdir)/include
25. BINdir = (TOPdir)/bin/ (ARCH)
26. LIBdir = (TOPdir)/lib/ (ARCH)
27. #
28. HPLlib = (LIBdir)/libhpl.a  
29. #  
30. # ———————————————————————-  
31. # - Message Passing library (MPI) ————————————–  
32. # ———————————————————————-  
33. # MPinc tells the  C  compiler where to find the Message Passing library  
34. # header files,  MPlib  is defined  to be the name of  the library to be  
35. # used. The variable MPdir is only used for defining MPinc and MPlib.  
36. #  
37. MPdir        = /usr/local/mpich2    //设置mpich的安装目录  
38. MPinc        = -I
(MPdir)/include
39. MPlib = (MPdir)/lib/libmpich.a  
40. #  
41. # ———————————————————————-  
42. # - Linear Algebra library (BLAS or VSIPL) —————————–  
43. # ———————————————————————-  
44. # LAinc tells the  C  compiler where to find the Linear Algebra  library  
45. # header files,  LAlib  is defined  to be the name of  the library to be  
46. # used. The variable LAdir is only used for defining LAinc and LAlib.  
47. #  
48. LAdir        =
(HOME)/linpack/GotoBLAS2 //设置gotoblas的目录
49. LAinc =
50. LAlib = (LAdir)/libgoto2.a (LAdir)/libgoto2.so //加入库支持
51. #
52. # ———————————————————————-
53. # - F77 / C interface ————————————————–
54. # ———————————————————————-
55. # You can skip this section if and only if you are not planning to use
56. # a BLAS library featuring a Fortran 77 interface. Otherwise, it is
57. # necessary to fill out the F2CDEFS variable with the appropriate
58. # options. One and only one option should be chosen in each of
59. # the 3 following categories:
60. #
61. # 1) name space (How C calls a Fortran 77 routine)
62. #
63. # -DAdd_ : all lower case and a suffixed underscore (Suns,
64. # Intel, …), [default]
65. # -DNoChange : all lower case (IBM RS6000),
66. # -DUpCase : all upper case (Cray),
67. # -DAdd__ : the FORTRAN compiler in use is f2c.
68. #
69. # 2) C and Fortran 77 integer mapping
70. #
71. # -DF77_INTEGER=int : Fortran 77 INTEGER is a C int, [default]
72. # -DF77_INTEGER=long : Fortran 77 INTEGER is a C long,
73. # -DF77_INTEGER=short : Fortran 77 INTEGER is a C short.
74. #
75. # 3) Fortran 77 string handling
76. #
77. # -DStringSunStyle : The string address is passed at the string loca-
78. # tion on the stack, and the string length is then
79. # passed as an F77_INTEGER after all explicit
80. # stack arguments, [default]
81. # -DStringStructPtr : The address of a structure is passed by a
82. # Fortran 77 string, and the structure is of the
83. # form: struct {char *cp; F77_INTEGER len;},
84. # -DStringStructVal : A structure is passed by value for each Fortran
85. # 77 string, and the structure is of the form:
86. # struct {char *cp; F77_INTEGER len;},
87. # -DStringCrayStyle : Special option for Cray machines, which uses
88. # Cray fcd (fortran character descriptor) for
89. # interoperation.
90. #
91. F2CDEFS = -DAdd__ -DF77_INTEGER=int -DStringSunStyle
92. #
93. # ———————————————————————-
94. # - HPL includes / libraries / specifics ——————————-
95. # ———————————————————————-
96. #
97. HPL_INCLUDES = -I (INCdir)I (INCdir)/ (ARCH) (LAinc) (MPinc)98.HPLLIBS= (HPLlib) (LAlib) (MPlib)
99. #
100. # - Compile time options ———————————————–
101. #
102. # -DHPL_COPY_L force the copy of the panel L before bcast;
103. # -DHPL_CALL_CBLAS call the cblas interface;
104. # -DHPL_CALL_VSIPL call the vsip library;
105. # -DHPL_DETAILED_TIMING enable detailed timers;
106. #
107. # By default HPL will:
108. # *) not copy L before broadcast,
109. # *) call the BLAS Fortran 77 interface,
110. # *) not display detailed timing information.
111. #
112. HPL_OPTS =
113. #
114. # ———————————————————————-
115. #
116. HPL_DEFS = (F2CDEFS) (HPL_OPTS) (HPL_INCLUDES)  
117.    #  
118.    # ———————————————————————-  
119.    # - Compilers / linkers - Optimization flags —————————  
120.    # ———————————————————————-  
121.    #  
122.    CC           = /usr/local/mpich2/bin/mpicc  //设置gcc编译器为mpicc  
123.    CCNOOPT      =
(HPL_DEFS)
124. CCFLAGS = (HPL_DEFS) -fomit-frame-pointer -O3 -funroll-loops -W -Wall  
125.    #  
126.    # On some platforms,  it is necessary  to use the Fortran linker to find  
127.    # the Fortran internals used in the BLAS library.  
128.    #  
129.    LINKER       = /usr/local/mpich2/bin/mpif77 //设置fortran编译器为mpif77  
130.    LINKFLAGS    =
(CCFLAGS)
131. #
132. ARCHIVER = ar
133. ARFLAGS = r
134. RANLIB = echo
135. #
136. # —————————–/usr/local/mpich2/bin/mpicc———————

我们这里选择从 /setup目录下复制这里写图片描述到/hpl目录下。因为本机上用的是intel xeon处理器 ,所以用PII的 ,CBLAS中的C大概表示C语言, 如果使用Fortran则是F开头的。并改名为Make.test 此处的test表示arch即架构。

对应使用的openmpi而非mpich 以及实际各种路径,我们编辑的Make.test文件为:
1 #
2 # – High Performance Computing Linpack Benchmark (HPL)
3 # HPL - 2.2 - February 24, 2016
4 # Antoine P. Petitet
5 # University of Tennessee, Knoxville
6 # Innovative Computing Laboratory
7 # (C) Copyright 2000-2008 All Rights Reserved
8 #
9 # – Copyright notice and Licensing terms:
10 #
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
13 # are met:
14 #
15 # 1. Redistributions of source code must retain the above copyright
16 # notice, this list of conditions and the following disclaimer.
17 #
18 # 2. Redistributions in binary form must reproduce the above copyright
19 # notice, this list of conditions, and the following disclaimer in the
20 # documentation and/or other materials provided with the distribution.
21 #
22 # 3. All advertising materials mentioning features or use of this
23 # software must display the following acknowledgement:
24 # This product includes software developed at the University of
25 # Tennessee, Knoxville, Innovative Computing Laboratory.
26 #
27 # 4. The name of the University, the name of the Laboratory, or the
28 # names of its contributors may not be used to endorse or promote
29 # products derived from this software without specific written
30 # permission.
31 #
32 # – Disclaimer:
33 #
34 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 # “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
38 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 # DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 # ######################################################################
46 #
47 # ———————————————————————-
48 # - shell ————————————————————–
49 # ———————————————————————-
50 #
51 SHELL = /bin/sh
52 #
53 CD = cd
54 CP = cp
55 LN_S = ln -s
56 MKDIR = mkdir
57 RM = /bin/rm -f
58 TOUCH = touch
59 #
60 # ———————————————————————-
61 # - Platform identifier ————————————————
62 # ———————————————————————-
63 #
64 ARCH =test
65 #
66 # ———————————————————————-
67 # - HPL Directory Structure / HPL library ——————————
68 # ———————————————————————-
69 #
70 TOPdir = /home/zgz/sourcecode/linpack/hpl
71 INCdir = (TOPdir)/include72BINdir= (TOPdir)/bin/ (ARCH)73LIBdir= (TOPdir)/lib/(ARCH)  
    74  #  
    75  HPLlib       =
(LIBdir)/libhpl.a
76 #
77 # ———————————————————————-
78 # - Message Passing library (MPI) ————————————–
79 # ———————————————————————-
80 # MPinc tells the C compiler where to find the Message Passing library
81 # header files, MPlib is defined to be the name of the library to be
82 # used. The variable MPdir is only used for defining MPinc and MPlib.
83 #
84 MPdir = /home/zgz/openmpi
85 MPinc = -I (MPdir)/include86MPlib= (MPdir)/lib/libmpi.so
87 #
88 # ———————————————————————-
89 # - Linear Algebra library (BLAS or VSIPL) —————————–
90 # ———————————————————————-
91 # LAinc tells the C compiler where to find the Linear Algebra library
92 # header files, LAlib is defined to be the name of the library to be
93 # used. The variable LAdir is only used for defining LAinc and LAlib.
94 #
95 LAdir = /home/zgz/sourcecode/linpack/GotoBLAS2
96 LAinc =
97 LAlib = (LAdir)/libgoto2.a (LAdir)/libgoto2.so
98 #
99 # ———————————————————————-
100 # - F77 / C interface ————————————————–
101 # ———————————————————————-
102 # You can skip this section if and only if you are not planning to use
103 # a BLAS library featuring a Fortran 77 interface. Otherwise, it is
104 # necessary to fill out the F2CDEFS variable with the appropriate
105 # options. One and only one option should be chosen in each of
106 # the 3 following categories:
107 #
108 # 1) name space (How C calls a Fortran 77 routine)
109 #
110 # -DAdd_ : all lower case and a suffixed underscore (Suns,
111 # Intel, …), [default]
112 # -DNoChange : all lower case (IBM RS6000),
113 # -DUpCase : all upper case (Cray),
114 # -DAdd__ : the FORTRAN compiler in use is f2c.
115 #
116 # 2) C and Fortran 77 integer mapping
117 #
118 # -DF77_INTEGER=int : Fortran 77 INTEGER is a C int, [default]
119 # -DF77_INTEGER=long : Fortran 77 INTEGER is a C long,
120 # -DF77_INTEGER=short : Fortran 77 INTEGER is a C short.
121 #
122 # 3) Fortran 77 string handling
123 #
124 # -DStringSunStyle : The string address is passed at the string loca-
125 # tion on the stack, and the string length is then
126 # passed as an F77_INTEGER after all explicit
127 # stack arguments, [default]
128 # -DStringStructPtr : The address of a structure is passed by a
129 # Fortran 77 string, and the structure is of the
130 # form: struct {char *cp; F77_INTEGER len;},
131 # -DStringStructVal : A structure is passed by value for each Fortran
132 # 77 string, and the structure is of the form:
133 # struct {char *cp; F77_INTEGER len;},
134 # -DStringCrayStyle : Special option for Cray machines, which uses
135 # Cray fcd (fortran character descriptor) for
136 # interoperation.
137 #
138 F2CDEFS =
139 #
140 # ———————————————————————-
141 # - HPL includes / libraries / specifics ——————————-
142 # ———————————————————————-
143 #
144 HPL_INCLUDES = -I (INCdir)I (INCdir)/ (ARCH) (LAinc) (MPinc)145HPLLIBS= (HPLlib) (LAlib) (MPlib)
146 #
147 # - Compile time options ———————————————–
148 #
149 # -DHPL_COPY_L force the copy of the panel L before bcast;
150 # -DHPL_CALL_CBLAS call the cblas interface;
151 # -DHPL_CALL_VSIPL call the vsip library;
152 # -DHPL_DETAILED_TIMING enable detailed timers;
153 #
154 # By default HPL will:
155 # *) not copy L before broadcast,
156 # *) call the BLAS Fortran 77 interface,
157 # *) not display detailed timing information.
158 #
159 HPL_OPTS = -DHPL_CALL_CBLAS
160 #
161 # ———————————————————————-
162 #
163 HPL_DEFS = (F2CDEFS) (HPL_OPTS) (HPL_INCLUDES)  
   164  #  
   165  # ———————————————————————-  
   166  # - Compilers / linkers - Optimization flags —————————  
   167  # ———————————————————————-  
   168  #  
   169  CC           = /home/zgz/openmpi/bin/mpicc  
   170  CCNOOPT      =
(HPL_DEFS)
171 CCFLAGS = (HPL_DEFS) -fomit-frame-pointer -O3 -funroll-loops  
   172  #  
   173  # On some platforms,  it is necessary  to use the Fortran linker to find  
   174  # the Fortran internals used in the BLAS library.  
   175  #  
   176  LINKER       = /home/zgz/openmpi/bin/mpif77  
   177  LINKFLAGS    =
(CCFLAGS)
178 #
179 ARCHIVER = ar
180 ARFLAGS = r
181 RANLIB = echo
182 #
183 # ———————————————————————-
然后Linpack的编译和安装_第3张图片在/bin文件夹下,实际为:/home/zgz/sourcecode/linpack/hpl/bin下这里写图片描述
test下有这里写图片描述
然后运行xhpl ,命令为: mpirun –np 4 xhpl 即可。
注意openmpi中的这里写图片描述
在mpich中为libmpich.a, 编辑Make.test文件的时候注意。
最后make clean 时 要执行 make clean arch=test,详见Makefile
Linpack的编译和安装_第4张图片

你可能感兴趣的:(Linpack的编译和安装)