From 113c37a153d2f53ed75352d74bbba3f24fd6e14c Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Tue, 5 Nov 2024 10:33:40 +0900 Subject: [PATCH 1/3] optimize precompilation process during runtests --- .buildkite/pipeline.yml | 2 +- Project.toml | 6 +++++- test/code_quality.jl | 3 --- test/{ => gpu}/CUDAExt.jl | 6 ------ test/gpu/Project.toml | 6 ++++++ test/runtests.jl | 24 +++++++++++++++++------- 6 files changed, 29 insertions(+), 18 deletions(-) rename test/{ => gpu}/CUDAExt.jl (97%) create mode 100644 test/gpu/Project.toml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 7ee46c61..cbedf79b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -9,7 +9,7 @@ steps: - "src/**" - "ext/HierarchicalEOM_CUDAExt.jl" - "test/runtests.jl" - - "test/CUDAExt.jl" + - "test/gpu/**" - "Project.toml" target: ".buildkite/CUDA_Ext.yml" agents: diff --git a/Project.toml b/Project.toml index a2590e6e..389d256f 100644 --- a/Project.toml +++ b/Project.toml @@ -26,9 +26,11 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" HierarchicalEOM_CUDAExt = "CUDA" [compat] +Aqua = "0.8" CUDA = "5" DiffEqCallbacks = "2 - 4" FastExpm = "1.1" +JET = "0.9" JLD2 = "0.4.31 - 0.5" LinearAlgebra = "1" LinearSolve = "2.4.2 - 2" @@ -45,7 +47,9 @@ Test = "1" julia = "1.10" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Aqua", "JET", "Test"] diff --git a/test/code_quality.jl b/test/code_quality.jl index 2e42500e..55a9c21b 100644 --- a/test/code_quality.jl +++ b/test/code_quality.jl @@ -1,6 +1,3 @@ -import Aqua -import JET - @testset "Code quality" verbose = true begin @testset "Aqua.jl" begin Aqua.test_all(HierarchicalEOM; ambiguities = false) diff --git a/test/CUDAExt.jl b/test/gpu/CUDAExt.jl similarity index 97% rename from test/CUDAExt.jl rename to test/gpu/CUDAExt.jl index 18bb8e07..db0ff4c5 100644 --- a/test/CUDAExt.jl +++ b/test/gpu/CUDAExt.jl @@ -1,9 +1,3 @@ -using LinearSolve -using CUDA -CUDA.allowscalar(false) # Avoid unexpected scalar indexing - -CUDA.versioninfo() - CUDA.@time @testset "CUDA Extension" begin # re-define the bath (make the matrix smaller) diff --git a/test/gpu/Project.toml b/test/gpu/Project.toml new file mode 100644 index 00000000..63ad2aa7 --- /dev/null +++ b/test/gpu/Project.toml @@ -0,0 +1,6 @@ +[deps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab" + +[compat] +CUDA = "5" \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index db4316ca..c23bc83f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,5 @@ using Pkg using Test -using HierarchicalEOM -import JLD2: jldopen const GROUP = get(ENV, "GROUP", "All") @@ -28,22 +26,34 @@ core_tests = [ ] if (GROUP == "All") || (GROUP == "Code_Quality") - Pkg.add(["Aqua", "JET"]) + using HierarchicalEOM + using Aqua, JET - HierarchicalEOM.about() include(joinpath(testdir, "code_quality.jl")) end if (GROUP == "All") || (GROUP == "Core") - GROUP == "All" ? nothing : HierarchicalEOM.about() + using HierarchicalEOM + import JLD2: jldopen + + HierarchicalEOM.about() + for test in core_tests include(joinpath(testdir, test)) end end if (GROUP == "CUDA_Ext")# || (GROUP == "All") - Pkg.add("CUDA") + Pkg.activate("gpu") + Pkg.develop(PackageSpec(path = dirname(@__DIR__))) + Pkg.instantiate() + + using HierarchicalEOM + using CUDA, LinearSolve + CUDA.allowscalar(false) # Avoid unexpected scalar indexing HierarchicalEOM.about() - include(joinpath(testdir, "CUDAExt.jl")) + CUDA.versioninfo() + + include(joinpath(testdir, "gpu", "CUDAExt.jl")) end From 6806f40954cf085e39bf27200262f12f4cadde54 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Tue, 5 Nov 2024 10:43:59 +0900 Subject: [PATCH 2/3] fix typo --- test/test_utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_utils.jl b/test/test_utils.jl index a5326295..db9f2a82 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -1,4 +1,4 @@ -function _is_Matrix_approx(M1::QuantumObject, M2; atol = 1.0e-6) +function _is_Matrix_approx(M1, M2; atol = 1.0e-6) s1 = size(M1) s2 = size(M2) if s1 == s2 From de74b2a35bbe2c22f17455fef02448bdaa63fbe2 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Tue, 5 Nov 2024 13:35:14 +0900 Subject: [PATCH 3/3] minor changes --- test/runtests.jl | 5 +++-- test/test_utils.jl | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index c23bc83f..ef3d1904 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,8 +5,6 @@ const GROUP = get(ENV, "GROUP", "All") const testdir = dirname(@__FILE__) -include("test_utils.jl") - # Put Core tests in alphabetical order core_tests = [ "ADOs.jl", @@ -38,6 +36,8 @@ if (GROUP == "All") || (GROUP == "Core") HierarchicalEOM.about() + include(joinpath(testdir, "test_utils.jl")) + for test in core_tests include(joinpath(testdir, test)) end @@ -55,5 +55,6 @@ if (GROUP == "CUDA_Ext")# || (GROUP == "All") HierarchicalEOM.about() CUDA.versioninfo() + include(joinpath(testdir, "test_utils.jl")) include(joinpath(testdir, "gpu", "CUDAExt.jl")) end diff --git a/test/test_utils.jl b/test/test_utils.jl index db9f2a82..a5326295 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -1,4 +1,4 @@ -function _is_Matrix_approx(M1, M2; atol = 1.0e-6) +function _is_Matrix_approx(M1::QuantumObject, M2; atol = 1.0e-6) s1 = size(M1) s2 = size(M2) if s1 == s2