-
-
Save luraess/9b595f66ccdbacbbffa740d33ce772f7 to your computer and use it in GitHub Desktop.
Use struct in ParallelStencil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ParallelStencil | |
using ParallelStencil.FiniteDifferences2D | |
@init_parallel_stencil(CUDA, Float64, 2) | |
struct myStruct{T} | |
val::T | |
end | |
n = 20 | |
A = myStruct(@rand(n,n)) | |
B = similar(A.val) | |
@parallel_indices (i, j) function bar!(B, A) | |
B[i,j] = A.val[i,j] | |
return nothing | |
end | |
import Adapt | |
function Adapt.adapt_structure(to, A::myStruct) | |
val = Adapt.adapt_structure(to, A.val) | |
myStruct(val) | |
end | |
@parallel (1:n, 1:n) bar!(B, A) | |
@assert all(Array(A.val) .== Array(B)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment