From 13f3472f1809bcb68558984829256312ec222ddb Mon Sep 17 00:00:00 2001 From: Navid Constantinou Date: Sat, 6 Mar 2021 11:05:21 +1100 Subject: [PATCH 1/5] CUDA.@allowscalar is not just for tests --- src/utils.jl | 6 +++--- test/test_utils.jl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index b6cfed74..a41342d4 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -248,16 +248,16 @@ end Returns an array, of the ArrayType of the device `grid` lives on, that contains the values of function `func` evaluated on the `grid`. """ -on_grid(func, grid::OneDGrid) = @. func(grid.x) +on_grid(func, grid::OneDGrid) = CUDA.@allowscalar @. func(grid.x) function on_grid(func, grid::TwoDGrid) x, y = gridpoints(grid) - return func.(x, y) + return CUDA.@allowscalar func.(x, y) end function on_grid(func, grid::ThreeDGrid) x, y, z = gridpoints(grid) - return func.(x, y, z) + return CUDA.@allowscalar func.(x, y, z) end """ diff --git a/test/test_utils.jl b/test/test_utils.jl index 198605ae..f847d0d5 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -157,5 +157,5 @@ function test_ongrid(dev::Device) X₃, Y₃, Z₃ = gridpoints(g₃) f₃(x, y, z) = x^2 - y^3 + sin(z) - return CUDA.@allowscalar (FourierFlows.on_grid(f₁, g₁) == f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃)) + return (FourierFlows.on_grid(f₁, g₁) == f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃)) end From 17cc1274a102af5cfd2a34078f9e602148373575 Mon Sep 17 00:00:00 2001 From: Navid Constantinou Date: Sat, 6 Mar 2021 14:55:30 +1100 Subject: [PATCH 2/5] but tests need CUDA.@allowscalar also --- 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 f847d0d5..afdfb9fa 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -157,5 +157,5 @@ function test_ongrid(dev::Device) X₃, Y₃, Z₃ = gridpoints(g₃) f₃(x, y, z) = x^2 - y^3 + sin(z) - return (FourierFlows.on_grid(f₁, g₁) == f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃)) + return (FourierFlows.on_grid(f₁, g₁) == CUDA.@allowscalar f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) == CUDA.@allowscalar f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) == CUDA.@allowscalar f₃.(X₃, Y₃, Z₃)) end From bfadb0ff877bb0b2e7faa541841aabc0bfd9b6dc Mon Sep 17 00:00:00 2001 From: Navid Constantinou Date: Sat, 6 Mar 2021 15:01:33 +1100 Subject: [PATCH 3/5] unecessary CUDA.@allowscalar for x::Range --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index a41342d4..b4956445 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -248,7 +248,7 @@ end Returns an array, of the ArrayType of the device `grid` lives on, that contains the values of function `func` evaluated on the `grid`. """ -on_grid(func, grid::OneDGrid) = CUDA.@allowscalar @. func(grid.x) +on_grid(func, grid::OneDGrid) = func.(grid.x) function on_grid(func, grid::TwoDGrid) x, y = gridpoints(grid) From 435c99847b45f401d4cf9c245586d49f9564a75c Mon Sep 17 00:00:00 2001 From: Navid Constantinou Date: Sat, 6 Mar 2021 15:11:52 +1100 Subject: [PATCH 4/5] but what if 1D x is array? --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index b4956445..f64d7dd6 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -248,7 +248,7 @@ end Returns an array, of the ArrayType of the device `grid` lives on, that contains the values of function `func` evaluated on the `grid`. """ -on_grid(func, grid::OneDGrid) = func.(grid.x) +on_grid(func, grid::OneDGrid) = CUDA.@allowscalar func.(grid.x) function on_grid(func, grid::TwoDGrid) x, y = gridpoints(grid) From 9bf61749e6b7ae524ae26eda7388f848e0b8b362 Mon Sep 17 00:00:00 2001 From: Navid Constantinou Date: Sat, 6 Mar 2021 15:21:06 +1100 Subject: [PATCH 5/5] an attempt to finally generalize --- Project.toml | 2 +- README.md | 2 +- test/test_utils.jl | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 3cbcdd4b..ddd8a9d4 100644 --- a/Project.toml +++ b/Project.toml @@ -6,7 +6,7 @@ authors = ["Gregory L. Wagner ", "Navid C. Constantinou < description = "Tools for building fast, hackable, pseudospectral partial differential equation solvers on periodic domains." documentation = "https://fourierflows.github.io/FourierFlowsDocumentation/stable/" repository = "https://github.com/FourierFlows/FourierFlows.jl" -version = "0.6.11" +version = "0.6.12" [deps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" diff --git a/README.md b/README.md index e1475b56..5cd685d6 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ and [Navid C. Constantinou][] (@navidcy). The code is citable via [zenodo](https://zenodo.org). Please cite as: -> Navid C. Constantinou & Gregory L. Wagner. (2021). FourierFlows/FourierFlows.jl: FourierFlows v0.6.11 (Version v0.6.11). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724) +> Navid C. Constantinou & Gregory L. Wagner. (2021). FourierFlows/FourierFlows.jl: FourierFlows v0.6.12 (Version v0.6.12). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724) [Julia]: https://julialang.org/ diff --git a/test/test_utils.jl b/test/test_utils.jl index afdfb9fa..96ee4fc5 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -145,17 +145,17 @@ function test_ongrid(dev::Device) nx, ny, nz = 6, 8, 10 Lx, Ly, Lz = 2π, 2.0, 3.0 - g₁ = OneDGrid(nx, Lx) + g₁ = OneDGrid(dev, nx, Lx) X₁ = ArrayType(dev)(g₁.x) f₁(x) = x^2 - g₂ = TwoDGrid(nx, Lx, ny, Ly) + g₂ = TwoDGrid(dev, nx, Lx, ny, Ly) X₂, Y₂ = gridpoints(g₂) f₂(x, y) = x^2 - y^3 - g₃ = ThreeDGrid(nx, Lx, ny, Ly, nz, Lz) + g₃ = ThreeDGrid(dev, nx, Lx, ny, Ly, nz, Lz) X₃, Y₃, Z₃ = gridpoints(g₃) f₃(x, y, z) = x^2 - y^3 + sin(z) - return (FourierFlows.on_grid(f₁, g₁) == CUDA.@allowscalar f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) == CUDA.@allowscalar f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) == CUDA.@allowscalar f₃.(X₃, Y₃, Z₃)) + return (CUDA.@allowscalar FourierFlows.on_grid(f₁, g₁) == f₁.(X₁) && CUDA.@allowscalar FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && CUDA.@allowscalar FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃)) end