Skip to content

Commit

Permalink
LAMMPS uses Int32, so need BLAS LP64 compatibility. Default to OpenBL…
Browse files Browse the repository at this point in the history
…AS32_jll if LP64 library not available
  • Loading branch information
swyant committed Nov 22, 2024
1 parent 8bda95b commit 2317c39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ version = "0.7.2"
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
LAMMPS_jll = "5b3ab26d-9607-527c-88ea-8fe5ba57cafe"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
OpenBLAS32_jll = "656ef2d0-ae68-5445-9ca0-591084a874a2"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[compat]
CEnum = "0.4, 0.5"
LAMMPS_jll = "2.6.0"
Preferences = "1"
MPI = "0.20"
Preferences = "1"
julia = "1.10"
9 changes: 9 additions & 0 deletions src/LAMMPS.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module LAMMPS
import MPI
import LinearAlgebra
import OpenBLAS32_jll

include("api.jl")

export LMP, command, create_atoms, get_natoms, extract_atom, extract_compute, extract_global,
Expand Down Expand Up @@ -84,6 +87,12 @@ const TAGINT = API.lammps_extract_setting(C_NULL, "tagint") == 4 ? Int32 : Int64
const IMAGEINT = API.lammps_extract_setting(C_NULL, "imageint") == 4 ? Int32 : Int64

function __init__()
# LAMMPS requires using LP64, default to OpenBLAS32 if not already available
config = LinearAlgebra.BLAS.lbt_get_config()
if !any(lib -> lib.interface == :lp64, config.loaded_libs)
LinearAlgebra.BLAS.lbt_forward(OpenBLAS32_jll.libopenblas_path)
end

BIGINT != (API.lammps_extract_setting(C_NULL, "bigint") == 4 ? Int32 : Int64) &&
error("The size of the LAMMPS integer type BIGINT has changed! To fix this, you need to manually invalidate the LAMMPS.jl cache.")
TAGINT != (API.lammps_extract_setting(C_NULL, "tagint") == 4 ? Int32 : Int64) &&
Expand Down

0 comments on commit 2317c39

Please sign in to comment.