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 33 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  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/distributing/">
  7. <link rel="prev" href="../build_system/">
  8. <link rel="next" href="../ci/">
  9. <link rel="icon" href="../logo.svg">
  10. <meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.22">
  11. <title>Redistributing OpenBLAS - 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="#redistributing-openblas" 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. Redistributing OpenBLAS
  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">
  134. <a href="../build_system/" class="md-nav__link">
  135. <span class="md-ellipsis">
  136. Build system
  137. </span>
  138. </a>
  139. </li>
  140. <li class="md-nav__item md-nav__item--active">
  141. <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
  142. <label class="md-nav__link md-nav__link--active" for="__toc">
  143. <span class="md-ellipsis">
  144. Redistributing OpenBLAS
  145. </span>
  146. <span class="md-nav__icon md-icon"></span>
  147. </label>
  148. <a href="./" class="md-nav__link md-nav__link--active">
  149. <span class="md-ellipsis">
  150. Redistributing OpenBLAS
  151. </span>
  152. </a>
  153. <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  154. <label class="md-nav__title" for="__toc">
  155. <span class="md-nav__icon md-icon"></span>
  156. Table of contents
  157. </label>
  158. <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
  159. <li class="md-nav__item">
  160. <a href="#ilp64-interface-builds" class="md-nav__link">
  161. <span class="md-ellipsis">
  162. ILP64 interface builds
  163. </span>
  164. </a>
  165. <nav class="md-nav" aria-label="ILP64 interface builds">
  166. <ul class="md-nav__list">
  167. <li class="md-nav__item">
  168. <a href="#the-current-openblas-agreed-upon-ilp64-convention" class="md-nav__link">
  169. <span class="md-ellipsis">
  170. The current OpenBLAS agreed-upon ILP64 convention
  171. </span>
  172. </a>
  173. </li>
  174. <li class="md-nav__item">
  175. <a href="#the-upcoming-standardized-ilp64-convention" class="md-nav__link">
  176. <span class="md-ellipsis">
  177. The upcoming standardized ILP64 convention
  178. </span>
  179. </a>
  180. </li>
  181. </ul>
  182. </nav>
  183. </li>
  184. <li class="md-nav__item">
  185. <a href="#performance-and-runtime-behavior-related-build-options" class="md-nav__link">
  186. <span class="md-ellipsis">
  187. Performance and runtime behavior related build options
  188. </span>
  189. </a>
  190. <nav class="md-nav" aria-label="Performance and runtime behavior related build options">
  191. <ul class="md-nav__list">
  192. <li class="md-nav__item">
  193. <a href="#threading-related-options" class="md-nav__link">
  194. <span class="md-ellipsis">
  195. Threading related options
  196. </span>
  197. </a>
  198. </li>
  199. <li class="md-nav__item">
  200. <a href="#cpu-architecture-related-options" class="md-nav__link">
  201. <span class="md-ellipsis">
  202. CPU architecture related options
  203. </span>
  204. </a>
  205. </li>
  206. </ul>
  207. </nav>
  208. </li>
  209. <li class="md-nav__item">
  210. <a href="#real-world-examples" class="md-nav__link">
  211. <span class="md-ellipsis">
  212. Real-world examples
  213. </span>
  214. </a>
  215. </li>
  216. </ul>
  217. </nav>
  218. </li>
  219. <li class="md-nav__item">
  220. <a href="../ci/" class="md-nav__link">
  221. <span class="md-ellipsis">
  222. CI jobs
  223. </span>
  224. </a>
  225. </li>
  226. <li class="md-nav__item">
  227. <a href="../about/" class="md-nav__link">
  228. <span class="md-ellipsis">
  229. About
  230. </span>
  231. </a>
  232. </li>
  233. <li class="md-nav__item">
  234. <a href="../faq/" class="md-nav__link">
  235. <span class="md-ellipsis">
  236. FAQ
  237. </span>
  238. </a>
  239. </li>
  240. </ul>
  241. </nav>
  242. </div>
  243. </div>
  244. </div>
  245. <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
  246. <div class="md-sidebar__scrollwrap">
  247. <div class="md-sidebar__inner">
  248. <nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  249. <label class="md-nav__title" for="__toc">
  250. <span class="md-nav__icon md-icon"></span>
  251. Table of contents
  252. </label>
  253. <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
  254. <li class="md-nav__item">
  255. <a href="#ilp64-interface-builds" class="md-nav__link">
  256. <span class="md-ellipsis">
  257. ILP64 interface builds
  258. </span>
  259. </a>
  260. <nav class="md-nav" aria-label="ILP64 interface builds">
  261. <ul class="md-nav__list">
  262. <li class="md-nav__item">
  263. <a href="#the-current-openblas-agreed-upon-ilp64-convention" class="md-nav__link">
  264. <span class="md-ellipsis">
  265. The current OpenBLAS agreed-upon ILP64 convention
  266. </span>
  267. </a>
  268. </li>
  269. <li class="md-nav__item">
  270. <a href="#the-upcoming-standardized-ilp64-convention" class="md-nav__link">
  271. <span class="md-ellipsis">
  272. The upcoming standardized ILP64 convention
  273. </span>
  274. </a>
  275. </li>
  276. </ul>
  277. </nav>
  278. </li>
  279. <li class="md-nav__item">
  280. <a href="#performance-and-runtime-behavior-related-build-options" class="md-nav__link">
  281. <span class="md-ellipsis">
  282. Performance and runtime behavior related build options
  283. </span>
  284. </a>
  285. <nav class="md-nav" aria-label="Performance and runtime behavior related build options">
  286. <ul class="md-nav__list">
  287. <li class="md-nav__item">
  288. <a href="#threading-related-options" class="md-nav__link">
  289. <span class="md-ellipsis">
  290. Threading related options
  291. </span>
  292. </a>
  293. </li>
  294. <li class="md-nav__item">
  295. <a href="#cpu-architecture-related-options" class="md-nav__link">
  296. <span class="md-ellipsis">
  297. CPU architecture related options
  298. </span>
  299. </a>
  300. </li>
  301. </ul>
  302. </nav>
  303. </li>
  304. <li class="md-nav__item">
  305. <a href="#real-world-examples" class="md-nav__link">
  306. <span class="md-ellipsis">
  307. Real-world examples
  308. </span>
  309. </a>
  310. </li>
  311. </ul>
  312. </nav>
  313. </div>
  314. </div>
  315. </div>
  316. <div class="md-content" data-md-component="content">
  317. <article class="md-content__inner md-typeset">
  318. <h1 id="redistributing-openblas">Redistributing OpenBLAS</h1>
  319. <div class="admonition note">
  320. <p class="admonition-title">Note</p>
  321. <p>This document contains recommendations only - packagers and other
  322. redistributors are in charge of how OpenBLAS is built and distributed in their
  323. systems, and may have good reasons to deviate from the guidance given on this
  324. page. These recommendations are aimed at general packaging systems, with a user
  325. base that typically is large, open source (or freely available at least), and
  326. doesn't behave uniformly or that the packager is directly connected with.*</p>
  327. </div>
  328. <p>OpenBLAS has a large number of build-time options which can be used to change
  329. how it behaves at runtime, how artifacts or symbols are named, etc. Variation
  330. in build configuration can be necessary to acheive a given end goal within a
  331. distribution or as an end user. However, such variation can also make it more
  332. difficult to build on top of OpenBLAS and ship code or other packages in a way
  333. that works across many different distros. Here we provide guidance about the
  334. most important build options, what effects they may have when changed, and
  335. which ones to default to.</p>
  336. <p>The Make and CMake build systems provide equivalent options and yield more or
  337. less the same artifacts, but not exactly (the CMake builds are still
  338. experimental). You can choose either one and the options will function in the
  339. same way, however the CMake outputs may require some renaming. To review
  340. available build options, see <code>Makefile.rule</code> or <code>CMakeLists.txt</code> in the root of
  341. the repository.</p>
  342. <p>Build options typically fall into two categories: (a) options that affect the
  343. user interface, such as library and symbol names or APIs that are made
  344. available, and (b) options that affect performance and runtime behavior, such
  345. as threading behavior or CPU architecture-specific code paths. The user
  346. interface options are more important to keep aligned between distributions,
  347. while for the performance-related options there are typically more reasons to
  348. make choices that deviate from the defaults.</p>
  349. <p>Here are recommendations for user interface related packaging choices where it
  350. is not likely to be a good idea to deviate (typically these are the default
  351. settings):</p>
  352. <ol>
  353. <li>Include CBLAS. The CBLAS interface is widely used and it doesn't affect
  354. binary size much, so don't turn it off.</li>
  355. <li>Include LAPACK and LAPACKE. The LAPACK interface is also widely used, and
  356. while it does make up a significant part of the binary size of the installed
  357. library, that does not outweigh the regression in usability when deviating
  358. from the default here.[^1]</li>
  359. <li>Always distribute the pkg-config (<code>.pc</code>) and CMake <code>.cmake</code>) dependency
  360. detection files. These files are used by build systems when users want to
  361. link against OpenBLAS, and there is no benefit of leaving them out.</li>
  362. <li>Provide the LP64 interface by default, and if in addition to that you choose
  363. to provide an ILP64 interface build as well, use a symbol suffix to avoid
  364. symbol name clashes (see the next section).</li>
  365. </ol>
  366. <p>[^1] All major distributions do include LAPACK as of mid 2023 as far as we
  367. know. Older versions of Arch Linux did not, and that was known to cause
  368. problems.</p>
  369. <h2 id="ilp64-interface-builds">ILP64 interface builds</h2>
  370. <p>The LP64 (32-bit integer) interface is the default build, and has
  371. well-established C and Fortran APIs as determined by the reference (Netlib)
  372. BLAS and LAPACK libraries. The ILP64 (64-bit integer) interface however does
  373. not have a standard API: symbol names and shared/static library names can be
  374. produced in multiple ways, and this tends to make it difficult to use.
  375. As of today there is an agreed-upon way of choosing names for OpenBLAS between
  376. a number of key users/redistributors, which is the closest thing to a standard
  377. that there is now. However, there is an ongoing standardization effort in the
  378. reference BLAS and LAPACK libraries, which differs from the current OpenBLAS
  379. agreed-upon convention. In this section we'll aim to explain both.</p>
  380. <p>Those two methods are fairly similar, and have a key thing in common: <em>using a
  381. symbol suffix</em>. This is good practice; it is recommended that if you distribute
  382. an ILP64 build, to have it use a symbol suffix containing <code>64</code> in the name.
  383. This avoids potential symbol clashes when different packages which depend on
  384. OpenBLAS load both an LP64 and an ILP64 library into memory at the same time.</p>
  385. <h3 id="the-current-openblas-agreed-upon-ilp64-convention">The current OpenBLAS agreed-upon ILP64 convention</h3>
  386. <p>This convention comprises the shared library name and the symbol suffix in the
  387. shared library. The symbol suffix to use is <code>64_</code>, implying that the library
  388. name will be <code>libopenblas64_.so</code> and the symbols in that library end in <code>64_</code>.
  389. The central issue where this was discussed is
  390. <a href="https://github.com/xianyi/OpenBLAS/issues/646">openblas#646</a>, and adopters
  391. include Fedora, Julia, NumPy and SciPy - SuiteSparse already used it as well.</p>
  392. <p>To build shared and static libraries with the currently recommended ILP64
  393. conventions with Make:
  394. <div class="highlight"><pre><span></span><code>$<span class="w"> </span>make<span class="w"> </span><span class="nv">INTERFACE64</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">SYMBOLSUFFIX</span><span class="o">=</span>64_
  395. </code></pre></div></p>
  396. <p>This will produce libraries named <code>libopenblas64_.so|a</code>, a pkg-config file
  397. named <code>openblas64.pc</code>, and CMake and header files.</p>
  398. <p>Installing locally and inspecting the output will show a few more details:
  399. <div class="highlight"><pre><span></span><code>$<span class="w"> </span>make<span class="w"> </span>install<span class="w"> </span><span class="nv">PREFIX</span><span class="o">=</span><span class="nv">$PWD</span>/../openblas/make64<span class="w"> </span><span class="nv">INTERFACE64</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">SYMBOLSUFFIX</span><span class="o">=</span>64_
  400. $<span class="w"> </span>tree<span class="w"> </span>.<span class="w"> </span><span class="c1"># output slightly edited down</span>
  401. .
  402. ├──<span class="w"> </span>include
  403. │<span class="w">   </span>├──<span class="w"> </span>cblas.h
  404. │<span class="w">   </span>├──<span class="w"> </span>f77blas.h
  405. │<span class="w">   </span>├──<span class="w"> </span>lapacke_config.h
  406. │<span class="w">   </span>├──<span class="w"> </span>lapacke.h
  407. │<span class="w">   </span>├──<span class="w"> </span>lapacke_mangling.h
  408. │<span class="w">   </span>├──<span class="w"> </span>lapacke_utils.h
  409. │<span class="w">   </span>├──<span class="w"> </span>lapack.h
  410. │<span class="w">   </span>└──<span class="w"> </span>openblas_config.h
  411. └──<span class="w"> </span>lib
  412. <span class="w"> </span>├──<span class="w"> </span>cmake
  413. <span class="w"> </span>│<span class="w">   </span>└──<span class="w"> </span>openblas
  414. <span class="w"> </span>│<span class="w">   </span>├──<span class="w"> </span>OpenBLASConfig.cmake
  415. <span class="w"> </span>│<span class="w">   </span>└──<span class="w"> </span>OpenBLASConfigVersion.cmake
  416. <span class="w"> </span>├──<span class="w"> </span>libopenblas64_.a
  417. <span class="w"> </span>├──<span class="w"> </span>libopenblas64_.so
  418. <span class="w"> </span>└──<span class="w"> </span>pkgconfig
  419. <span class="w"> </span>└──<span class="w"> </span>openblas64.pc
  420. </code></pre></div></p>
  421. <p>A key point are the symbol names. These will equal the LP64 symbol names, then
  422. (for Fortran only) the compiler mangling, and then the <code>64_</code> symbol suffix.
  423. Hence to obtain the final symbol names, we need to take into account which
  424. Fortran compiler we are using. For the most common cases (e.g., gfortran, Intel
  425. Fortran, or Flang), that means appending a single underscore. In that case, the
  426. result is:</p>
  427. <table>
  428. <thead>
  429. <tr>
  430. <th>base API name</th>
  431. <th>binary symbol name</th>
  432. <th>call from Fortran code</th>
  433. <th>call from C code</th>
  434. </tr>
  435. </thead>
  436. <tbody>
  437. <tr>
  438. <td><code>dgemm</code></td>
  439. <td><code>dgemm_64_</code></td>
  440. <td><code>dgemm_64(...)</code></td>
  441. <td><code>dgemm_64_(...)</code></td>
  442. </tr>
  443. <tr>
  444. <td><code>cblas_dgemm</code></td>
  445. <td><code>cblas_dgemm64_</code></td>
  446. <td>n/a</td>
  447. <td><code>cblas_dgemm64_(...)</code></td>
  448. </tr>
  449. </tbody>
  450. </table>
  451. <p>It is quite useful to have these symbol names be as uniform as possible across
  452. different packaging systems.</p>
  453. <p>The equivalent build options with CMake are:
  454. <div class="highlight"><pre><span></span><code>$<span class="w"> </span>mkdir<span class="w"> </span>build<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="nb">cd</span><span class="w"> </span>build
  455. $<span class="w"> </span>cmake<span class="w"> </span>..<span class="w"> </span>-DINTERFACE64<span class="o">=</span><span class="m">1</span><span class="w"> </span>-DSYMBOLSUFFIX<span class="o">=</span>64_<span class="w"> </span>-DBUILD_SHARED_LIBS<span class="o">=</span>ON<span class="w"> </span>-DBUILD_STATIC_LIBS<span class="o">=</span>ON
  456. $<span class="w"> </span>cmake<span class="w"> </span>--build<span class="w"> </span>.<span class="w"> </span>-j
  457. </code></pre></div></p>
  458. <p>Note that the result is not 100% identical to the Make result. For example, the
  459. library name ends in <code>_64</code> rather than <code>64_</code> - it is recommended to rename them
  460. to match the Make library names (also update the <code>libsuffix</code> entry in
  461. <code>openblas64.pc</code> to match that rename).
  462. <div class="highlight"><pre><span></span><code>$<span class="w"> </span>cmake<span class="w"> </span>--install<span class="w"> </span>.<span class="w"> </span>--prefix<span class="w"> </span><span class="nv">$PWD</span>/../../openblas/cmake64
  463. $<span class="w"> </span>tree<span class="w"> </span>.
  464. .
  465. ├──<span class="w"> </span>include
  466. │<span class="w">   </span>└──<span class="w"> </span>openblas64
  467. │<span class="w">   </span>├──<span class="w"> </span>cblas.h
  468. │<span class="w">   </span>├──<span class="w"> </span>f77blas.h
  469. │<span class="w">   </span>├──<span class="w"> </span>lapacke_config.h
  470. │<span class="w">   </span>├──<span class="w"> </span>lapacke_example_aux.h
  471. │<span class="w">   </span>├──<span class="w"> </span>lapacke.h
  472. │<span class="w">   </span>├──<span class="w"> </span>lapacke_mangling.h
  473. │<span class="w">   </span>├──<span class="w"> </span>lapacke_utils.h
  474. │<span class="w">   </span>├──<span class="w"> </span>lapack.h
  475. │<span class="w">   </span>├──<span class="w"> </span>openblas64
  476. │<span class="w">   </span>│<span class="w">   </span>└──<span class="w"> </span>lapacke_mangling.h
  477. │<span class="w">   </span>└──<span class="w"> </span>openblas_config.h
  478. └──<span class="w"> </span>lib
  479. <span class="w"> </span>├──<span class="w"> </span>cmake
  480. <span class="w"> </span>│<span class="w">   </span>└──<span class="w"> </span>OpenBLAS64
  481. <span class="w"> </span>│<span class="w">   </span>├──<span class="w"> </span>OpenBLAS64Config.cmake
  482. <span class="w"> </span>│<span class="w">   </span>├──<span class="w"> </span>OpenBLAS64ConfigVersion.cmake
  483. <span class="w"> </span>│<span class="w">   </span>├──<span class="w"> </span>OpenBLAS64Targets.cmake
  484. <span class="w"> </span>│<span class="w">   </span>└──<span class="w"> </span>OpenBLAS64Targets-noconfig.cmake
  485. <span class="w"> </span>├──<span class="w"> </span>libopenblas_64.a
  486. <span class="w"> </span>├──<span class="w"> </span>libopenblas_64.so<span class="w"> </span>-&gt;<span class="w"> </span>libopenblas_64.so.0
  487. <span class="w"> </span>└──<span class="w"> </span>pkgconfig
  488. <span class="w"> </span>└──<span class="w"> </span>openblas64.pc
  489. </code></pre></div></p>
  490. <h3 id="the-upcoming-standardized-ilp64-convention">The upcoming standardized ILP64 convention</h3>
  491. <p>While the <code>64_</code> convention above got some adoption, it's slightly hacky and is
  492. implemented through the use of <code>objcopy</code>. An effort is ongoing for a more
  493. broadly adopted convention in the reference BLAS and LAPACK libraries, using
  494. (a) the <code>_64</code> suffix, and (b) applying that suffix <em>before</em> rather than after
  495. Fortran compiler mangling. The central issue for this is
  496. <a href="https://github.com/Reference-LAPACK/lapack/issues/666">lapack#666</a>.</p>
  497. <p>For the most common cases of compiler mangling (a single <code>_</code> appended), the end
  498. result will be:</p>
  499. <table>
  500. <thead>
  501. <tr>
  502. <th>base API name</th>
  503. <th>binary symbol name</th>
  504. <th>call from Fortran code</th>
  505. <th>call from C code</th>
  506. </tr>
  507. </thead>
  508. <tbody>
  509. <tr>
  510. <td><code>dgemm</code></td>
  511. <td><code>dgemm_64_</code></td>
  512. <td><code>dgemm_64(...)</code></td>
  513. <td><code>dgemm_64_(...)</code></td>
  514. </tr>
  515. <tr>
  516. <td><code>cblas_dgemm</code></td>
  517. <td><code>cblas_dgemm_64</code></td>
  518. <td>n/a</td>
  519. <td><code>cblas_dgemm_64(...)</code></td>
  520. </tr>
  521. </tbody>
  522. </table>
  523. <p>For other compiler mangling schemes, replace the trailing <code>_</code> by the scheme in use.</p>
  524. <p>The shared library name for this <code>_64</code> convention should be <code>libopenblas_64.so</code>.</p>
  525. <p>Note: it is not yet possible to produce an OpenBLAS build which employs this
  526. convention! Once reference BLAS and LAPACK with support for <code>_64</code> have been
  527. released, a future OpenBLAS release will support it. For now, please use the
  528. older <code>64_</code> scheme and avoid using the name <code>libopenblas_64.so</code>; it should be
  529. considered reserved for future use of the <code>_64</code> standard as prescribed by
  530. reference BLAS/LAPACK.</p>
  531. <h2 id="performance-and-runtime-behavior-related-build-options">Performance and runtime behavior related build options</h2>
  532. <p>For these options there are multiple reasonable or common choices.</p>
  533. <h3 id="threading-related-options">Threading related options</h3>
  534. <p>OpenBLAS can be built as a multi-threaded or single-threaded library, with the
  535. default being multi-threaded. It's expected that the default <code>libopenblas</code>
  536. library is multi-threaded; if you'd like to also distribute single-threaded
  537. builds, consider naming them <code>libopenblas_sequential</code>.</p>
  538. <p>OpenBLAS can be built with pthreads or OpenMP as the threading model, with the
  539. default being pthreads. Both options are commonly used, and the choice here
  540. should not influence the shared library name. The choice will be captured by
  541. the <code>.pc</code> file. E.g.,:
  542. <div class="highlight"><pre><span></span><code>$<span class="w"> </span>pkg-config<span class="w"> </span>--libs<span class="w"> </span>openblas
  543. -fopenmp<span class="w"> </span>-lopenblas
  544. $<span class="w"> </span>cat<span class="w"> </span>openblas.pc
  545. ...
  546. <span class="nv">openblas_config</span><span class="o">=</span><span class="w"> </span>...<span class="w"> </span><span class="nv">USE_OPENMP</span><span class="o">=</span><span class="m">0</span><span class="w"> </span><span class="nv">MAX_THREADS</span><span class="o">=</span><span class="m">24</span>
  547. </code></pre></div></p>
  548. <p>The maximum number of threads users will be able to use is determined at build
  549. time by the <code>NUM_THREADS</code> build option. It defaults to 24, and there's a wide
  550. range of values that are reasonable to use (up to 256). 64 is a typical choice
  551. here; there is a memory footprint penalty that is linear in <code>NUM_THREADS</code>.
  552. Please see <code>Makefile.rule</code> for more details.</p>
  553. <h3 id="cpu-architecture-related-options">CPU architecture related options</h3>
  554. <p>OpenBLAS contains a lot of CPU architecture-specific optimizations, hence when
  555. distributing to a user base with a variety of hardware, it is recommended to
  556. enable CPU architecture runtime detection. This will dynamically select
  557. optimized kernels for individual APIs. To do this, use the <code>DYNAMIC_ARCH=1</code>
  558. build option. This is usually done on all common CPU families, except when
  559. there are known issues.</p>
  560. <p>In case the CPU architecture is known (e.g. you're building binaries for macOS
  561. M1 users), it is possible to specify the target architecture directly with the
  562. <code>TARGET=</code> build option.</p>
  563. <p><code>DYNAMIC_ARCH</code> and <code>TARGET</code> are covered in more detail in the main <code>README.md</code>
  564. in this repository.</p>
  565. <h2 id="real-world-examples">Real-world examples</h2>
  566. <p>OpenBLAS is likely to be distributed in one of these distribution models:</p>
  567. <ol>
  568. <li>As a standalone package, or multiple packages, in a packaging ecosystem like
  569. a Linux distro, Homebrew, conda-forge or MSYS2.</li>
  570. <li>Vendored as part of a larger package, e.g. in Julia, NumPy, SciPy, or R.</li>
  571. <li>Locally, e.g. making available as a build on a single HPC cluster.</li>
  572. </ol>
  573. <p>The guidance on this page is most important for models (1) and (2). These links
  574. to build recipes for a representative selection of packaging systems may be
  575. helpful as a reference:</p>
  576. <ul>
  577. <li><a href="https://src.fedoraproject.org/rpms/openblas/blob/rawhide/f/openblas.spec">Fedora</a></li>
  578. <li><a href="https://salsa.debian.org/science-team/openblas/-/blob/master/debian/rules">Debian</a></li>
  579. <li><a href="https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openblas.rb">Homebrew</a></li>
  580. <li><a href="https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-openblas/PKGBUILD">MSYS2</a></li>
  581. <li><a href="https://github.com/conda-forge/openblas-feedstock/blob/main/recipe/build.sh">conda-forge</a></li>
  582. <li><a href="https://github.com/MacPython/openblas-libs/blob/main/tools/build_openblas.sh">NumPy/SciPy</a></li>
  583. <li><a href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/science/math/openblas/default.nix">Nixpkgs</a></li>
  584. </ul>
  585. </article>
  586. </div>
  587. <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
  588. </div>
  589. </main>
  590. <footer class="md-footer">
  591. <div class="md-footer-meta md-typeset">
  592. <div class="md-footer-meta__inner md-grid">
  593. <div class="md-copyright">
  594. Made with
  595. <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
  596. Material for MkDocs
  597. </a>
  598. </div>
  599. </div>
  600. </div>
  601. </footer>
  602. </div>
  603. <div class="md-dialog" data-md-component="dialog">
  604. <div class="md-dialog__inner md-typeset"></div>
  605. </div>
  606. <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>
  607. <script src="../assets/javascripts/bundle.5cfa9459.min.js"></script>
  608. </body>
  609. </html>

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