@@ -3468,80 +3468,6 @@ You should pass the following command-line option to Valgrind to use it:
3468
3468
\endverbatim
3469
3469
3470
3470
3471
- \subsection faq_upgrade How do I handle ABI breaks and API upgrades?
3472
-
3473
- The hwloc interface is extended with every new major release.
3474
- Any application using the hwloc API should be prepared to check at
3475
- compile-time whether some features are available in the currently
3476
- installed hwloc distribution.
3477
-
3478
- For instance, to check whether the hwloc version is at least 2.0, you should use:
3479
- \verbatim
3480
- #include <hwloc.h>
3481
- #if HWLOC_API_VERSION >= 0x00020000
3482
- ...
3483
- #endif
3484
- \endverbatim
3485
-
3486
- To check for the API of release X.Y.Z at build time,
3487
- you may compare ::HWLOC_API_VERSION with <tt>(X<<16)+(Y<<8)+Z</tt>.
3488
-
3489
- For supporting older releases that do not have <tt>HWLOC_OBJ_NUMANODE</tt>
3490
- and <tt>HWLOC_OBJ_PACKAGE</tt> yet, you may use:
3491
-
3492
- \verbatim
3493
- #include <hwloc.h>
3494
- #if HWLOC_API_VERSION < 0x00010b00
3495
- #define HWLOC_OBJ_NUMANODE HWLOC_OBJ_NODE
3496
- #define HWLOC_OBJ_PACKAGE HWLOC_OBJ_SOCKET
3497
- #endif
3498
- \endverbatim
3499
-
3500
- The hwloc interface was deeply modified in release 2.0
3501
- to fix several issues of the 1.x interface
3502
- (see \ref upgrade_to_api_2x and the NEWS file in the source directory for details).
3503
- The ABI was broken, which means
3504
- <b>applications must be recompiled against the new 2.0 interface</b>.
3505
-
3506
- To check that you are not mixing old/recent headers with a recent/old runtime library,
3507
- check the major revision number in the API version:
3508
- \verbatim
3509
- #include <hwloc.h>
3510
- unsigned version = hwloc_get_api_version();
3511
- if ((version >> 16) != (HWLOC_API_VERSION >> 16)) {
3512
- fprintf(stderr,
3513
- "%s compiled for hwloc API 0x%x but running on library API 0x%x.\n"
3514
- "You may need to point LD_LIBRARY_PATH to the right hwloc library.\n"
3515
- "Aborting since the new ABI is not backward compatible.\n",
3516
- callname, HWLOC_API_VERSION, version);
3517
- exit(EXIT_FAILURE);
3518
- }
3519
- \endverbatim
3520
- To specifically detect v2.0 issues:
3521
- \verbatim
3522
- #include <hwloc.h>
3523
- #if HWLOC_API_VERSION >= 0x00020000
3524
- /* headers are recent */
3525
- if (hwloc_get_api_version() < 0x20000)
3526
- ... error out, the hwloc runtime library is older than 2.0 ...
3527
- #else
3528
- /* headers are pre-2.0 */
3529
- if (hwloc_get_api_version() >= 0x20000)
3530
- ... error out, the hwloc runtime library is more recent than 2.0 ...
3531
- #endif
3532
- \endverbatim
3533
-
3534
- You should not try to remain compatible with very old releases such as
3535
- 1.1.x or earlier because <tt>::HWLOC_API_VERSION</tt> was added in 1.0.0
3536
- and <tt>hwloc_get_api_version()</tt> came only in 1.1.1.
3537
- Also do not use the old cpuset API since it was deprecated and superseded
3538
- by the bitmap API in 1.1, and later removed in 1.5.
3539
-
3540
- If you ever need to look at the library version instead of the API version,
3541
- you may want to use HWLOC_VERSION instead.
3542
- Two stable releases of the same series usually have the same ::HWLOC_API_VERSION
3543
- even if their HWLOC_VERSION are different.
3544
-
3545
3471
3546
3472
3547
3473
\htmlonly
@@ -3710,13 +3636,110 @@ chuser "capabilities=CAP_PROPAGATE,CAP_NUMA_ATTACH" <username>
3710
3636
\endverbatim
3711
3637
3712
3638
3639
+ \htmlonly
3640
+ </div><div class="section" id="faq5">
3641
+ \endhtmlonly
3642
+ \section faq5 Compatibility between hwloc versions
3643
+
3644
+ \subsection faq_version_api How do I handle API changes?
3645
+
3646
+ The hwloc interface is extended with every new major release.
3647
+ Any application using the hwloc API should be prepared to check at
3648
+ compile-time whether some features are available in the currently
3649
+ installed hwloc distribution.
3650
+
3651
+ For instance, to check whether the hwloc version is at least 2.0, you should use:
3652
+ \verbatim
3653
+ #include <hwloc.h>
3654
+ #if HWLOC_API_VERSION >= 0x00020000
3655
+ ...
3656
+ #endif
3657
+ \endverbatim
3658
+
3659
+ To check for the API of release X.Y.Z at build time,
3660
+ you may compare ::HWLOC_API_VERSION with <tt>(X<<16)+(Y<<8)+Z</tt>.
3661
+
3662
+ For supporting older releases that do not have <tt>HWLOC_OBJ_NUMANODE</tt>
3663
+ and <tt>HWLOC_OBJ_PACKAGE</tt> yet, you may use:
3664
+
3665
+ \verbatim
3666
+ #include <hwloc.h>
3667
+ #if HWLOC_API_VERSION < 0x00010b00
3668
+ #define HWLOC_OBJ_NUMANODE HWLOC_OBJ_NODE
3669
+ #define HWLOC_OBJ_PACKAGE HWLOC_OBJ_SOCKET
3670
+ #endif
3671
+ \endverbatim
3672
+
3673
+ Once a program is built against a hwloc library, it may also dynamically
3674
+ link with compatible libraries from other hwloc releases.
3675
+ The version of that runtime library may be queried with hwloc_get_api_version().
3676
+ See \ref faq_version_abi for using this function for testing ABI compatibility.
3677
+
3678
+
3679
+
3680
+ \subsection faq_version What is the difference between API and library version numbers?
3681
+
3682
+ ::HWLOC_API_VERSION is the version of the API.
3683
+ It changes when functions are added, modified, etc.
3684
+ However it does not necessarily change from one release to another.
3685
+ For instance, two releases of the same series (e.g. 2.0.3 and 2.0.4)
3686
+ usually have the same ::HWLOC_API_VERSION (<tt>0x00020000</tt>).
3687
+ However their HWLOC_VERSION strings are different
3688
+ (<tt>\"2.0.3\"</tt> and <tt>\"2.0.4\"</tt> respectively).
3689
+
3690
+
3691
+
3692
+ \subsection faq_version_abi How do I handle ABI breaks?
3693
+
3694
+ The hwloc interface was deeply modified in release 2.0
3695
+ to fix several issues of the 1.x interface
3696
+ (see \ref upgrade_to_api_2x and the NEWS file in the source directory for details).
3697
+ The ABI was broken, which means
3698
+ <b>applications must be recompiled against the new 2.0 interface</b>.
3699
+
3700
+ To check that you are not mixing old/recent headers with a recent/old runtime library,
3701
+ check the major revision number in the API version:
3702
+ \verbatim
3703
+ #include <hwloc.h>
3704
+ unsigned version = hwloc_get_api_version();
3705
+ if ((version >> 16) != (HWLOC_API_VERSION >> 16)) {
3706
+ fprintf(stderr,
3707
+ "%s compiled for hwloc API 0x%x but running on library API 0x%x.\n"
3708
+ "You may need to point LD_LIBRARY_PATH to the right hwloc library.\n"
3709
+ "Aborting since the new ABI is not backward compatible.\n",
3710
+ callname, HWLOC_API_VERSION, version);
3711
+ exit(EXIT_FAILURE);
3712
+ }
3713
+ \endverbatim
3714
+ To specifically detect v2.0 issues:
3715
+ \verbatim
3716
+ #include <hwloc.h>
3717
+ #if HWLOC_API_VERSION >= 0x00020000
3718
+ /* headers are recent */
3719
+ if (hwloc_get_api_version() < 0x20000)
3720
+ ... error out, the hwloc runtime library is older than 2.0 ...
3721
+ #else
3722
+ /* headers are pre-2.0 */
3723
+ if (hwloc_get_api_version() >= 0x20000)
3724
+ ... error out, the hwloc runtime library is more recent than 2.0 ...
3725
+ #endif
3726
+ \endverbatim
3727
+
3728
+ In theory, library sonames prevent linking with incompatible libraries.
3729
+ However custom hwloc installations or improperly configured build environments
3730
+ may still lead to such issues.
3731
+ Hence running one of the above (cheap) checks before initializing hwloc topology
3732
+ may be useful.
3733
+
3734
+
3735
+
3713
3736
\page upgrade_to_api_2x Upgrading to the hwloc 2.0 API
3714
3737
3715
3738
\htmlonly
3716
3739
<div class="section">
3717
3740
\endhtmlonly
3718
3741
3719
- See \ref faq_upgrade for detecting the hwloc version that you are compiling
3742
+ See \ref faq5 for detecting the hwloc version that you are compiling
3720
3743
and/or running against.
3721
3744
3722
3745
0 commit comments