Skip to content

Commit

Permalink
Merge pull request #147 from climate-machine/isbitstype-abstractions
Browse files Browse the repository at this point in the history
Parameterized abstractions that work on CPU and GPU architectures.

Former-commit-id: 1594d9e
  • Loading branch information
ali-ramadhan committed Apr 3, 2019
2 parents 41be602 + 5890f7e commit 66627a8
Show file tree
Hide file tree
Showing 27 changed files with 1,118 additions and 1,140 deletions.
68 changes: 42 additions & 26 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,29 @@ uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"

[[CUDAapi]]
deps = ["Libdl", "Logging", "Test"]
git-tree-sha1 = "e1f551ad1c03b3fa2a966794ead05772bff4b064"
git-tree-sha1 = "125122309a4387e0d18787cef0f03800fa57702a"
uuid = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3"
version = "0.6.0"
version = "0.6.3"

[[CUDAdrv]]
deps = ["CUDAapi", "Libdl", "Printf", "Test"]
git-tree-sha1 = "dfe527ba231b6b699f879d1d384c1d39b49fc005"
git-tree-sha1 = "3014fc9bab66af6646e476f86ff1f86f019fb869"
uuid = "c5f51814-7f29-56b8-a69c-e4d8f6be1fde"
version = "1.0.1"
version = "2.0.0"

[[CUDAnative]]
deps = ["Adapt", "CUDAapi", "CUDAdrv", "InteractiveUtils", "LLVM", "Libdl", "Pkg", "Printf", "Statistics", "Test"]
git-tree-sha1 = "92e3ec4f4458e43cc17be4388b68690dbef24f31"
deps = ["Adapt", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "Logging", "Pkg", "Printf", "TimerOutputs"]
git-tree-sha1 = "a3ef145ae18093aad134e03493e390f0eaf32363"
repo-rev = "master"
repo-url = "https://github.com/JuliaGPU/CUDAnative.jl.git"
uuid = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17"
version = "1.0.1"
version = "2.0.1+"

[[Cassette]]
deps = ["InteractiveUtils", "LinearAlgebra", "Test"]
git-tree-sha1 = "1d00c35118babf85c4a9a72c3d3550d498b64a03"
uuid = "7057c7e9-c182-5462-911a-8362d720325c"
version = "0.2.2"

[[CommonSubexpressions]]
deps = ["Test"]
Expand All @@ -80,9 +88,9 @@ version = "0.2.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "195a3ffcb8b0762684b6821de18f83a16455c6ea"
git-tree-sha1 = "84aa74986c5b9b898b0d1acaf3258741ee64754f"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "2.0.0"
version = "2.1.0"

[[Conda]]
deps = ["Compat", "JSON", "VersionParsing"]
Expand All @@ -98,15 +106,21 @@ version = "0.1.0"

[[Crayons]]
deps = ["Test"]
git-tree-sha1 = "416737eea5c50ee5a08c588ea73d77d5eebc94e7"
git-tree-sha1 = "f621b8ef51fd2004c7cf157ea47f027fdeac5523"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "3.0.0"
version = "4.0.0"

[[CuArrays]]
deps = ["AbstractFFTs", "Adapt", "CUDAapi", "CUDAdrv", "CUDAnative", "DiffRules", "ForwardDiff", "GPUArrays", "LinearAlgebra", "MacroTools", "NNlib", "Pkg", "Printf", "Random", "SparseArrays", "Test"]
git-tree-sha1 = "c1cd8792ca783987fcba2ed0d6b3b58176e6b13e"
deps = ["AbstractFFTs", "Adapt", "CUDAapi", "CUDAdrv", "CUDAnative", "DiffRules", "ForwardDiff", "GPUArrays", "LinearAlgebra", "MacroTools", "NNlib", "Pkg", "Printf", "Random", "SparseArrays", "Test", "TimerOutputs"]
git-tree-sha1 = "34f30ae1a027b0b2e01694bb1b91003d7a9d5fc5"
uuid = "3a865a2d-5b23-5a0f-bc46-62713ec82fae"
version = "0.9.1"
version = "1.0.1"

[[DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"]
git-tree-sha1 = "ca971f03e146cf144a9e2f2ce59674f5bf0e8038"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.15.0"

[[Dates]]
deps = ["Printf"]
Expand Down Expand Up @@ -140,9 +154,9 @@ version = "0.2.4"

[[FileIO]]
deps = ["Pkg", "Random", "Test"]
git-tree-sha1 = "c94b0787956629036fb2b20fccde9e52b89d079a"
git-tree-sha1 = "da32159d4a2e526338506685e280e39ed2f18961"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.0.5"
version = "1.0.6"

[[FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "Test"]
Expand All @@ -169,10 +183,12 @@ uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
version = "0.6.1"

[[GPUifyLoops]]
deps = ["Pkg", "Requires", "StaticArrays", "Test"]
git-tree-sha1 = "8211bda31777c6822d00414c67f6c831d0062c48"
deps = ["Cassette", "Requires", "StaticArrays"]
git-tree-sha1 = "4b0bd8981df6da871c4e2c0c4fa34e113d4d90be"
repo-rev = "vc/interactive"
repo-url = "https://github.com/vchuravy/GPUifyLoops.jl.git"
uuid = "ba82f77b-6841-5d2e-bd9f-4daf811aec27"
version = "0.1.0"
version = "0.2.0"

[[HDF5]]
deps = ["BinDeps", "Blosc", "CRC32c", "Distributed", "Homebrew", "Libdl", "LinearAlgebra", "Mmap", "Pkg", "Test", "WinRPM"]
Expand Down Expand Up @@ -210,9 +226,9 @@ version = "0.20.0"

[[LLVM]]
deps = ["InteractiveUtils", "Libdl", "Printf", "Test", "Unicode"]
git-tree-sha1 = "d98bd8e6e56591caceb7db300a6877fb6daca6ba"
git-tree-sha1 = "d22678f75aca241f1e4b79093712aef264ad50fa"
uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
version = "1.0.0"
version = "1.1.0"

[[LegacyStrings]]
deps = ["Compat"]
Expand All @@ -221,10 +237,10 @@ uuid = "1b4a561d-cfcb-5daf-8433-43fcf8b4bea3"
version = "0.4.1"

[[LibCURL]]
deps = ["BinaryProvider", "Compat", "Libdl", "Printf"]
git-tree-sha1 = "6339c87cb76923a3cf947fcd213cbc364355c9c9"
deps = ["BinaryProvider", "Libdl", "Printf", "Test"]
git-tree-sha1 = "d051c8057512ca38a273aaa514145a0b25f24d46"
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.4.1"
version = "0.5.0"

[[LibExpat]]
deps = ["Compat"]
Expand Down Expand Up @@ -266,9 +282,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[NNlib]]
deps = ["Libdl", "LinearAlgebra", "MacroTools", "Requires", "Test"]
git-tree-sha1 = "51330bb45927379007e089997bf548fbe232589d"
git-tree-sha1 = "9ac5cd21484189339b27840818c4882d1b6df7fd"
uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
version = "0.4.3"
version = "0.5.0"

[[NaNMath]]
deps = ["Compat"]
Expand Down
5 changes: 0 additions & 5 deletions docs/src/internal/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ FaceFieldX
FaceFieldY
FaceFieldZ
EdgeField
CellField(metadata::ModelMetadata, grid::Grid, T)
FaceFieldX(metadata::ModelMetadata, grid::Grid, T)
FaceFieldY(metadata::ModelMetadata, grid::Grid, T)
FaceFieldZ(metadata::ModelMetadata, grid::Grid, T)
EdgeField(metadata::ModelMetadata, grid::Grid, T)
```
1 change: 0 additions & 1 deletion docs/src/internal/grids.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Grids
```@docs
RegularCartesianGrid
RegularCartesianGrid(metadata::ModelMetadata, N, L)
```
10 changes: 4 additions & 6 deletions examples/deep_convection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ function impose_cooling_disk!(model::Model)
# until we can figure out the best way of imposing forcings with complex
# geometries, probably by being able to define, e.g. a forcing only at the
# top, etc.
@inline function cooling_disk(u, v, w, T, S, Nx, Ny, Nz, Δx, Δy, Δz, i, j, k)
@inine function cooling_disk(grid, u, v, w, T, S, i, j, k)
if k == 1
x = i*Δx
y = j*Δy
Lx = Nx*Δx
Ly = Ny*Δy
= (x - Lx/2)^2 + (y - Ly/2)^2
x = i*grid.Δx
y = j*grid.Δy
= (x - grid.Lx/2)^2 + (y - grid.Ly/2)^2
if< 600^2
return -4.5e-6
else
Expand Down
27 changes: 19 additions & 8 deletions src/Oceananigans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module Oceananigans
export
# Helper variables and macros for determining if machine is CUDA-enabled.
HAVE_CUDA,
hascuda,
@hascuda,

Architecture,
CPU,
GPU,
device,

# Planetary Constants
ConstantsCollection,
Expand Down Expand Up @@ -56,17 +61,15 @@ export
# Poisson solver
PoissonSolver,
PoissonSolverGPU,
init_poisson_solver,
solve_poisson_3d_ppn,
solve_poisson_3d_ppn!,
solve_poisson_3d_ppn_planned!,
solve_poisson_3d_ppn_gpu!,
solve_poisson_3d_ppn_gpu_planned!,

# Model helper structs, e.g. metadata, configuration, clock, etc.
ModelMetadata,
_ModelMetadata,
# Model helper structs, e.g. configuration, clock, etc.
ModelConfiguration,
_ModelConfiguration,
Clock,
Model,

Expand All @@ -89,17 +92,19 @@ export
# Package utilities
prettytime

# Standard library modules
using
Statistics,
Printf

# Third-party modules
using
FFTW,
JLD,
NetCDF,
StaticArrays

using
import
GPUifyLoops

const HAVE_CUDA = try
Expand All @@ -113,14 +118,21 @@ macro hascuda(ex)
return HAVE_CUDA ? :($(esc(ex))) : :(nothing)
end

abstract type Architecture end
struct CPU <: Architecture end
struct GPU <: Architecture end

device(::CPU) = GPUifyLoops.CPU()
device(::GPU) = GPUifyLoops.CUDA()

@hascuda begin
println("CUDA-enabled GPU(s) detected:")
for (gpu, dev) in enumerate(CUDAnative.devices())
println(dev)
end
end

@hascuda CuArrays.allowscalar(false)
# @hascuda CuArrays.allowscalar(false)

abstract type Metadata end
abstract type ConstantsCollection end
Expand All @@ -133,7 +145,6 @@ abstract type OutputWriter end
abstract type Diagnostic end
abstract type AbstractPoissonSolver end

include("model_metadata.jl")
include("model_configuration.jl")
include("clock.jl")
include("planetary_constants.jl")
Expand Down
Loading

0 comments on commit 66627a8

Please sign in to comment.