diff --git a/ext/JustPICAMDGPUExt.jl b/ext/JustPICAMDGPUExt.jl index 10e680d..37eb1a7 100644 --- a/ext/JustPICAMDGPUExt.jl +++ b/ext/JustPICAMDGPUExt.jl @@ -17,8 +17,13 @@ function AMDGPU.ROCArray(::Type{T}, particles::JustPIC.Particles) where {T<:Numb end function AMDGPU.ROCArray(::Type{T}, phase_ratios::JustPIC.PhaseRatios) where {T<:Number} - (; vertex, center) = phase_ratios - return JustPIC.PhaseRatios(AMDGPUBackend, ROCArray(T, center), ROCArray(T, vertex)) + (; center, vertex, Vx, Vy, Vz, yz, xz, xy) = phase_ratios + return JustPIC.PhaseRatios(AMDGPUBackend, ROCArray(T, center), ROCArray(T, vertex), ROCArray(T, Vx), ROCArray(T, Vy), ROCArray(T, Vz), ROCArray(T, yz), ROCArray(T, xz), ROCArray(T, xy)) +end + +function AMDGPU.ROCArray(phase_ratios::JustPIC.PhaseRatios) + (; center, vertex, Vx, Vy, Vz, yz, xz, xy) = phase_ratios + return JustPIC.PhaseRatios(AMDGPUBackend, ROCArray(center), ROCArray(vertex), ROCArray(Vx), ROCArray(Vy), ROCArray(Vz), ROCArray(yz), ROCArray(xz), ROCArray(xy)) end function AMDGPU.ROCArray(particles::JustPIC.Particles) @@ -87,7 +92,7 @@ module _2D # Conversions function JustPIC._2D.Particles( coords, - index::CellArray{StaticArraysCore.SVector{N1,Bool},3,0, ROCArray{Bool,N2}}, + index::CellArray{StaticArraysCore.SVector{N1,Bool},2,0, ROCArray{Bool,N2}}, nxcell, max_xcell, min_xcell, @@ -98,7 +103,7 @@ module _2D function JustPIC._2D.Particles( coords, - index::CellArray{StaticArraysCore.SVector{N1,Bool},3,0,ROCArray{Bool,N2, B}}, + index::CellArray{StaticArraysCore.SVector{N1,Bool},2,0,ROCArray{Bool,N2, B}}, nxcell, max_xcell, min_xcell, diff --git a/ext/JustPICCUDAExt.jl b/ext/JustPICCUDAExt.jl index 486c83e..c856cb1 100644 --- a/ext/JustPICCUDAExt.jl +++ b/ext/JustPICCUDAExt.jl @@ -15,8 +15,13 @@ function CUDA.CuArray(::Type{T}, particles::JustPIC.Particles) where {T<:Number} end function CUDA.CuArray(::Type{T}, phase_ratios::JustPIC.PhaseRatios) where {T<:Number} - (; vertex, center) = phase_ratios - return JustPIC.PhaseRatios(CUDABackend, CuArray(T, center), CuArray(T, vertex)) + (; center, vertex, Vx, Vy, Vz, yz, xz, xy) = phase_ratios + return JustPIC.PhaseRatios(CUDABackend, CuArray(T, center), CuArray(T, vertex), CuArray(T, Vx), CuArray(T, Vy), CuArray(T, Vz), CuArray(T, yz), CuArray(T, xz), CuArray(T, xy)) +end + +function CUDA.CuArray(phase_ratios::JustPIC.PhaseRatios) + (; center, vertex, Vx, Vy, Vz, yz, xz, xy) = phase_ratios + return JustPIC.PhaseRatios(CUDABackend, CuArray(center), CuArray(vertex), CuArray(Vx), CuArray(Vy), CuArray(Vz), CuArray(yz), CuArray(xz), CuArray(xy)) end function CUDA.CuArray(particles::JustPIC.Particles) @@ -25,11 +30,6 @@ function CUDA.CuArray(particles::JustPIC.Particles) return Particles(CUDABackend, coords_gpu, CuArray(index), nxcell, max_xcell, min_xcell, np) end -function CUDA.CuArray(phase_ratios::JustPIC.PhaseRatios) - (; vertex, center) = phase_ratios - return JustPIC.PhaseRatios(CUDABackend, CuArray(center), CuArray(vertex)) -end - function CUDA.CuArray(::Type{T}, CA::CellArray) where {T<:Number} ni = size(CA) # Array initializations @@ -87,7 +87,7 @@ module _2D # Conversions function JustPIC._2D.Particles( coords, - index::CellArray{StaticArraysCore.SVector{N1,Bool},3,0, CuArray{Bool,N2}}, + index::CellArray{StaticArraysCore.SVector{N1,Bool},2,0, CuArray{Bool,N2}}, nxcell, max_xcell, min_xcell, @@ -98,7 +98,7 @@ module _2D function JustPIC._2D.Particles( coords, - index::CellArray{StaticArraysCore.SVector{N1,Bool},3,0,CuArray{Bool,N2, B}}, + index::CellArray{StaticArraysCore.SVector{N1,Bool},2,0,CuArray{Bool,N2, B}}, nxcell, max_xcell, min_xcell, diff --git a/test/runtests.jl b/test/runtests.jl index 8a9e6d8..5869e77 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,6 +44,7 @@ function runtests() include("test_2D.jl") include("test_integrators.jl") include("test_CellArrays.jl") + include("test_save_load.jl") catch nfail +=1 end @@ -79,6 +80,9 @@ function runtests() end end end + + # Force IO test on GPU + run(`$(Base.julia_cmd()) --startup-file=no $(joinpath(testdir, "test_save_load.jl"))`) end return nfail diff --git a/test/test_save_load.jl b/test/test_save_load.jl index 8bc2d84..5342c7e 100644 --- a/test/test_save_load.jl +++ b/test/test_save_load.jl @@ -1,6 +1,15 @@ -using JLD2, JustPIC +@static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU" + using AMDGPU +elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA" + using CUDA +end + +using JLD2, JustPIC, Test import JustPIC._2D as JP2 import JustPIC._3D as JP3 + +const backend = JustPIC.CPUBackend + @testset "Save and load 2D" begin # Initialize particles ------------------------------- nxcell, max_xcell, min_xcell = 6, 6, 6 @@ -18,24 +27,24 @@ import JustPIC._3D as JP3 @views particles.index.data[:, 4:6, 1] .= 0.0 # test type conversion - @test eltype(eltype(JP2.Array(phases))) === Float64 - @test eltype(eltype(JP2.Array(Float64, phases))) === Float64 - @test eltype(eltype(JP2.Array(Float32, phases))) === Float32 - @test eltype(eltype(JP2.Array(particles).coords[1].data)) === Float64 - @test eltype(eltype(JP2.Array(Float64, particles).coords[1].data)) === Float64 - @test eltype(eltype(JP2.Array(Float32, particles).coords[1].data)) === Float32 - @test eltype(eltype(JP2.Array(particles).index.data)) === Bool - @test eltype(eltype(JP2.Array(Float32, particles).index.data)) === Bool - @test eltype(eltype(JP2.Array(Float64, particles).index.data)) === Bool - @test eltype(eltype(JP2.Array(phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(JP2.Array(Float64, phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(JP2.Array(Float32, phase_ratios).vertex.data)) === Float32 + @test eltype(eltype(Array(phases))) === Float64 + @test eltype(eltype(Array(Float64, phases))) === Float64 + @test eltype(eltype(Array(Float32, phases))) === Float32 + @test eltype(eltype(Array(particles).coords[1].data)) === Float64 + @test eltype(eltype(Array(Float64, particles).coords[1].data)) === Float64 + @test eltype(eltype(Array(Float32, particles).coords[1].data)) === Float32 + @test eltype(eltype(Array(particles).index.data)) === Bool + @test eltype(eltype(Array(Float32, particles).index.data)) === Bool + @test eltype(eltype(Array(Float64, particles).index.data)) === Bool + @test eltype(eltype(Array(phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(Array(Float64, phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(Array(Float32, phase_ratios).vertex.data)) === Float32 jldsave( "particles.jld2"; - particles = JP2.Array(particles), - phases = JP2.Array(phases), - phase_ratios = JP2.Array(phase_ratios) + particles = Array(particles), + phases = Array(phases), + phase_ratios = Array(phase_ratios) ) data = load("particles.jld2") @@ -43,78 +52,58 @@ import JustPIC._3D as JP3 phases2 = data["phases"] phase_ratios2 = data["phase_ratios"] - @test JP2.Array(particles).coords[1].data == particles2.coords[1].data - @test JP2.Array(particles).coords[2].data == particles2.coords[2].data - @test JP2.Array(particles).index.data == particles2.index.data - @test JP2.Array(phase_ratios).center.data == phase_ratios2.center.data - @test JP2.Array(phase_ratios).vertex.data == phase_ratios2.vertex.data - @test JP2.Array(phases).data == phases2.data - @test size(JP2.Array(particles).coords[1].data) == size(particles2.coords[1].data) - @test size(JP2.Array(particles).coords[2].data) == size(particles2.coords[2].data) - @test size(JP2.Array(particles).index.data) == size(particles2.index.data) - @test size(JP2.Array(phase_ratios).center.data) == size(phase_ratios2.center.data) - @test size(JP2.Array(phase_ratios).vertex.data) == size(phase_ratios2.vertex.data) - @test size(JP2.Array(phases).data) == size(phases2.data) - - if isdefined(Main, :CUDA) - particles_cuda = CuArray(particles2) - phase_ratios_cuda = CuArray(phase_ratios2) - phases_cuda = CuArray(phases2); - - @test particles_cuda isa JustPIC.Particles{CUDABackend} - @test phase_ratios_cuda isa JustPIC.PhaseRatios{CUDABackend} - @test last(typeof(phases_cuda).parameters) <: CuArray{Float64, 3} - @test typeof(phases_cuda) == typeof(phases) - @test size(particles_cuda.coords[1].data) == size(particles.coords[1].data) - @test size(particles_cuda.coords[2].data) == size(particles.coords[2].data) - @test size(particles_cuda.index.data) == size(particles.index.data) - @test size(phase_ratios_cuda.center.data) == size(phase_ratios.center.data) - @test size(phase_ratios_cuda.vertex.data) == size(phase_ratios.vertex.data) - @test size(phases_cuda.data) == size(phases.data) - - # test type conversion - @test eltype(eltype(CuArray(phases))) === Float64 - @test eltype(eltype(CuArray(Float64, phases))) === Float64 - @test eltype(eltype(CuArray(Float32, phases))) === Float32 - @test eltype(eltype(CuArray(particles).coords[1].data)) === Float64 - @test eltype(eltype(CuArray(Float64, particles).coords[1].data)) === Float64 - @test eltype(eltype(CuArray(Float32, particles).coords[1].data)) === Float32 - @test eltype(eltype(CuArray(phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(CuArray(Float64, phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(CuArray(Float32, phase_ratios).vertex.data)) === Float32 - @test eltype(eltype(CuArray(particles).index.data)) === Bool - @test eltype(eltype(CuArray(Float32, particles).index.data)) === Bool - @test eltype(eltype(CuArray(Float64, particles).index.data)) === Bool - - elseif isdefined(Main, :AMDGPU) - particles_amdgpu = ROCArray(particles2) - phase_ratios_amdgpu = ROCArray(phase_ratios2) - phases_amdgpu = ROCArray(phases2) - - @test particles_amdgpu isa JustPIC.Particles{AMDGPUBackend} - @test phase_ratios_amdgpu isa JustPIC.PhaseRatios{AMDGPUBackend} - @test last(typeof(phases_amdgpu).parameters) <: ROCArray{Float64, 3} - @test typeof(phases_amdgpu) == typeof(phases) - @test size(particles_amdgpu.coords[1].data) == size(particles.coords[1].data) - @test size(particles_amdgpu.coords[2].data) == size(particles.coords[2].data) - @test size(particles_amdgpu.index.data) == size(particles.index.data) - @test size(phase_ratios_amdgpu.center.data) == size(phase_ratios.center.data) - @test size(phase_ratios_amdgpu.vertex.data) == size(phase_ratios.vertex.data) - @test size(phases_amdgpu.data) == size(phases.data) + @test Array(particles).coords[1].data == particles2.coords[1].data + @test Array(particles).coords[2].data == particles2.coords[2].data + @test Array(particles).index.data == particles2.index.data + @test Array(phase_ratios).center.data == phase_ratios2.center.data + @test Array(phase_ratios).vertex.data == phase_ratios2.vertex.data + @test Array(phases).data == phases2.data + @test size(Array(particles).coords[1].data) == size(particles2.coords[1].data) + @test size(Array(particles).coords[2].data) == size(particles2.coords[2].data) + @test size(Array(particles).index.data) == size(particles2.index.data) + @test size(Array(phase_ratios).center.data) == size(phase_ratios2.center.data) + @test size(Array(phase_ratios).vertex.data) == size(phase_ratios2.vertex.data) + @test size(Array(phases).data) == size(phases2.data) + + # Test on GPU card, if available + isCUDA = isdefined(Main, :CUDA) + isAMDGPU = isdefined(Main, :AMDGPU) + + if isCUDA || isAMDGPU + T = isCUDA ? CuArray : ROCArray + Backend = isCUDA ? CUDABackend : AMDGPUBackend + + particles2 = Array(particles) + phases2 = Array(phases) + phase_ratios2 = Array(phase_ratios) + + particles_gpu = T(particles2) + phase_ratios_gpu = T(phase_ratios2) + phases_gpu = T(phases2); + + @test particles_gpu isa JustPIC.Particles{Backend} + @test phase_ratios_gpu isa JustPIC.PhaseRatios{Backend} + @test last(typeof(phases_gpu).parameters) <: T{Float64, 3} + @test size(particles_gpu.coords[1].data) == size(permutedims(particles.coords[1].data, (3, 2, 1))) + @test size(particles_gpu.coords[2].data) == size(permutedims(particles.coords[2].data, (3, 2, 1))) + @test size(particles_gpu.index.data) == size(permutedims(particles.index.data, (3, 2, 1))) + @test size(phase_ratios_gpu.center.data) == size(permutedims(phase_ratios.center.data, (3, 2, 1))) + @test size(phase_ratios_gpu.vertex.data) == size(permutedims(phase_ratios.vertex.data, (3, 2, 1))) + @test size(phases_gpu.data) == size(permutedims(phases.data, (3, 2, 1))) # test type conversion - @test eltype(eltype(ROCArray(phases))) === Float64 - @test eltype(eltype(ROCArray(Float64, phases))) === Float64 - @test eltype(eltype(ROCArray(Float32, phases))) === Float32 - @test eltype(eltype(ROCArray(particles).coords[1].data)) === Float64 - @test eltype(eltype(ROCArray(Float64, particles).coords[1].data)) === Float64 - @test eltype(eltype(ROCArray(Float32, particles).coords[1].data)) === Float32 - @test eltype(eltype(ROCArray(phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(ROCArray(Float64, phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(ROCArray(Float32, phase_ratios).vertex.data)) === Float32 - @test eltype(eltype(ROCArray(particles).index.data)) === Bool - @test eltype(eltype(ROCArray(Float32, particles).index.data)) === Bool - @test eltype(eltype(ROCArray(Float64, particles).index.data)) === Bool + @test eltype(eltype(T(phases))) === Float64 + @test eltype(eltype(T(Float64, phases))) === Float64 + @test eltype(eltype(T(Float32, phases))) === Float32 + @test eltype(eltype(T(particles).coords[1].data)) === Float64 + @test eltype(eltype(T(Float64, particles).coords[1].data)) === Float64 + @test eltype(eltype(T(Float32, particles).coords[1].data)) === Float32 + @test eltype(eltype(T(phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(T(Float64, phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(T(Float32, phase_ratios).vertex.data)) === Float32 + @test eltype(eltype(T(particles).index.data)) === Bool + @test eltype(eltype(T(Float32, particles).index.data)) === Bool + @test eltype(eltype(T(Float64, particles).index.data)) === Bool end rm("particles.jld2") # cleanup @@ -135,27 +124,27 @@ end phase_ratios = JP3.PhaseRatios(backend, 2, ni); # test type conversion - @test eltype(eltype(JP3.Array(phases))) === Float64 - @test eltype(eltype(JP3.Array(Float64, phases))) === Float64 - @test eltype(eltype(JP3.Array(Float32, phases))) === Float32 - @test eltype(eltype(JP3.Array(particles).coords[1].data)) === Float64 - @test eltype(eltype(JP3.Array(Float64, particles).coords[1].data)) === Float64 - @test eltype(eltype(JP3.Array(Float32, particles).coords[1].data)) === Float32 - @test eltype(eltype(JP3.Array(phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(JP3.Array(Float64, phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(JP3.Array(Float32, phase_ratios).vertex.data)) === Float32 - @test eltype(eltype(JP3.Array(particles).index.data)) === Bool - @test eltype(eltype(JP3.Array(Float32, particles).index.data)) === Bool - @test eltype(eltype(JP3.Array(Float64, particles).index.data)) === Bool + @test eltype(eltype(Array(phases))) === Float64 + @test eltype(eltype(Array(Float64, phases))) === Float64 + @test eltype(eltype(Array(Float32, phases))) === Float32 + @test eltype(eltype(Array(particles).coords[1].data)) === Float64 + @test eltype(eltype(Array(Float64, particles).coords[1].data)) === Float64 + @test eltype(eltype(Array(Float32, particles).coords[1].data)) === Float32 + @test eltype(eltype(Array(phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(Array(Float64, phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(Array(Float32, phase_ratios).vertex.data)) === Float32 + @test eltype(eltype(Array(particles).index.data)) === Bool + @test eltype(eltype(Array(Float32, particles).index.data)) === Bool + @test eltype(eltype(Array(Float64, particles).index.data)) === Bool particles.index.data[:, 1:3, 1] .= 1.0 particles.index.data[:, 4:6, 1] .= 0.0 jldsave( "particles.jld2"; - particles = JP3.Array(particles), - phases = JP3.Array(phases), - phase_ratios = JP3.Array(phase_ratios) + particles = Array(particles), + phases = Array(phases), + phase_ratios = Array(phase_ratios) ) data = load("particles.jld2") @@ -163,80 +152,58 @@ end phases2 = data["phases"] phase_ratios2 = data["phase_ratios"] - @test JP3.Array(particles).coords[1].data == particles2.coords[1].data - @test JP3.Array(particles).coords[2].data == particles2.coords[2].data - @test JP3.Array(particles).index.data == particles2.index.data - @test JP3.Array(phase_ratios).center.data == phase_ratios2.center.data - @test JP3.Array(phase_ratios).vertex.data == phase_ratios2.vertex.data - @test JP3.Array(phases).data == phases2.data - @test size(JP3.Array(particles).coords[1].data) == size(particles2.coords[1].data) - @test size(JP3.Array(particles).coords[2].data) == size(particles2.coords[2].data) - @test size(JP3.Array(particles).index.data) == size(particles2.index.data) - @test size(JP3.Array(phase_ratios).center.data) == size(phase_ratios2.center.data) - @test size(JP3.Array(phase_ratios).vertex.data) == size(phase_ratios2.vertex.data) - @test size(JP3.Array(phases).data) == size(phases2.data) - - if isdefined(Main, :CUDA) - particles_cuda = CuArray(particles2) - phase_ratios_cuda = CuArray(phase_ratios2) - phases_cuda = CuArray(phases2); - - @test particles_cuda isa JustPIC.Particles{CUDABackend} - @test phase_ratios_cuda isa JustPIC.PhaseRatios{CUDABackend} - @test last(typeof(phases_cuda).parameters) <: CuArray{Float64, 3} - @test typeof(phases_cuda) == typeof(phases) - @test size(particles_cuda.coords[1].data) == size(particles.coords[1].data) - @test size(particles_cuda.coords[2].data) == size(particles.coords[2].data) - @test size(particles_cuda.index.data) == size(particles.index.data) - @test size(phase_ratios_cuda.center.data) == size(phase_ratios.center.data) - @test size(phase_ratios_cuda.vertex.data) == size(phase_ratios.vertex.data) - @test size(phases_cuda.data) == size(phases.data) + @test Array(particles).coords[1].data == particles2.coords[1].data + @test Array(particles).coords[2].data == particles2.coords[2].data + @test Array(particles).index.data == particles2.index.data + @test Array(phase_ratios).center.data == phase_ratios2.center.data + @test Array(phase_ratios).vertex.data == phase_ratios2.vertex.data + @test Array(phases).data == phases2.data + @test size(Array(particles).coords[1].data) == size(particles2.coords[1].data) + @test size(Array(particles).coords[2].data) == size(particles2.coords[2].data) + @test size(Array(particles).index.data) == size(particles2.index.data) + @test size(Array(phase_ratios).center.data) == size(phase_ratios2.center.data) + @test size(Array(phase_ratios).vertex.data) == size(phase_ratios2.vertex.data) + @test size(Array(phases).data) == size(phases2.data) + + # Test on GPU card, if available + isCUDA = isdefined(Main, :CUDA) + isAMDGPU = isdefined(Main, :AMDGPU) + + if isCUDA || isAMDGPU + T = isCUDA ? CuArray : ROCArray + Backend = isCUDA ? CUDABackend : AMDGPUBackend + + particles2 = Array(particles) + phases2 = Array(phases) + phase_ratios2 = Array(phase_ratios) + particles_gpu = T(particles2) + phase_ratios_gpu = T(phase_ratios2) + phases_gpu = T(phases2); + + @test particles_gpu isa JustPIC.Particles{Backend} + @test phase_ratios_gpu isa JustPIC.PhaseRatios{Backend} + @test last(typeof(phases_gpu).parameters) <: T{Float64, 3} + @test size(particles_gpu.coords[1].data) == size(permutedims(particles.coords[1].data, (3, 2, 1))) + @test size(particles_gpu.coords[2].data) == size(permutedims(particles.coords[2].data, (3, 2, 1))) + @test size(particles_gpu.index.data) == size(permutedims(particles.index.data, (3, 2, 1))) + @test size(phase_ratios_gpu.center.data) == size(permutedims(phase_ratios.center.data, (3, 2, 1))) + @test size(phase_ratios_gpu.vertex.data) == size(permutedims(phase_ratios.vertex.data, (3, 2, 1))) + @test size(phases_gpu.data) == size(permutedims(phases.data, (3, 2, 1))) # test type conversion - @test eltype(eltype(CuArray(phases))) === Float64 - @test eltype(eltype(CuArray(Float64, phases))) === Float64 - @test eltype(eltype(CuArray(Float32, phases))) === Float32 - @test eltype(eltype(CuArray(particles).coords[1].data)) === Float64 - @test eltype(eltype(CuArray(Float64, particles).coords[1].data)) === Float64 - @test eltype(eltype(CuArray(Float32, particles).coords[1].data)) === Float32 - @test eltype(eltype(CuArray(phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(CuArray(Float64, phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(CuArray(Float32, phase_ratios).vertex.data)) === Float32 - @test eltype(eltype(CuArray(particles).index.data)) === Bool - @test eltype(eltype(CuArray(Float32, particles).index.data)) === Bool - @test eltype(eltype(CuArray(Float64, particles).index.data)) === Bool - - elseif isdefined(Main, :AMDGPU) - particles_amdgpu = JP3.ROCArray(particles2) - phase_ratios_amdgpu = JP3.ROCArray(phase_ratios2) - phases_amdgpu = JP3.ROCArray(phases2) - - @test particles_amdgpu isa JustPIC.Particles{AMDGPUBackend} - @test phase_ratios_amdgpu isa JustPIC.PhaseRatios{AMDGPUBackend} - @test last(typeof(phases_amdgpu).parameters) <: ROCArray{Float64, 3} - @test typeof(phases_amdgpu) == typeof(phases) - @test size(particles_amdgpu.coords[1].data) == size(particles.coords[1].data) - @test size(particles_amdgpu.coords[2].data) == size(particles.coords[2].data) - @test size(particles_amdgpu.index.data) == size(particles.index.data) - @test size(phase_ratios_amdgpu.center.data) == size(phase_ratios.center.data) - @test size(phase_ratios_amdgpu.vertex.data) == size(phase_ratios.vertex.data) - @test size(phases_amdgpu.data) == size(phases.data) - - # test type conversion - @test eltype(eltype(ROCArray(phases))) === Float64 - @test eltype(eltype(ROCArray(Float64, phases))) === Float64 - @test eltype(eltype(ROCArray(Float32, phases))) === Float32 - @test eltype(eltype(ROCArray(particles).coords[1].data)) === Float64 - @test eltype(eltype(ROCArray(Float64, particles).coords[1].data)) === Float64 - @test eltype(eltype(ROCArray(Float32, particles).coords[1].data)) === Float32 - @test eltype(eltype(ROCArray(phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(ROCArray(Float64, phase_ratios).vertex.data)) === Float64 - @test eltype(eltype(ROCArray(Float32, phase_ratios).vertex.data)) === Float32 - @test eltype(eltype(ROCArray(particles).index.data)) === Bool - @test eltype(eltype(ROCArray(Float32, particles).index.data)) === Bool - @test eltype(eltype(ROCArray(Float64, particles).index.data)) === Bool - - end + @test eltype(eltype(T(phases))) === Float64 + @test eltype(eltype(T(Float64, phases))) === Float64 + @test eltype(eltype(T(Float32, phases))) === Float32 + @test eltype(eltype(T(particles).coords[1].data)) === Float64 + @test eltype(eltype(T(Float64, particles).coords[1].data)) === Float64 + @test eltype(eltype(T(Float32, particles).coords[1].data)) === Float32 + @test eltype(eltype(T(phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(T(Float64, phase_ratios).vertex.data)) === Float64 + @test eltype(eltype(T(Float32, phase_ratios).vertex.data)) === Float32 + @test eltype(eltype(T(particles).index.data)) === Bool + @test eltype(eltype(T(Float32, particles).index.data)) === Bool + @test eltype(eltype(T(Float64, particles).index.data)) === Bool + end rm("particles.jld2") # cleanup -end \ No newline at end of file +end