Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Preferences for using custom hdf5 library #1061

Merged
merged 41 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f7dc5c2
use system library using Preferences.jl
JoshuaLampert Apr 19, 2023
7d226ae
allow specific library filenames
JoshuaLampert Apr 19, 2023
3261f29
fix typo
JoshuaLampert Apr 19, 2023
0489e4d
Apply suggestions from code review
JoshuaLampert Apr 19, 2023
d60a8e6
import dlsym
JoshuaLampert Apr 19, 2023
93601ac
remove deps folder from Format check
JoshuaLampert Apr 19, 2023
7c34b18
set julia compat to 1.6
JoshuaLampert Apr 19, 2023
f292a51
extend docs
JoshuaLampert Apr 19, 2023
efbda60
format
JoshuaLampert Apr 20, 2023
0571a1d
bump version
JoshuaLampert Apr 20, 2023
99f695a
bump HDF5 compat versions of filters to 0.17
JoshuaLampert Apr 20, 2023
6eb754c
update HISTORY.md
JoshuaLampert Apr 20, 2023
2e5239b
add note on migration instructions
JoshuaLampert Apr 21, 2023
d190097
add example of LocalPreferences.toml in docs
JoshuaLampert Apr 21, 2023
00b320a
CI test for system libraries with Preferences
JoshuaLampert Apr 27, 2023
31f6114
format
JoshuaLampert Apr 27, 2023
1cc907d
fix pwd
JoshuaLampert Apr 27, 2023
3a440e7
add Project.toml
JoshuaLampert Apr 27, 2023
09167eb
rm Project.toml
JoshuaLampert Apr 27, 2023
63ca75d
add julia-actions to system library CI
JoshuaLampert Apr 27, 2023
91efbee
debug CI
JoshuaLampert Apr 27, 2023
37cc3c2
add Project.toml
JoshuaLampert Apr 27, 2023
e896d9d
remove additional julia-actions
JoshuaLampert Apr 27, 2023
bf1cebc
debug CI
JoshuaLampert Apr 27, 2023
369caa2
debug CI
JoshuaLampert Apr 27, 2023
ab7700c
explicitly state possible library names in docs
JoshuaLampert Apr 27, 2023
645f574
set prefs to each library
JoshuaLampert Apr 27, 2023
811650d
Merge branch 'master' into preferences
mkitti Apr 27, 2023
a8cb6ba
Merge branch 'master' into preferences
JoshuaLampert May 1, 2023
77f3e19
update docs (HDF5_jll comes with MPI)
JoshuaLampert May 29, 2023
99f3875
workaround
JoshuaLampert May 29, 2023
cf318da
Merge branch 'master' into preferences
mkitti May 30, 2023
1e183f0
fix workaround
JoshuaLampert May 30, 2023
bd14d4f
disable virtual dataset tests for libhdf5 version < 1.12
JoshuaLampert Jun 1, 2023
13ec550
fix typo in docs
JoshuaLampert Jun 1, 2023
8e98087
raise warning if JULIA_HDF5_PATH is detected
JoshuaLampert Jun 1, 2023
a156e60
format
JoshuaLampert Jun 1, 2023
5304ba5
Apply suggestions from code review
JoshuaLampert Jun 2, 2023
b89dda3
set both preferences in one call
JoshuaLampert Jun 2, 2023
7e5eec7
set both preferences in one call
JoshuaLampert Jun 2, 2023
37dde47
Apply suggestions from code review
JoshuaLampert Jun 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
strategy:
matrix:
version:
- '1.3'
- '1.6'
- '1'
os:
- ubuntu-20.04 # required for libhdf5 v1.10.4 support
arch:
Expand All @@ -27,15 +28,20 @@ jobs:
sudo apt-get update
sudo apt-get install mpich libhdf5-mpich-dev
echo "JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/" >> $GITHUB_ENV
echo "JULIA_MPI_BINARY=system" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- name: Configure MPI.jl
shell: julia --color=yes {0}
run: |
@show pwd()
include(joinpath(pwd(), "test", "configure_packages.jl"))
- uses: julia-actions/julia-runtest@latest


HDF5:
name: julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
Expand All @@ -44,7 +50,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.3'
- '1.6'
- '1'
- 'nightly'
os:
Expand All @@ -59,13 +65,13 @@ jobs:
arch: x86
- os: ubuntu-latest # excluded because HDF5_jll v1.12 does not support i686
arch: x86
- version: '1.3'
- version: '1.6'
arch: x86
- version: 'nightly'
arch: x86
- version: '1.3'
- version: '1.6'
os: macOS-latest
- version: '1.3'
- version: '1.6'
os: windows-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(["src", "test", "deps", "filters", "gen"], verbose=true)'
julia -e 'using JuliaFormatter; format(["src", "test", "filters", "gen"], verbose=true)'
- name: Format check
run: |
julia -e '
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.jl.mem
/docs/build/
Manifest.toml
LocalPreferences.toml
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Please also see the [release notes](https://github.com/JuliaIO/HDF5.jl/releases) for additional details.

## v0.17.0
* Replace build step by using Preferences.jl to use system HDF5 library

## v0.16.14
* Allow `begin` to work in a dataset
* Simplify MPIO tests and internals
Expand Down
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
name = "HDF5"
uuid = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
version = "0.16.15"
version = "0.17.0"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
HDF5_jll = "0234f1f7-429e-5d53-9886-15a909be8d59"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"

[compat]
Compat = "3.1.0, 4"
HDF5_jll = "~1.10.5, ~1.12.0, ~1.14.0"
MPIPreferences = "0.1.7"
Preferences = "1.3"
Requires = "1.0"
julia = "1.3"
julia = "1.6"

[extras]
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
Expand Down
5 changes: 0 additions & 5 deletions deps/.gitignore

This file was deleted.

77 changes: 0 additions & 77 deletions deps/build.jl

This file was deleted.

48 changes: 41 additions & 7 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,58 @@ Starting from Julia 1.3, the HDF5 binaries are by default downloaded using the `

### Using custom or system provided HDF5 binaries

To use system-provided HDF5 binaries instead, set the environment variable `JULIA_HDF5_PATH` to the top-level installation directory HDF5, i.e. the library should be located in `${JULIA_HDF5_PATH}/lib` or `${JULIA_HDF5_PATH}/lib64`, or alternatively simply in `${JULIA_HDF5_PATH}`. Then run `import Pkg; Pkg.build("HDF5")`. In particular, this is required if you need parallel HDF5 support, which is not provided by the `HDF5_jll` binaries.
!!! note "Migration from HDF5.jl v0.16 and earlier"
How to use a system-provided HDF5 library has been changed in HDF5.jl v0.17. Previously,
the library path was set by the environment variable `JULIA_HDF5_PATH`, which required to
rebuild HDF5.jl afterwards. The environment variable has been removed and no longer has an
effect (for backward compatibility it is still recommended to **also** set the environment
variable). Instead, proceed as described below.

If the library is in your library search path, then `JULIA_HDF5_PATH` can be set to an empty string.
To use system-provided HDF5 binaries instead, set the preferences `libhdf5` and `libhdf5_hl`, see also [Preferences.jl](https://github.com/JuliaPackaging/Preferences.jl). These need to point to the local paths of the libraries `libhdf5` and `libhdf5_hl`.

For example, to use HDF5 (`libhdf5-mpich-dev`) with MPI using system libraries on Ubuntu 20.04, you would run:
For example, to use HDF5 (`libhdf5-mpich-dev`) with MPI using system libraries on Ubuntu 20.04, you would run

```sh
$ sudo apt install mpich libhdf5-mpich-dev
$ JULIA_HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/mpich/
$ JULIA_MPI_BINARY=system
```

Then in Julia, run:
If your system HDF5 library is compiled with MPI, you need to tell MPI.jl to use the same locally installed MPI implementation. This can be done in Julia by running:

```julia
pkg> build
using MPIPreferences
MPIPreferences.use_system_binary()
```

to set the MPI preferences, see the [documentation of MPI.jl](https://juliaparallel.org/MPI.jl/stable/configuration/). You can set the path to the system library using [Preferences.jl](https://github.com/JuliaPackaging/Preferences.jl) by:

```julia
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
using Preferences, UUIDs

set_preferences!(
UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl
"libhdf5" => "/usr/lib/x86_64-linux-gnu/hdf5/mpich/libhdf5.so", force = true)
set_preferences!(
UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl
"libhdf5_hl" => "/usr/lib/x86_64-linux-gnu/hdf5/mpich/libhdf5_hl.so", force = true)
```

JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
Both, the MPI preferences and the preferences for HDF5.jl write to a file called LocalPreferences.toml in the project directory. After performing the described steps this file could look like the following:

```toml
[MPIPreferences]
_format = "1.0"
abi = "MPICH"
binary = "system"
libmpi = "/software/mpi/lib/libmpi.so"
mpiexec = "/software/mpi/bin/mpiexec"

[HDF5]
libhdf5 = "/usr/lib/x86_64-linux-gnu/hdf5/mpich/libhdf5.so"
libhdf5_hl = "/usr/lib/x86_64-linux-gnu/hdf5/mpich/libhdf5_hl.so"
```

If you want to switch to another HDF5 library or the library moved, you can call the `set_preferences!` commands again (or manually edit LocalPreferences.toml) to set the new paths. Using the default implementation provided by HDF5_jll can be done by simply manually deleting the LocalPreferences.toml file.

## Opening and closing files

"Plain" (i.e., with no extra formatting conventions) HDF5 files are created and/or opened with the `h5open` command:
Expand Down
46 changes: 41 additions & 5 deletions docs/src/mpi.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In practice, this means that in Julia code, `MPI` must be imported _before_
The following step-by-step guide assumes one already has access to
parallel-enabled HDF5 libraries linked to an existent MPI installation.

### 1. Using system-provided MPI libraries
### [1. Using system-provided MPI libraries](@id using_system_MPI)

Using a system-provided MPI library can be done with MPIPreferences.jl.
After installing MPIPreferences.jl and running
Expand All @@ -31,12 +31,29 @@ See the [MPI.jl
docs](https://juliaparallel.org/MPI.jl/stable/configuration/#Using-a-system-provided-MPI-backend)
for details.

### 2. Using parallel HDF5 libraries
### [2. Using parallel HDF5 libraries](@id using_parallel_HDF5)

!!! note "Migration from HDF5.jl v0.16 and earlier"
How to use a system-provided HDF5 library has been changed in HDF5.jl v0.17. Previously,
the library path was set by the environment variable `JULIA_HDF5_PATH`, which required to
rebuild HDF5.jl afterwards. The environment variable has been removed and no longer has an
effect (for backward compatibility it is still recommended to **also** set the environment
variable). Instead, proceed as described below.

As detailed in [Using custom or system provided HDF5 binaries](@ref), set the
`JULIA_HDF5_PATH` environment variable to the path where the parallel HDF5
binaries are located.
Then run `]build HDF5` from Julia.
preferences `libhdf5` and `libhdf5_hl` to the full path, where the parallel HDF5 binaries are located.
This can be done by:

```julia
julia> using Preferences, UUIDs

julia> set_preferences!(
UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl
"libhdf5" => "/path/to/your/libhdf5.so", force = true)
julia> set_preferences!(
UUID("f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"), # UUID of HDF5.jl
"libhdf5_hl" => "/path/to/your/libhdf5_hl.so", force = true)
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
```
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved

### 3. Loading MPI-enabled HDF5

Expand All @@ -50,6 +67,25 @@ using HDF5
@assert HDF5.has_parallel()
```

### Notes to HPC cluster administrators

More information for a setup at an HPC cluster can be found in the [docs of MPI.jl](https://juliaparallel.org/MPI.jl/stable/configuration/#Notes-to-HPC-cluster-administrators).
After performing the steps [1.](@ref using_system_MPI) and [2.](@ref using_parallel_HDF5) the
LocalPreferences.toml file could look something like the following:

```toml
[MPIPreferences]
_format = "1.0"
abi = "OpenMPI"
binary = "system"
libmpi = "/software/mpi/lib/libmpi.so"
mpiexec = "/software/mpi/bin/mpiexec"

[HDF5]
libhdf5 = "/path/to/your/libhdf5.so"
libhdf5_hl = "/path/to/your/libhdf5_hl.so"
```

### Reading and writing data in parallel

A parallel HDF5 file may be opened by passing a `MPI.Comm` (and optionally a
Expand Down
2 changes: 1 addition & 1 deletion filters/H5Zbitshuffle/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
bitshuffle_jll = "228fe19c-1b83-5282-a626-13744502a320"

[compat]
HDF5 = "0.16"
HDF5 = "0.17"
bitshuffle_jll = "0.4.2"
julia = "1.6"
2 changes: 1 addition & 1 deletion filters/H5Zblosc/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Blosc = "a74b3585-a348-5f62-a45c-50e91977d574"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"

[compat]
HDF5 = "0.16"
HDF5 = "0.17"
Blosc = "0.7.3"
julia = "1.3"
2 changes: 1 addition & 1 deletion filters/H5Zbzip2/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"

[compat]
HDF5 = "0.16"
HDF5 = "0.17"
CodecBzip2 = "0.7"
julia = "1.3"
2 changes: 1 addition & 1 deletion filters/H5Zlz4/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ CodecLz4 = "5ba52731-8f18-5e0d-9241-30f10d1ec561"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"

[compat]
HDF5 = "0.16"
HDF5 = "0.17"
CodecLz4 = "0.4"
julia = "1.3"
2 changes: 1 addition & 1 deletion filters/H5Zzstd/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ CodecZstd = "6b39b394-51ab-5f42-8807-6242bab2b4c2"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"

[compat]
HDF5 = "0.16"
HDF5 = "0.17"
CodecZstd = "0.7"
julia = "1.3"
Loading