Skip to content

Commit

Permalink
messing around with extension loading and a few typos
Browse files Browse the repository at this point in the history
  • Loading branch information
leios committed Dec 18, 2024
1 parent a173ac2 commit fcdd072
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"

[extensions]
MollyEnzymeExt = "Enzyme"
MollyCUDAExt = "CUDA"
MollyEnzymeExt = "Enzyme"
MollyCUDAEnzymeExt = ["CUDA", "Enzyme"]
MollyGLMakieExt = ["GLMakie", "Colors"]
MollyKernelDensityExt = "KernelDensity"
MollyPythonCallExt = "PythonCall"
Expand All @@ -55,6 +56,7 @@ BioStructures = "4"
CUDA = "4.2, 5"
CellListMap = "0.8.11, 0.9"
Chemfiles = "0.10.3"
ChainRulesCore = "1.25.0"
Colors = "0.11, 0.12, 0.13"
Combinatorics = "1"
DataStructures = "0.18"
Expand Down
13 changes: 13 additions & 0 deletions ext/MollyCUDAEnzymeExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module MollyCUDAEnzymeExt

using Molly
using CUDA
using Enzyme

ext = Base.get_extension(Molly,:MollyCUDAExt)

EnzymeRules.inactive(::typeof(ext.cuda_threads_blocks_pairwise), args...) = nothing
EnzymeRules.inactive(::typeof(ext.cuda_threads_blocks_specific), args...) = nothing


end
1 change: 0 additions & 1 deletion ext/MollyCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module MollyCUDAExt

using Molly
using CUDA
using ChainRulesCore
using Atomix

CUDA.Const(nl::Molly.NoNeighborList) = nl
Expand Down
3 changes: 0 additions & 3 deletions ext/MollyEnzymeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ EnzymeRules.inactive(::typeof(Molly.n_infinite_dims), args...) = nothing
EnzymeRules.inactive(::typeof(random_velocity), args...) = nothing
EnzymeRules.inactive(::typeof(random_velocities), args...) = nothing
EnzymeRules.inactive(::typeof(random_velocities!), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.cuda_threads_blocks_pairwise), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.cuda_threads_blocks_specific), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.check_force_units), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.check_energy_units), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.atoms_bonded_to_N), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.lookup_table), args...) = nothing
EnzymeRules.inactive(::typeof(Molly.cuda_threads_blocks_gbsa), args...) = nothing
EnzymeRules.inactive(::typeof(find_neighbors), args...) = nothing
EnzymeRules.inactive_type(::Type{DistanceNeighborFinder}) = nothing
EnzymeRules.inactive(::typeof(visualize), args...) = nothing
Expand Down
4 changes: 2 additions & 2 deletions src/force.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ function forces(sys, neighbors, step_n::Integer=0; n_threads::Integer=Threads.nt
return forces_nounits .* sys.force_units
end

function forces_nounits!(fs_nounits, sys::System{D, false}, neighbors, fs_chunks=nothing,
step_n::Integer=0; n_threads::Integer=Threads.nthreads()) where D
function forces_nounits!(fs_nounits, sys::System{D, AT}, neighbors, fs_chunks=nothing,
step_n::Integer=0; n_threads::Integer=Threads.nthreads()) where {D, AT <: AbstractArray}
pairwise_inters_nonl = filter(!use_neighbors, values(sys.pairwise_inters))
pairwise_inters_nl = filter( use_neighbors, values(sys.pairwise_inters))
sils_1_atoms = filter(il -> il isa InteractionList1Atoms, values(sys.specific_inter_lists))
Expand Down
4 changes: 2 additions & 2 deletions src/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ function System(coord_file::AbstractString,
)
end

atoms = ArrayType(atoms)
coords = ArrayType(coords)
atoms = ArrayType([atoms_abst...])
coords_dev = ArrayType(coords)

if isnothing(velocities)
if units
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
12 changes: 1 addition & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ end
# Allow CUDA device to be specified
const DEVICE = parse(Int, get(ENV, "DEVICE", "0"))

<<<<<<< HEAD
const run_gpu_tests = get(ENV, "GPUTESTS", "1") != "0" && CUDA.functional()
const gpu_list = (run_gpu_tests ? (false, true) : (false,))
if run_gpu_tests
device!(DEVICE)
@info "The GPU tests will be run on device $DEVICE"
elseif get(ENV, "GPUTESTS", "1") == "0"
@warn "The GPU tests will not be run as GPUTESTS is set to 0"
=======
const run_cuda_tests = get(ENV, "GPUTESTS", "1") != "0" && CUDA.functional()
const run_rocm_tests = get(ENV, "GPUTESTS", "1") != "0" && AMDGPU.functional()

Expand All @@ -72,14 +63,13 @@ if run_cuda_tests
array_list = (array_list..., CuArray)
device!(parse(Int, DEVICE))
@info "The CUDA tests will be run on device $DEVICE"
>>>>>>> c820f41f (Adding KernelAbstractions tooling for Molly and tests)
else
@warn "The CUDA tests will not be run as a CUDA-enabled device is not available"
end

if run_rocm_tests
array_list = (array_list..., ROCArray)
AMDGPU.device!(AMDGPU.devices()[parse(Int, DEVICE)+1])
AMDGPU.device!(AMDGPU.device(DEVICE+1))
@info "The ROCM tests will be run on device $DEVICE"
else
@warn "The ROCM tests will not be run as a ROCM-enabled device is not available"
Expand Down

0 comments on commit fcdd072

Please sign in to comment.