You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 20 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <!doctype html>
  2. <html lang="en" class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <link rel="canonical" href="https://openblas.net/docs/build_system/">
  7. <link rel="prev" href="../developers/">
  8. <link rel="next" href="../distributing/">
  9. <link rel="icon" href="../logo.svg">
  10. <meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.22">
  11. <title>Build system - OpenBLAS</title>
  12. <link rel="stylesheet" href="../assets/stylesheets/main.732c4fb1.min.css">
  13. <link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.min.css">
  14. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  15. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
  16. <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
  17. <script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
  18. </head>
  19. <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="grey" data-md-color-accent="indigo">
  20. <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
  21. <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
  22. <label class="md-overlay" for="__drawer"></label>
  23. <div data-md-component="skip">
  24. <a href="#makefile-dep-graph" class="md-skip">
  25. Skip to content
  26. </a>
  27. </div>
  28. <div data-md-component="announce">
  29. </div>
  30. <header class="md-header md-header--shadow" data-md-component="header">
  31. <nav class="md-header__inner md-grid" aria-label="Header">
  32. <a href=".." title="OpenBLAS" class="md-header__button md-logo" aria-label="OpenBLAS" data-md-component="logo">
  33. <img src="../logo.svg" alt="logo">
  34. </a>
  35. <label class="md-header__button md-icon" for="__drawer">
  36. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
  37. </label>
  38. <div class="md-header__title" data-md-component="header-title">
  39. <div class="md-header__ellipsis">
  40. <div class="md-header__topic">
  41. <span class="md-ellipsis">
  42. OpenBLAS
  43. </span>
  44. </div>
  45. <div class="md-header__topic" data-md-component="header-topic">
  46. <span class="md-ellipsis">
  47. Build system
  48. </span>
  49. </div>
  50. </div>
  51. </div>
  52. <label class="md-header__button md-icon" for="__search">
  53. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
  54. </label>
  55. <div class="md-search" data-md-component="search" role="dialog">
  56. <label class="md-search__overlay" for="__search"></label>
  57. <div class="md-search__inner" role="search">
  58. <form class="md-search__form" name="search">
  59. <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
  60. <label class="md-search__icon md-icon" for="__search">
  61. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
  62. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
  63. </label>
  64. <nav class="md-search__options" aria-label="Search">
  65. <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
  66. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
  67. </button>
  68. </nav>
  69. </form>
  70. <div class="md-search__output">
  71. <div class="md-search__scrollwrap" data-md-scrollfix>
  72. <div class="md-search-result" data-md-component="search-result">
  73. <div class="md-search-result__meta">
  74. Initializing search
  75. </div>
  76. <ol class="md-search-result__list" role="presentation"></ol>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </nav>
  83. </header>
  84. <div class="md-container" data-md-component="container">
  85. <main class="md-main" data-md-component="main">
  86. <div class="md-main__inner md-grid">
  87. <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
  88. <div class="md-sidebar__scrollwrap">
  89. <div class="md-sidebar__inner">
  90. <nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
  91. <label class="md-nav__title" for="__drawer">
  92. <a href=".." title="OpenBLAS" class="md-nav__button md-logo" aria-label="OpenBLAS" data-md-component="logo">
  93. <img src="../logo.svg" alt="logo">
  94. </a>
  95. OpenBLAS
  96. </label>
  97. <ul class="md-nav__list" data-md-scrollfix>
  98. <li class="md-nav__item">
  99. <a href=".." class="md-nav__link">
  100. <span class="md-ellipsis">
  101. Home
  102. </span>
  103. </a>
  104. </li>
  105. <li class="md-nav__item">
  106. <a href="../install/" class="md-nav__link">
  107. <span class="md-ellipsis">
  108. Install OpenBLAS
  109. </span>
  110. </a>
  111. </li>
  112. <li class="md-nav__item">
  113. <a href="../user_manual/" class="md-nav__link">
  114. <span class="md-ellipsis">
  115. User manual
  116. </span>
  117. </a>
  118. </li>
  119. <li class="md-nav__item">
  120. <a href="../extensions/" class="md-nav__link">
  121. <span class="md-ellipsis">
  122. Extensions
  123. </span>
  124. </a>
  125. </li>
  126. <li class="md-nav__item">
  127. <a href="../developers/" class="md-nav__link">
  128. <span class="md-ellipsis">
  129. Developer manual
  130. </span>
  131. </a>
  132. </li>
  133. <li class="md-nav__item md-nav__item--active">
  134. <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
  135. <label class="md-nav__link md-nav__link--active" for="__toc">
  136. <span class="md-ellipsis">
  137. Build system
  138. </span>
  139. <span class="md-nav__icon md-icon"></span>
  140. </label>
  141. <a href="./" class="md-nav__link md-nav__link--active">
  142. <span class="md-ellipsis">
  143. Build system
  144. </span>
  145. </a>
  146. <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  147. <label class="md-nav__title" for="__toc">
  148. <span class="md-nav__icon md-icon"></span>
  149. Table of contents
  150. </label>
  151. <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
  152. <li class="md-nav__item">
  153. <a href="#makefile-dep-graph" class="md-nav__link">
  154. <span class="md-ellipsis">
  155. Makefile dep graph
  156. </span>
  157. </a>
  158. </li>
  159. <li class="md-nav__item">
  160. <a href="#important-variables" class="md-nav__link">
  161. <span class="md-ellipsis">
  162. Important Variables
  163. </span>
  164. </a>
  165. <nav class="md-nav" aria-label="Important Variables">
  166. <ul class="md-nav__list">
  167. <li class="md-nav__item">
  168. <a href="#cpu-related" class="md-nav__link">
  169. <span class="md-ellipsis">
  170. CPU related
  171. </span>
  172. </a>
  173. </li>
  174. <li class="md-nav__item">
  175. <a href="#toolchain-related" class="md-nav__link">
  176. <span class="md-ellipsis">
  177. Toolchain related
  178. </span>
  179. </a>
  180. </li>
  181. <li class="md-nav__item">
  182. <a href="#library-related" class="md-nav__link">
  183. <span class="md-ellipsis">
  184. Library related
  185. </span>
  186. </a>
  187. </li>
  188. </ul>
  189. </nav>
  190. </li>
  191. </ul>
  192. </nav>
  193. </li>
  194. <li class="md-nav__item">
  195. <a href="../distributing/" class="md-nav__link">
  196. <span class="md-ellipsis">
  197. Redistributing OpenBLAS
  198. </span>
  199. </a>
  200. </li>
  201. <li class="md-nav__item">
  202. <a href="../ci/" class="md-nav__link">
  203. <span class="md-ellipsis">
  204. CI jobs
  205. </span>
  206. </a>
  207. </li>
  208. <li class="md-nav__item">
  209. <a href="../about/" class="md-nav__link">
  210. <span class="md-ellipsis">
  211. About
  212. </span>
  213. </a>
  214. </li>
  215. <li class="md-nav__item">
  216. <a href="../faq/" class="md-nav__link">
  217. <span class="md-ellipsis">
  218. FAQ
  219. </span>
  220. </a>
  221. </li>
  222. </ul>
  223. </nav>
  224. </div>
  225. </div>
  226. </div>
  227. <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
  228. <div class="md-sidebar__scrollwrap">
  229. <div class="md-sidebar__inner">
  230. <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  231. <label class="md-nav__title" for="__toc">
  232. <span class="md-nav__icon md-icon"></span>
  233. Table of contents
  234. </label>
  235. <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
  236. <li class="md-nav__item">
  237. <a href="#makefile-dep-graph" class="md-nav__link">
  238. <span class="md-ellipsis">
  239. Makefile dep graph
  240. </span>
  241. </a>
  242. </li>
  243. <li class="md-nav__item">
  244. <a href="#important-variables" class="md-nav__link">
  245. <span class="md-ellipsis">
  246. Important Variables
  247. </span>
  248. </a>
  249. <nav class="md-nav" aria-label="Important Variables">
  250. <ul class="md-nav__list">
  251. <li class="md-nav__item">
  252. <a href="#cpu-related" class="md-nav__link">
  253. <span class="md-ellipsis">
  254. CPU related
  255. </span>
  256. </a>
  257. </li>
  258. <li class="md-nav__item">
  259. <a href="#toolchain-related" class="md-nav__link">
  260. <span class="md-ellipsis">
  261. Toolchain related
  262. </span>
  263. </a>
  264. </li>
  265. <li class="md-nav__item">
  266. <a href="#library-related" class="md-nav__link">
  267. <span class="md-ellipsis">
  268. Library related
  269. </span>
  270. </a>
  271. </li>
  272. </ul>
  273. </nav>
  274. </li>
  275. </ul>
  276. </nav>
  277. </div>
  278. </div>
  279. </div>
  280. <div class="md-content" data-md-component="content">
  281. <article class="md-content__inner md-typeset">
  282. <h1>Build system</h1>
  283. <div class="admonition warning">
  284. <p class="admonition-title">Warning</p>
  285. <p>This page is made by someone who is not the developer and should not be considered as an official documentation of the build system. For getting the full picture, it is best to read the Makefiles and understand them yourself.</p>
  286. </div>
  287. <h2 id="makefile-dep-graph">Makefile dep graph</h2>
  288. <div class="highlight"><pre><span></span><code>Makefile
  289. |
  290. |----- Makefile.system # !!! this is included by many of the Makefiles in the subdirectories !!!
  291. | |
  292. | |===== Makefile.prebuild # This is triggered (not included) once by Makefile.system
  293. | | | # and runs before any of the actual library code is built.
  294. | | | # (builds and runs the &quot;getarch&quot; tool for cpu identification,
  295. | | | # runs the compiler detection scripts c_check and f_check)
  296. | | |
  297. | | ----- (Makefile.conf) [ either this or Makefile_kernel.conf is generated ]
  298. | | | { Makefile.system#L243 }
  299. | | ----- (Makefile_kernel.conf) [ temporary Makefile.conf during DYNAMIC_ARCH builds ]
  300. | |
  301. | |----- Makefile.rule # defaults for build options that can be given on the make command line
  302. | |
  303. | |----- Makefile.$(ARCH) # architecture-specific compiler options and OpenBLAS buffer size values
  304. |
  305. |~~~~~ exports/
  306. |
  307. |~~~~~ test/
  308. |
  309. |~~~~~ utest/
  310. |
  311. |~~~~~ ctest/
  312. |
  313. |~~~~~ cpp_thread_test/
  314. |
  315. |~~~~~ kernel/
  316. |
  317. |~~~~~ ${SUBDIRS}
  318. |
  319. |~~~~~ ${BLASDIRS}
  320. |
  321. |~~~~~ ${NETLIB_LAPACK_DIR}{,/timing,/testing/{EIG,LIN}}
  322. |
  323. |~~~~~ relapack/
  324. </code></pre></div>
  325. <h2 id="important-variables">Important Variables</h2>
  326. <p>Most of the tunable variables are found in <a href="https://github.com/xianyi/OpenBLAS/blob/develop/Makefile.rule">Makefile.rule</a>, along with their detailed descriptions.<br/>
  327. Most of the variables are detected automatically in <a href="https://github.com/xianyi/OpenBLAS/blob/develop/Makefile.prebuild">Makefile.prebuild</a>, if they are not set in the environment.</p>
  328. <h3 id="cpu-related">CPU related</h3>
  329. <div class="highlight"><pre><span></span><code>ARCH - Target architecture (eg. x86_64)
  330. TARGET - Target CPU architecture, in case of DYNAMIC_ARCH=1 means library will not be usable on less capable CPUs
  331. TARGET_CORE - TARGET_CORE will override TARGET internally during each cpu-specific cycle of the build for DYNAMIC_ARCH
  332. DYNAMIC_ARCH - For building library for multiple TARGETs (does not lose any optimizations, but increases library size)
  333. DYNAMIC_LIST - optional user-provided subset of the DYNAMIC_CORE list in Makefile.system
  334. </code></pre></div>
  335. <h3 id="toolchain-related">Toolchain related</h3>
  336. <div class="highlight"><pre><span></span><code>CC - TARGET C compiler used for compilation (can be cross-toolchains)
  337. FC - TARGET Fortran compiler used for compilation (can be cross-toolchains, set NOFORTRAN=1 if used cross-toolchain has no fortran compiler)
  338. AR, AS, LD, RANLIB - TARGET toolchain helpers used for compilation (can be cross-toolchains)
  339. HOSTCC - compiler of build machine, needed to create proper config files for target architecture
  340. HOST_CFLAGS - flags for build machine compiler
  341. </code></pre></div>
  342. <h3 id="library-related">Library related</h3>
  343. <div class="highlight"><pre><span></span><code>BINARY - 32/64 bit library
  344. BUILD_SHARED - Create shared library
  345. BUILD_STATIC - Create static library
  346. QUAD_PRECISION - enable support for IEEE quad precision [ largely unimplemented leftover from GotoBLAS, do not use ]
  347. EXPRECISION - Obsolete option to use float80 of SSE on BSD-like systems
  348. INTERFACE64 - Build with 64bit integer representations to support large array index values [ incompatible with standard API ]
  349. BUILD_SINGLE - build the single-precision real functions of BLAS [and optionally LAPACK]
  350. BUILD_DOUBLE - build the double-precision real functions
  351. BUILD_COMPLEX - build the single-precision complex functions
  352. BUILD_COMPLEX16 - build the double-precision complex functions
  353. (all four types are included in the build by default when none was specifically selected)
  354. BUILD_BFLOAT16 - build the &quot;half precision brainfloat&quot; real functions
  355. USE_THREAD - Use a multithreading backend (default to pthread)
  356. USE_LOCKING - implement locking for thread safety even when USE_THREAD is not set (so that the singlethreaded library can
  357. safely be called from multithreaded programs)
  358. USE_OPENMP - Use OpenMP as multithreading backend
  359. NUM_THREADS - define this to the maximum number of parallel threads you expect to need (defaults to the number of cores in the build cpu)
  360. NUM_PARALLEL - define this to the number of OpenMP instances that your code may use for parallel calls into OpenBLAS (default 1,see below)
  361. </code></pre></div>
  362. <p>OpenBLAS uses a fixed set of memory buffers internally, used for communicating and compiling partial results from individual threads.
  363. For efficiency, the management array structure for these buffers is sized at build time - this makes it necessary to know in advance how
  364. many threads need to be supported on the target system(s).
  365. With OpenMP, there is an additional level of complexity as there may be calls originating from a parallel region in the calling program. If OpenBLAS gets called from a single parallel region, it runs single-threaded automatically to avoid overloading the system by fanning out its own set of threads.
  366. In the case that an OpenMP program makes multiple calls from independent regions or instances in parallel, this default serialization is not
  367. sufficient as the additional caller(s) would compete for the original set of buffers already in use by the first call.
  368. So if multiple OpenMP runtimes call into OpenBLAS at the same time, then only one of them will be able to make progress while all the rest of them spin-wait for the one available buffer. Setting NUM_PARALLEL to the upper bound on the number of OpenMP runtimes that you can have in a process ensures that there are a sufficient number of buffer sets available</p>
  369. </article>
  370. </div>
  371. <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
  372. </div>
  373. </main>
  374. <footer class="md-footer">
  375. <div class="md-footer-meta md-typeset">
  376. <div class="md-footer-meta__inner md-grid">
  377. <div class="md-copyright">
  378. Made with
  379. <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
  380. Material for MkDocs
  381. </a>
  382. </div>
  383. </div>
  384. </div>
  385. </footer>
  386. </div>
  387. <div class="md-dialog" data-md-component="dialog">
  388. <div class="md-dialog__inner md-typeset"></div>
  389. </div>
  390. <script id="__config" type="application/json">{"base": "..", "features": [], "search": "../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
  391. <script src="../assets/javascripts/bundle.5cfa9459.min.js"></script>
  392. </body>
  393. </html>

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.