Browse Source

Merge 5fe25ad8bb into 6ec51c483e

pull/38/merge
Olav Møyner 2 months ago committed by GitHub
parent
commit
1b456a3449
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      CHANGELOG.md
  2. 1
      Project.toml
  3. 7
      docs/src/api.md
  4. 2
      gen/Makefile
  5. 127
      gen/Manifest.toml
  6. 3
      gen/generator.jl
  7. 1046
      lib/LibHYPRE.jl
  8. 48
      src/HYPRE.jl
  9. 18
      src/LibHYPRE.jl
  10. 14
      test/runtests.jl

8
CHANGELOG.md

@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [unreleased]
### Changed
- Updated HYPRE_jll to use hypre 3.0.0. This jll now includes OpenMP support. The upstream API has a breaking release, see the [hypre changelog](https://github.com/hypre-space/hypre/blob/master/CHANGELOG).
- `HYPRE_Init` now calls `HYPRE_Initialize` to match updated API.
### Added
- Functions for controlling threads (`HYPRE.set_nthreads` and `HYPRE.nthreads`) have been added.
## [v1.7.0] - 2024-10-09 ## [v1.7.0] - 2024-10-09
### Changed ### Changed
- Support for Julia 1.6 have been dropped and for this and future releases Julia 1.10 or - Support for Julia 1.6 have been dropped and for this and future releases Julia 1.10 or

1
Project.toml

@ -23,6 +23,7 @@ CEnum = "0.4, 0.5"
MPI = "0.19, 0.20" MPI = "0.19, 0.20"
PartitionedArrays = "0.5" PartitionedArrays = "0.5"
SparseMatricesCSR = "0.6" SparseMatricesCSR = "0.6"
HYPRE_jll = "3"
julia = "1.10" julia = "1.10"
[extras] [extras]

7
docs/src/api.md

@ -6,6 +6,13 @@
HYPRE.Init HYPRE.Init
``` ```
## Threads
```@docs
HYPRE.set_nthreads
HYPRE.nthreads
```
## Matrix/vector creation ## Matrix/vector creation
```@docs ```@docs

2
gen/Makefile

@ -10,5 +10,5 @@ clean:
$(LIBHYPRE): Project.toml Manifest.toml $(MAKEDIR)/generator.toml $(MAKEDIR)/generator.jl $(LIBHYPRE): Project.toml Manifest.toml $(MAKEDIR)/generator.toml $(MAKEDIR)/generator.jl
julia --project generator.jl && \ julia --project generator.jl && \
sed -i -e '1s/^/local libHYPRE # Silence of the Langs(erver)\n\n/' -e 's/using HYPRE_jll/using HYPRE_jll: HYPRE_jll, libHYPRE/' -e 's/using CEnum/using CEnum: @cenum/' $(LIBHYPRE) && \
julia-1.11 --project=@runic -e 'using Runic; exit(Runic.main(ARGS))' -- -i $(LIBHYPRE) julia-1.11 --project=@runic -e 'using Runic; exit(Runic.main(ARGS))' -- -i $(LIBHYPRE)
sed -i -e '1s/^/local libHYPRE # Silence of the Langs(erver)\n\n/' -e 's/using HYPRE_jll/using HYPRE_jll: HYPRE_jll, libHYPRE/' $(LIBHYPRE) && \

127
gen/Manifest.toml

@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised # This file is machine-generated - editing it directly is not advised
julia_version = "1.11.2" julia_version = "1.12.1"
manifest_format = "2.0" manifest_format = "2.0"
project_hash = "cc39013dba1e9068883c1b156d3b25864ebc62f8" project_hash = "df277ca779738e153f08cf93f2f2c019b5b0acd7"
[[deps.ArgTools]] [[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@ -23,20 +23,20 @@ version = "0.5.0"
[[deps.Clang]] [[deps.Clang]]
deps = ["CEnum", "Clang_jll", "Downloads", "Pkg", "TOML"] deps = ["CEnum", "Clang_jll", "Downloads", "Pkg", "TOML"]
git-tree-sha1 = "2397d5da17ba4970f772a9888b208a0a1d77eb5d" git-tree-sha1 = "6bf09af911d9df84656ddd0c02b5e449c18adba8"
uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31" uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31"
version = "0.18.3" version = "0.19.0"
[[deps.Clang_jll]] [[deps.Clang_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "TOML", "Zlib_jll", "libLLVM_jll"] deps = ["Artifacts", "JLLWrappers", "Libdl", "TOML", "Zlib_jll", "libLLVM_jll"]
git-tree-sha1 = "0dc9bd89383fd6fffed127e03fc42ed409cc865b" git-tree-sha1 = "f85df021a5fd31ac59ea7126232b2875a848544f"
uuid = "0ee61d77-7f21-5576-8119-9fcc46b10100" uuid = "0ee61d77-7f21-5576-8119-9fcc46b10100"
version = "16.0.6+4" version = "18.1.7+4"
[[deps.CompilerSupportLibraries_jll]] [[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.1+0" version = "1.3.0+1"
[[deps.Dates]] [[deps.Dates]]
deps = ["Printf"] deps = ["Printf"]
@ -53,28 +53,39 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
version = "1.11.0" version = "1.11.0"
[[deps.HYPRE_jll]] [[deps.HYPRE_jll]]
deps = ["Artifacts", "JLLWrappers", "LAPACK_jll", "LazyArtifacts", "Libdl", "MPICH_jll", "MPIPreferences", "MPItrampoline_jll", "MicrosoftMPI_jll", "OpenBLAS_jll", "OpenMPI_jll", "Pkg", "TOML"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LAPACK_jll", "LLVMOpenMP_jll", "LazyArtifacts", "Libdl", "MPICH_jll", "MPIPreferences", "MPItrampoline_jll", "MicrosoftMPI_jll", "OpenBLAS_jll", "OpenMPI_jll", "TOML"]
git-tree-sha1 = "b77d3eca75f8442e034ccf415c87405a49e77985" git-tree-sha1 = "8de137fe308da8b531f8bb76f9f347babc331bbd"
uuid = "0a602bbd-b08b-5d75-8d32-0de6eef44785" uuid = "0a602bbd-b08b-5d75-8d32-0de6eef44785"
version = "2.23.1+1" version = "3.0.0+0"
[[deps.Hwloc_jll]] [[deps.Hwloc_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"] deps = ["Artifacts", "JLLWrappers", "Libdl", "XML2_jll", "Xorg_libpciaccess_jll"]
git-tree-sha1 = "50aedf345a709ab75872f80a2779568dc0bb461b" git-tree-sha1 = "3d468106a05408f9f7b6f161d9e7715159af247b"
uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8" uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8"
version = "2.11.2+3" version = "2.12.2+0"
[[deps.JLLWrappers]] [[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"] deps = ["Artifacts", "Preferences"]
git-tree-sha1 = "a007feb38b422fbdab534406aeca1b86823cb4d6" git-tree-sha1 = "0533e564aae234aff59ab625543145446d8b6ec2"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.7.0" version = "1.7.1"
[[deps.JuliaSyntaxHighlighting]]
deps = ["StyledStrings"]
uuid = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011"
version = "1.12.0"
[[deps.LAPACK_jll]] [[deps.LAPACK_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "libblastrampoline_jll"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "libblastrampoline_jll"]
git-tree-sha1 = "47a6ccfc4b78494669cd7c502ba112ee2b24eb45" git-tree-sha1 = "1468f4fc27e37a74972e9c0fd259b9afb2ca1821"
uuid = "51474c39-65e3-53ba-86ba-03b1b862ec14" uuid = "51474c39-65e3-53ba-86ba-03b1b862ec14"
version = "3.12.0+3" version = "3.12.1+0"
[[deps.LLVMOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "eb62a3deb62fc6d8822c0c4bef73e4412419c5d8"
uuid = "1d63c593-3942-5779-bab2-d838dc0a180e"
version = "18.1.8+0"
[[deps.LazyArtifacts]] [[deps.LazyArtifacts]]
deps = ["Artifacts", "Pkg"] deps = ["Artifacts", "Pkg"]
@ -87,38 +98,44 @@ uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.4" version = "0.6.4"
[[deps.LibCURL_jll]] [[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "8.6.0+0" version = "8.11.1+1"
[[deps.LibGit2]] [[deps.LibGit2]]
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] deps = ["LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
version = "1.11.0" version = "1.11.0"
[[deps.LibGit2_jll]] [[deps.LibGit2_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll"]
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
version = "1.7.2+0" version = "1.9.0+0"
[[deps.LibSSH2_jll]] [[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"] deps = ["Artifacts", "Libdl", "OpenSSL_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.11.0+1" version = "1.11.3+1"
[[deps.Libdl]] [[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
version = "1.11.0" version = "1.11.0"
[[deps.Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.18.0+0"
[[deps.Logging]] [[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
version = "1.11.0" version = "1.11.0"
[[deps.MPICH_jll]] [[deps.MPICH_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
git-tree-sha1 = "7715e65c47ba3941c502bffb7f266a41a7f54423" git-tree-sha1 = "9341048b9f723f2ae2a72a5269ac2f15f80534dc"
uuid = "7cb0a576-ebde-5e09-9194-50597f1243b4" uuid = "7cb0a576-ebde-5e09-9194-50597f1243b4"
version = "4.2.3+0" version = "4.3.2+0"
[[deps.MPIPreferences]] [[deps.MPIPreferences]]
deps = ["Libdl", "Preferences"] deps = ["Libdl", "Preferences"]
@ -128,20 +145,15 @@ version = "0.1.11"
[[deps.MPItrampoline_jll]] [[deps.MPItrampoline_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
git-tree-sha1 = "70e830dab5d0775183c99fc75e4c24c614ed7142" git-tree-sha1 = "e214f2a20bdd64c04cd3e4ff62d3c9be7e969a59"
uuid = "f1f71cc9-e9ae-5b93-9b94-4fe0e1ad3748" uuid = "f1f71cc9-e9ae-5b93-9b94-4fe0e1ad3748"
version = "5.5.1+2" version = "5.5.4+0"
[[deps.Markdown]] [[deps.Markdown]]
deps = ["Base64"] deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
version = "1.11.0" version = "1.11.0"
[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.6+0"
[[deps.MicrosoftMPI_jll]] [[deps.MicrosoftMPI_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "bc95bf4149bf535c09602e3acdf950d9b4376227" git-tree-sha1 = "bc95bf4149bf535c09602e3acdf950d9b4376227"
@ -150,27 +162,32 @@ version = "10.1.4+3"
[[deps.MozillaCACerts_jll]] [[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159" uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2023.12.12" version = "2025.5.20"
[[deps.NetworkOptions]] [[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0" version = "1.3.0"
[[deps.OpenBLAS_jll]] [[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.27+1" version = "0.3.29+0"
[[deps.OpenMPI_jll]] [[deps.OpenMPI_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]
git-tree-sha1 = "2dace87e14256edb1dd0724ab7ba831c779b96bd" git-tree-sha1 = "ec764453819f802fc1e144bfe750c454181bd66d"
uuid = "fe0851c0-eecd-5654-98d4-656369965a5c" uuid = "fe0851c0-eecd-5654-98d4-656369965a5c"
version = "5.0.6+0" version = "5.0.8+0"
[[deps.OpenSSL_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "3.5.1+0"
[[deps.Pkg]] [[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.11.0" version = "1.12.0"
[deps.Pkg.extensions] [deps.Pkg.extensions]
REPLExt = "REPL" REPLExt = "REPL"
@ -180,9 +197,9 @@ version = "1.11.0"
[[deps.Preferences]] [[deps.Preferences]]
deps = ["TOML"] deps = ["TOML"]
git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d"
uuid = "21216c6a-2e73-6563-6e65-726566657250" uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.4.3" version = "1.5.0"
[[deps.Printf]] [[deps.Printf]]
deps = ["Unicode"] deps = ["Unicode"]
@ -198,6 +215,10 @@ version = "1.11.0"
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0" version = "0.7.0"
[[deps.StyledStrings]]
uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
version = "1.11.0"
[[deps.TOML]] [[deps.TOML]]
deps = ["Dates"] deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
@ -217,27 +238,39 @@ version = "1.11.0"
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
version = "1.11.0" version = "1.11.0"
[[deps.XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"]
git-tree-sha1 = "80d3930c6347cfce7ccf96bd3bafdf079d9c0390"
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
version = "2.13.9+0"
[[deps.Xorg_libpciaccess_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Zlib_jll"]
git-tree-sha1 = "4909eb8f1cbf6bd4b1c30dd18b2ead9019ef2fad"
uuid = "a65dc6b1-eb27-53a1-bb3e-dea574b5389e"
version = "0.18.1+0"
[[deps.Zlib_jll]] [[deps.Zlib_jll]]
deps = ["Libdl"] deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a" uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.13+1" version = "1.3.1+2"
[[deps.libLLVM_jll]] [[deps.libLLVM_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a" uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a"
version = "16.0.6+4" version = "18.1.7+5"
[[deps.libblastrampoline_jll]] [[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.11.0+0" version = "5.15.0+0"
[[deps.nghttp2_jll]] [[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.59.0+0" version = "1.64.0+1"
[[deps.p7zip_jll]] [[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "17.4.0+2" version = "17.5.0+2"

3
gen/generator.jl

@ -14,12 +14,13 @@ push!(args, "-isystem$(mpi_include_dir)")
# Compiler flags from Yggdrasil (??) # Compiler flags from Yggdrasil (??)
# https://github.com/JuliaPackaging/Yggdrasil/blob/9d131ba0e4aa393b00f4d71ef5a3f909419a70a7/H/HYPRE/build_tarballs.jl # https://github.com/JuliaPackaging/Yggdrasil/blob/9d131ba0e4aa393b00f4d71ef5a3f909419a70a7/H/HYPRE/build_tarballs.jl
push!(args, "-DHYPRE_ENABLE_SHARED=ON") push!(args, "-DBUILD_SHARED_LIBS=ON")
push!(args, "-DHYPRE_ENABLE_HYPRE_BLAS=ON") push!(args, "-DHYPRE_ENABLE_HYPRE_BLAS=ON")
push!(args, "-DHYPRE_ENABLE_HYPRE_LAPACK=ON") push!(args, "-DHYPRE_ENABLE_HYPRE_LAPACK=ON")
push!(args, "-DHYPRE_ENABLE_CUDA_STREAMS=OFF") push!(args, "-DHYPRE_ENABLE_CUDA_STREAMS=OFF")
push!(args, "-DHYPRE_ENABLE_CUSPARSE=OFF") push!(args, "-DHYPRE_ENABLE_CUSPARSE=OFF")
push!(args, "-DHYPRE_ENABLE_CURAND=OFF") push!(args, "-DHYPRE_ENABLE_CURAND=OFF")
push!(args, "-DHYPRE_ENABLE_OPENMP=ON")
headers = joinpath.( headers = joinpath.(
hypre_include_dir, hypre_include_dir,

1046
lib/LibHYPRE.jl

File diff suppressed because it is too large Load Diff

48
src/HYPRE.jl

@ -10,27 +10,37 @@ export HYPREMatrix, HYPREVector
# Clang.jl auto-generated bindings and some manual methods # Clang.jl auto-generated bindings and some manual methods
include("LibHYPRE.jl") include("LibHYPRE.jl")
using .LibHYPRE using .LibHYPRE
using .LibHYPRE: @check using .LibHYPRE: @check, HYPRE_SetNumThreads, HYPRE_NumThreads
# Internal namespace to hide utility functions # Internal namespace to hide utility functions
include("Internals.jl") include("Internals.jl")
""" """
Init(; finalize_atexit=true) Init(; finalize_atexit=true, nthreads = 1)
Wrapper around `HYPRE_Init`. If `finalize_atexit` is `true` a Julia exit hook is added, Wrapper around `HYPRE_Initialize`. If `finalize_atexit` is `true` a Julia exit hook is added,
which calls `HYPRE_Finalize`. This method will also call `MPI.Init` unless MPI is already which calls `HYPRE_Finalize`. This method will also call `MPI.Init` unless MPI is already
initialized. initialized.
The optional argument `nthreads` can be used to set the number of OpenMP threads
HYPRE should use. The default is `1`, meaning no multithreading. See
[`set_nthreads`](@ref) for more details. Setting `threads` to `0` or a negative
value means that the number of threads will be controlled by hypre internally.
This will typically be equal to the maximum number of threads, or the value in
the ENV variable `OMP_NUM_THREADS`.
**Note**: This function *must* be called before using HYPRE functions. **Note**: This function *must* be called before using HYPRE functions.
""" """
function Init(; finalize_atexit = true) function Init(; nthreads = 1, finalize_atexit = true)
if !(MPI.Initialized()) if !(MPI.Initialized())
MPI.Init() MPI.Init()
end end
# TODO: Check if already initialized? # TODO: Check if already initialized?
HYPRE_Init() HYPRE_Initialize()
if nthreads > 0
set_nthreads(nthreads)
end
if finalize_atexit if finalize_atexit
# TODO: MPI only calls the finalizer if not exiting due to a Julia exeption. Does # TODO: MPI only calls the finalizer if not exiting due to a Julia exeption. Does
# the same reasoning apply here? # the same reasoning apply here?
@ -44,6 +54,34 @@ function Init(; finalize_atexit = true)
return nothing return nothing
end end
"""
set_nthreads(1) # Single OpenMP thread
set_nthreads(10) # Use up to 10 OpenMP threads
Set the number of OpenMP threads HYPRE should use internally on current process.
The default is `1`, meaning no multithreading. Setting it to a zero or a
negative value means that the number of threads will be unchanged.
**Note***: The number of threads can improve execution speed, but a large number
of threads can be detrimental to actual solver performance for some solvers
(e.g. parallel Gauss-Seidel smoothers).
"""
function set_nthreads(nt::Integer)
if nt > 0
nt = min(nt, Sys.CPU_THREADS)
HYPRE_SetNumThreads(nt)
end
return nthreads()
end
"""
n = threads()
Get the current number of OpenMP threads HYPRE is set to use on current process.
"""
function nthreads()
return HYPRE_NumThreads()
end
############### ###############
# HYPREMatrix # # HYPREMatrix #

18
src/LibHYPRE.jl

@ -5,6 +5,24 @@ using Libdl: dlsym
# Clang.jl auto-generated bindings # Clang.jl auto-generated bindings
include("../lib/LibHYPRE.jl") include("../lib/LibHYPRE.jl")
# Backwards compatibility for older versions of HYPRE.jl
function HYPRE_Init()
return HYPRE_Initialize()
end
# Threading utilities if built with OpenMP
function HYPRE_NumThreads()
return @ccall libHYPRE.hypre_NumThreads()::HYPRE_Int
end
function HYPRE_SetNumThreads(nt::HYPRE_Int)
return @ccall libHYPRE.hypre_SetNumThreads(nt::HYPRE_Int)::Ptr{Cvoid}
end
function HYPRE_SetNumThreads(nt::Integer)
return HYPRE_SetNumThreads(HYPRE_Int(nt))
end
# Add manual methods for some ::Function signatures where the library wants function # Add manual methods for some ::Function signatures where the library wants function
# pointers. Instead of creating function pointers to the Julia wrappers we can just look # pointers. Instead of creating function pointers to the Julia wrappers we can just look
# up the pointer in the library and pass that. # up the pointer in the library and pass that.

14
test/runtests.jl

@ -17,7 +17,7 @@ HYPRE.Init()
@testset "LibHYPRE" begin @testset "LibHYPRE" begin
@test LibHYPRE.VERSION > VERSION # :) @test LibHYPRE.VERSION > VERSION # :)
@test LibHYPRE.VERSION.major == 2 @test LibHYPRE.VERSION.major == 3
end end
@testset "HYPREMatrix" begin @testset "HYPREMatrix" begin
@ -420,7 +420,7 @@ end
x_h = HYPREVector(b, ilower, iupper) x_h = HYPREVector(b, ilower, iupper)
# Solve # Solve
tol = 1.0e-9 tol = 1.0e-9
amg = HYPRE.BoomerAMG(; Tol = tol) amg = HYPRE.BoomerAMG(; Tol = tol, MaxIter = 25)
HYPRE.solve!(amg, x_h, A_h, b_h) HYPRE.solve!(amg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test (A * x b) atol = tol * norm(b) # default BoomerAMG criteria @test (A * x b) atol = tol * norm(b) # default BoomerAMG criteria
@ -749,6 +749,16 @@ end
@test xcsr CSC \ b atol = tol # TODO: CSR \ b fails @test xcsr CSC \ b atol = tol # TODO: CSR \ b fails
end end
@testset "Threads" begin
current = HYPRE.nthreads()
@test HYPRE.set_nthreads(1) == 1
@test HYPRE.set_nthreads(2) == 2
@test HYPRE.nthreads() == 2
@test HYPRE.set_nthreads(0) == 2
@test HYPRE.set_nthreads(1_000_000) == Sys.CPU_THREADS
@test HYPRE.set_nthreads(current) == current
end
@testset "MPI execution" begin @testset "MPI execution" begin
testfiles = joinpath.( testfiles = joinpath.(
@__DIR__, @__DIR__,

Loading…
Cancel
Save