From 4cb8fa6b8c469e392b06628979fc3fbfc32c046b Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 2 Nov 2023 16:41:21 -0400 Subject: [PATCH 1/6] Support manually closing and lmp instance --- .github/workflows/CI.yml | 2 +- Project.toml | 4 ++-- src/LAMMPS.jl | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e21a0d6..afc3128 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: version: - - "1.6" + - "1.8" - "nightly" os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 4e6835b..20cac21 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LAMMPS" uuid = "ee2e13b9-eee9-4449-aafa-cfa6a2dbe14d" authors = ["Valentin Churavy "] -version = "0.2.2" +version = "0.3.0" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" @@ -15,4 +15,4 @@ CEnum = "0.4" LAMMPS_jll = "2.4" Preferences = "1" MPI = "0.20" -julia = "1.6" +julia = "1.8" diff --git a/src/LAMMPS.jl b/src/LAMMPS.jl index 09fcf6a..c99db89 100644 --- a/src/LAMMPS.jl +++ b/src/LAMMPS.jl @@ -48,7 +48,7 @@ function set_library!(path) end mutable struct LMP - handle::Ptr{Cvoid} + @atomic handle::Ptr{Cvoid} function LMP(args::Vector{String}=String[], comm::Union{Nothing, MPI.Comm}=nothing) if isempty(args) @@ -71,14 +71,24 @@ mutable struct LMP end this = new(handle) - finalizer(this) do this - API.lammps_close(this) - end + finalizer(close!, this) return this end end Base.unsafe_convert(::Type{Ptr{Cvoid}}, lmp::LMP) = lmp.handle +""" + close!(lmp::LMP) + +Shutdown an LMP instance. +""" +function close!(lmp::LMP) + handle = @atomicswp this.handle => C_NULL + if handle !== C_NULL + API.lammps_close(handle) + end +end + function LMP(f::Function, args=String[], comm=nothing) lmp = LMP(args, comm) f(lmp) From d3f2e67445ba40505f49110658c42efc23c797bf Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 2 Nov 2023 20:53:20 -0400 Subject: [PATCH 2/6] Update src/LAMMPS.jl --- src/LAMMPS.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LAMMPS.jl b/src/LAMMPS.jl index c99db89..69c99af 100644 --- a/src/LAMMPS.jl +++ b/src/LAMMPS.jl @@ -83,7 +83,7 @@ Base.unsafe_convert(::Type{Ptr{Cvoid}}, lmp::LMP) = lmp.handle Shutdown an LMP instance. """ function close!(lmp::LMP) - handle = @atomicswp this.handle => C_NULL + handle = @atomicswap this.handle => C_NULL if handle !== C_NULL API.lammps_close(handle) end From 9bf13b00a948d411b32840e00bf63b561ff3f866 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Fri, 3 Nov 2023 10:19:01 -0400 Subject: [PATCH 3/6] Update src/LAMMPS.jl --- src/LAMMPS.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LAMMPS.jl b/src/LAMMPS.jl index 69c99af..b1cf9c4 100644 --- a/src/LAMMPS.jl +++ b/src/LAMMPS.jl @@ -83,7 +83,7 @@ Base.unsafe_convert(::Type{Ptr{Cvoid}}, lmp::LMP) = lmp.handle Shutdown an LMP instance. """ function close!(lmp::LMP) - handle = @atomicswap this.handle => C_NULL + handle = @atomicswap this.handle = C_NULL if handle !== C_NULL API.lammps_close(handle) end From e968d0f603302da161acaca0543d39f164d58f23 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Fri, 3 Nov 2023 10:25:00 -0400 Subject: [PATCH 4/6] update CI --- .github/workflows/CI.yml | 8 -------- .github/workflows/Documentation.yml | 9 +-------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index afc3128..48bb198 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -37,14 +37,6 @@ jobs: ${{ runner.os }}-test-${{ env.cache-name }}- ${{ runner.os }}-test- ${{ runner.os }}- - - name: add CESMIX registry - run: | - julia -e ' - using Pkg - Pkg.Registry.add("General") - Pkg.Registry.add(RegistrySpec(url = "https://github.com/cesmix-mit/CESMIX.git")) - ' - shell: bash - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index a0210cb..ecc3697 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -13,14 +13,7 @@ jobs: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 with: - version: "1.6" - - name: add CESMIX registry - run: | - julia -e ' - using Pkg - Pkg.Registry.add("General") - Pkg.Registry.add(RegistrySpec(url = "https://github.com/cesmix-mit/CESMIX.git")) - ' + version: "1.8" shell: bash - name: instantiate docs run: | From c3472e1b4ede0d801b16a83340c88f8039073c96 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Fri, 3 Nov 2023 12:49:43 -0400 Subject: [PATCH 5/6] Update src/LAMMPS.jl --- src/LAMMPS.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LAMMPS.jl b/src/LAMMPS.jl index b1cf9c4..c0a2cbc 100644 --- a/src/LAMMPS.jl +++ b/src/LAMMPS.jl @@ -83,7 +83,7 @@ Base.unsafe_convert(::Type{Ptr{Cvoid}}, lmp::LMP) = lmp.handle Shutdown an LMP instance. """ function close!(lmp::LMP) - handle = @atomicswap this.handle = C_NULL + handle = @atomicswap lmp.handle = C_NULL if handle !== C_NULL API.lammps_close(handle) end From 5d5812623381b91420146ed69c1e28263fec3e77 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sat, 4 Nov 2023 10:00:06 -0400 Subject: [PATCH 6/6] Update .github/workflows/CI.yml --- .github/workflows/CI.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 48bb198..2c8546f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,6 +14,8 @@ jobs: matrix: version: - "1.8" + - "1.9" + - "~1.10.0-0" - "nightly" os: - ubuntu-latest