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/下載最新版本。
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 #
如上操作后,問題解決。
(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 # ———————————————————————-
然后在/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的编译和安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 视频剪辑后期处理软件生态
- 下一篇: 微信公众号头像如何修改