Chmy.jl
Documentation for Chmy.jl
Information about the GPU4GEO project can be found on the GPU4GEO website
diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 6044abe6..4f092f5a 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-02-07T22:02:50","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-02-07T22:09:30","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 65dcfd24..aa97ca63 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -
Documentation for Chmy.jl
Information about the GPU4GEO project can be found on the GPU4GEO website
Settings
This document was generated with Documenter.jl version 1.2.1 on Wednesday 7 February 2024. Using Julia version 1.10.0.
Documentation for Chmy.jl
Information about the GPU4GEO project can be found on the GPU4GEO website
Settings
This document was generated with Documenter.jl version 1.2.1 on Wednesday 7 February 2024. Using Julia version 1.10.0.
Chmy.Grids.StructuredGrid
— Typestruct StructuredGrid{N,T,C,A}
Represents a structured grid with orthogonal axes.
Chmy.Grids.UniformGrid
— MethodUniformGrid(; origin, extent, dims, topology=nothing) where {N}
Constructs a uniform grid with specified origin, extent, dimensions, and topology.
Arguments
origin::NTuple{N,Number}
: The origin of the grid.extent::NTuple{N,Number}
: The extent of the grid.dims::NTuple{N,Integer}
: The dimensions of the grid.topology=nothing
: The topology of the grid. If not provided, a default Bounded
topology is used.Chmy.Grids.axis
— Methodaxis(grid::RegularGrid, ::Val{dim}) where {dim}
Return the axis corresponding to the spatial dimension dim
.
Chmy.Grids.bounds
— Methodbounds(grid::StructuredGrid{N}, loc::LocOrLocs{N}) where {N}
Compute the bounds of a structured grid at the specified location(s).
Chmy.Grids.connectivity
— Methodconnectivity(grid::StructuredGrid{N,T,C}, D::Val, S::Val)
Return the connectivity of the structured grid grid
for the given dimension D
and side S
.
Chmy.Grids.coord
— Methodcoord(grid::RegularGrid{N}, loc::[Location, NTuple{N,Location}], I...) where {N}
Return a tuple of spatial coordinates of a grid point at location loc
and indices I
.
For vertex locations, first grid point is at the origin. For center locations, first grid point at half-spacing distance from the origin.
Chmy.Grids.inv_spacing
— Methodinv_spacing(grid::RegularGrid{N}, loc::[Location, NTuple{N,Location}], I...) where {N}
Return a tuple of inverse grid spacings at location loc
and indices I
.
Chmy.Grids.spacing
— Methodspacing(grid::RegularGrid{N}, loc::[Location, NTuple{N,Location}], I...) where {N}
Return a tuple of grid spacings at location loc
and indices I
.
Chmy.Architectures.Architecture
— Typeabstract type Architecture
Abstract type representing an architecture.
Chmy.Architectures.SingleDeviceArchitecture
— Typestruct SingleDeviceArchitecture{B,D} <: Architecture
A struct representing an architecture that operates on a single CPU or GPU device.
Chmy.Architectures.Arch
— MethodArch(backend::Backend; device_id::Integer=1)
Create an architecture object for the specified backend and device.
Arguments
backend
: The backend to use for computation.device_id=1
: The ID of the device to use.Chmy.Architectures.activate!
— Methodactivate!(arch::SingleDeviceArchitecture; priority=:normal)
Activate the given architecture on the specified device and set the priority of the backend.
Chmy.Architectures.get_backend
— Methodget_backend(arch::SingleDeviceArchitecture)
Get the backend associated with a SingleDeviceArchitecture.
Chmy.Architectures.get_device
— Methodget_device(arch::SingleDeviceArchitecture)
Get the device associated with a SingleDeviceArchitecture.
Chmy.Fields.ConstantField
— TypeScalar field with a constant value
Chmy.Fields.Field
— Typestruct Field{T,N,L,H,A} <: AbstractField{T,N,L}
Field represents a discrete scalar field with specified type, number of dimensions, location, and halo size.
Chmy.Fields.Field
— MethodField(backend, grid, loc, type=eltype(grid); halo=1)
Constructs a field on a structured grid at the specified location.
Arguments:
backend
: The backend to use for memory allocation.grid
: The structured grid on which the field is constructed.loc
: The location or locations on the grid where the field is constructed.type
: The element type of the field. Defaults to the element type of the grid.halo
: The halo size for the field. Defaults to 1.Chmy.Fields.FunctionField
— Typestruct FunctionField{T,N,L,CD,F,G,P} <: AbstractField{T,N,L}
Continuous or discrete field with values computed at runtime.
Constructors
FunctionField{CD,L}(func::F, grid::G, parameters::P) where {CD,L,F,G,P}
: Create a new FunctionField
object.Chmy.Fields.OneField
— TypeConstant field with values equal to one(T)
Chmy.Fields.ValueField
— TypeField with a constant value
Chmy.Fields.ZeroField
— TypeConstant field with values equal to zero(T)
Chmy.GridOperators.δx
— Methodδx(f, loc, I)
Finite difference in x direction.
Chmy.GridOperators.δy
— Methodδy(f, loc, I)
Finite difference in y direction.
Chmy.GridOperators.δz
— Methodδz(f, loc, I)
Finite difference in z direction.
Chmy.GridOperators.∂x
— Method∂x(f, loc, grid, I)
Directional partial derivative in x direction.
Chmy.GridOperators.∂y
— Method∂y(f, loc, grid, I)
Directional partial derivative in y direction.
Chmy.GridOperators.∂z
— Method∂z(f, loc, grid, I)
Directional partial derivative in z direction.
Chmy.BoundaryConditions.AbstractBatch
— Typeabstract type AbstractBatch
Abstract type representing a batch of boundary conditions.
Chmy.BoundaryConditions.EmptyBatch
— Typestruct EmptyBatch <: AbstractBatch
EmptyBatch represents no boundary conditions.
Chmy.BoundaryConditions.bc!
— Methodbc!(arch::Architecture, grid::StructuredGrid, batch::BatchSet)
Apply boundary conditions using a batch set batch
containing an AbstractBatch
per dimension per side of grid
.
Arguments
arch
: The architecture.grid
: The grid.batch:
: The batch set to apply boundary conditions to.Chmy.Distributed.CartesianTopology
— TypeCartesianTopology
Represents N-dimensional Cartesian topology of distributed processes.
Chmy.Distributed.CartesianTopology
— MethodCartesianTopology(comm::MPI.Comm, dims::NTuple{N,Int}) where {N}
Create an N-dimensional Cartesian topology using base MPI communicator comm
with dimensions dims
. If all entries in dims
are not equal to 0
, the product of dims
should be equal to the total number of MPI processes MPI.Comm_size(comm)
. If any (or all) entries of dims
are 0
, the dimensions in the corresponding spatial directions will be picked automatically.
Chmy.Distributed.DistributedArchitecture
— Typestruct DistributedArchitecture{ChildArch,Topo}
A struct representing a distributed architecture.
Chmy.Distributed.StackAllocator
— Typemutable struct StackAllocator
Simple stack (a.k.a. bump/arena) allocator. Maintains an internal buffer that grows dynamically if the requested allocation exceeds current buffer size.
Chmy.Distributed.StackAllocator
— MethodStackAllocator(backend::Backend)
Create a stack allocator using the specified backend to store allocations.
Chmy.Architectures.Arch
— MethodArch(backend::Backend, comm::MPI::Comm, dims; kwargs...) where {N}
Create a distributed Architecture using backend backend
and comm
. For GPU backends, device will be selected automatically based on a process id within a node.
Chmy.Distributed.allocate
— Functionallocate(sa::StackAllocator, T::DataType, dims, [align=sizeof(T)])
Allocate a buffer of type T
with dimensions dims
using a stack allocator. The align
parameter specifies the alignment of the buffer elements.
Arguments
sa::StackAllocator
: The stack allocator object.T::DataType
: The data type of the requested allocation.dims
: The dimensions of the requested allocation.align::Integer
: The alignment of the allocated buffer in bytes.Chmy.Distributed.cart_comm
— Methodcart_comm(t::CartesianTopology)
MPI Cartesian communicator for the topology.
Chmy.Distributed.coords
— Methodcoords(t::CartesianTopology)
Coordinates of a current process within a Cartesian topology.
Chmy.Distributed.dims
— Methoddims(t::CartesianTopology)
Dimensions of the topology as NTuple.
Chmy.Distributed.gather!
— Methodgather!(arch::DistributedArchitecture, dst, src::Field; kwargs...)
Gather the interior of a field src
into a global array dst
.
Chmy.Distributed.gather!
— Methodgather!(dst::Union{AbstractArray{T,N},Nothing}, src::AbstractArray{T,N}, comm::MPI.Comm; root=0) where {T,N}
Gather local array src
into a global array dst
. Size of the global array size(dst)
should be equal to the product of the size of a local array size(src)
and the dimensions of a Cartesian communicator comm
. The array will be gathered on the process with id root
(root=0
by default). Note that the memory for a global array should be allocated only on the process with id root
, on other processes dst
can be set to nothing
.
Chmy.Distributed.global_rank
— Methodglobal_rank(t::CartesianTopology)
Global id of a process in a Cartesian topology.
Chmy.Distributed.global_size
— Methodglobal_size(t::CartesianTopology)
Total number of processes withing the topology.
Chmy.Distributed.has_neighbor
— Methodhas_neighbor(t::CartesianTopology, dim, side)
Returns true if there a neighbor process in spatial direction dim
on the side side
, or false otherwise.
Chmy.Distributed.nallocs
— Methodnallocs(sa::StackAllocator)
Get the number of allocations made by the given StackAllocator
.
Chmy.Distributed.neighbor
— Methodneighbor(t::CartesianTopology, dim, side)
Returns id of a neighbor process in spatial direction dim
on the side side
, if this neighbor exists, or MPI.PROC_NULL otherwise.
Chmy.Distributed.neighbors
— Methodneighbors(t::CartesianTopology)
Neighbors of a current process.
Returns NTuple containing process ids of the two immediate neighbors in each spatial direction, or MPI.PROC_NULL if no neighbor on a corresponding side.
Chmy.Distributed.node_name
— Methodnode_name(t::CartesianTopology)
Name of a node according to MPI.Get_processor_name()
.
Chmy.Distributed.node_size
— Methodnode_size(t::CartesianTopology)
Number of processes sharing the same node.
Chmy.Distributed.reset!
— Methodreset!(sa::StackAllocator)
Reset the stack allocator by resetting the pointer. Doesn't free the internal memory buffer.
Chmy.Distributed.shared_comm
— Methodshared_comm(t::CartesianTopology)
MPI communicator for the processes sharing the same node.
Chmy.Distributed.shared_rank
— Methodshared_rank(t::CartesianTopology)
Local id of a process within a single node. Can be used to set the GPU device.
Chmy.Workers.Worker
— Typemutable struct Worker{T}
A worker that performs tasks asynchronously.
Constructor
Worker{T}(; setup=nothing, teardown=nothing) where {T}
Constructs a new Worker
object.
Arguments
setup
: A function to be executed before the worker starts processing tasks. (optional)teardown
: A function to be executed after the worker finishes processing tasks. (optional)Settings
This document was generated with Documenter.jl version 1.2.1 on Wednesday 7 February 2024. Using Julia version 1.10.0.
Chmy.Grids.StructuredGrid
— Typestruct StructuredGrid{N,T,C,A}
Represents a structured grid with orthogonal axes.
Chmy.Grids.UniformGrid
— MethodUniformGrid(; origin, extent, dims, topology=nothing) where {N}
Constructs a uniform grid with specified origin, extent, dimensions, and topology.
Arguments
origin::NTuple{N,Number}
: The origin of the grid.extent::NTuple{N,Number}
: The extent of the grid.dims::NTuple{N,Integer}
: The dimensions of the grid.topology=nothing
: The topology of the grid. If not provided, a default Bounded
topology is used.Chmy.Grids.axis
— Methodaxis(grid::RegularGrid, ::Val{dim}) where {dim}
Return the axis corresponding to the spatial dimension dim
.
Chmy.Grids.bounds
— Methodbounds(grid::StructuredGrid{N}, loc::LocOrLocs{N}) where {N}
Compute the bounds of a structured grid at the specified location(s).
Chmy.Grids.connectivity
— Methodconnectivity(grid::StructuredGrid{N,T,C}, D::Val, S::Val)
Return the connectivity of the structured grid grid
for the given dimension D
and side S
.
Chmy.Grids.coord
— Methodcoord(grid::RegularGrid{N}, loc::[Location, NTuple{N,Location}], I...) where {N}
Return a tuple of spatial coordinates of a grid point at location loc
and indices I
.
For vertex locations, first grid point is at the origin. For center locations, first grid point at half-spacing distance from the origin.
Chmy.Grids.inv_spacing
— Methodinv_spacing(grid::RegularGrid{N}, loc::[Location, NTuple{N,Location}], I...) where {N}
Return a tuple of inverse grid spacings at location loc
and indices I
.
Chmy.Grids.spacing
— Methodspacing(grid::RegularGrid{N}, loc::[Location, NTuple{N,Location}], I...) where {N}
Return a tuple of grid spacings at location loc
and indices I
.
Chmy.Architectures.Architecture
— Typeabstract type Architecture
Abstract type representing an architecture.
Chmy.Architectures.SingleDeviceArchitecture
— Typestruct SingleDeviceArchitecture{B,D} <: Architecture
A struct representing an architecture that operates on a single CPU or GPU device.
Chmy.Architectures.Arch
— MethodArch(backend::Backend; device_id::Integer=1)
Create an architecture object for the specified backend and device.
Arguments
backend
: The backend to use for computation.device_id=1
: The ID of the device to use.Chmy.Architectures.activate!
— Methodactivate!(arch::SingleDeviceArchitecture; priority=:normal)
Activate the given architecture on the specified device and set the priority of the backend.
Chmy.Architectures.get_backend
— Methodget_backend(arch::SingleDeviceArchitecture)
Get the backend associated with a SingleDeviceArchitecture.
Chmy.Architectures.get_device
— Methodget_device(arch::SingleDeviceArchitecture)
Get the device associated with a SingleDeviceArchitecture.
Chmy.Fields.ConstantField
— TypeScalar field with a constant value
Chmy.Fields.Field
— Typestruct Field{T,N,L,H,A} <: AbstractField{T,N,L}
Field represents a discrete scalar field with specified type, number of dimensions, location, and halo size.
Chmy.Fields.Field
— MethodField(backend, grid, loc, type=eltype(grid); halo=1)
Constructs a field on a structured grid at the specified location.
Arguments:
backend
: The backend to use for memory allocation.grid
: The structured grid on which the field is constructed.loc
: The location or locations on the grid where the field is constructed.type
: The element type of the field. Defaults to the element type of the grid.halo
: The halo size for the field. Defaults to 1.Chmy.Fields.FunctionField
— Typestruct FunctionField{T,N,L,CD,F,G,P} <: AbstractField{T,N,L}
Continuous or discrete field with values computed at runtime.
Constructors
FunctionField{CD,L}(func::F, grid::G, parameters::P) where {CD,L,F,G,P}
: Create a new FunctionField
object.Chmy.Fields.OneField
— TypeConstant field with values equal to one(T)
Chmy.Fields.ValueField
— TypeField with a constant value
Chmy.Fields.ZeroField
— TypeConstant field with values equal to zero(T)
Chmy.GridOperators.δx
— Methodδx(f, loc, I)
Finite difference in x direction.
Chmy.GridOperators.δy
— Methodδy(f, loc, I)
Finite difference in y direction.
Chmy.GridOperators.δz
— Methodδz(f, loc, I)
Finite difference in z direction.
Chmy.GridOperators.∂x
— Method∂x(f, loc, grid, I)
Directional partial derivative in x direction.
Chmy.GridOperators.∂y
— Method∂y(f, loc, grid, I)
Directional partial derivative in y direction.
Chmy.GridOperators.∂z
— Method∂z(f, loc, grid, I)
Directional partial derivative in z direction.
Chmy.BoundaryConditions.AbstractBatch
— Typeabstract type AbstractBatch
Abstract type representing a batch of boundary conditions.
Chmy.BoundaryConditions.EmptyBatch
— Typestruct EmptyBatch <: AbstractBatch
EmptyBatch represents no boundary conditions.
Chmy.BoundaryConditions.bc!
— Methodbc!(arch::Architecture, grid::StructuredGrid, batch::BatchSet)
Apply boundary conditions using a batch set batch
containing an AbstractBatch
per dimension per side of grid
.
Arguments
arch
: The architecture.grid
: The grid.batch:
: The batch set to apply boundary conditions to.Chmy.Distributed.CartesianTopology
— TypeCartesianTopology
Represents N-dimensional Cartesian topology of distributed processes.
Chmy.Distributed.CartesianTopology
— MethodCartesianTopology(comm::MPI.Comm, dims::NTuple{N,Int}) where {N}
Create an N-dimensional Cartesian topology using base MPI communicator comm
with dimensions dims
. If all entries in dims
are not equal to 0
, the product of dims
should be equal to the total number of MPI processes MPI.Comm_size(comm)
. If any (or all) entries of dims
are 0
, the dimensions in the corresponding spatial directions will be picked automatically.
Chmy.Distributed.DistributedArchitecture
— Typestruct DistributedArchitecture{ChildArch,Topo}
A struct representing a distributed architecture.
Chmy.Distributed.StackAllocator
— Typemutable struct StackAllocator
Simple stack (a.k.a. bump/arena) allocator. Maintains an internal buffer that grows dynamically if the requested allocation exceeds current buffer size.
Chmy.Distributed.StackAllocator
— MethodStackAllocator(backend::Backend)
Create a stack allocator using the specified backend to store allocations.
Chmy.Architectures.Arch
— MethodArch(backend::Backend, comm::MPI::Comm, dims; kwargs...) where {N}
Create a distributed Architecture using backend backend
and comm
. For GPU backends, device will be selected automatically based on a process id within a node.
Chmy.Distributed.allocate
— Functionallocate(sa::StackAllocator, T::DataType, dims, [align=sizeof(T)])
Allocate a buffer of type T
with dimensions dims
using a stack allocator. The align
parameter specifies the alignment of the buffer elements.
Arguments
sa::StackAllocator
: The stack allocator object.T::DataType
: The data type of the requested allocation.dims
: The dimensions of the requested allocation.align::Integer
: The alignment of the allocated buffer in bytes.Chmy.Distributed.cart_comm
— Methodcart_comm(t::CartesianTopology)
MPI Cartesian communicator for the topology.
Chmy.Distributed.coords
— Methodcoords(t::CartesianTopology)
Coordinates of a current process within a Cartesian topology.
Chmy.Distributed.dims
— Methoddims(t::CartesianTopology)
Dimensions of the topology as NTuple.
Chmy.Distributed.gather!
— Methodgather!(arch::DistributedArchitecture, dst, src::Field; kwargs...)
Gather the interior of a field src
into a global array dst
.
Chmy.Distributed.gather!
— Methodgather!(dst::Union{AbstractArray{T,N},Nothing}, src::AbstractArray{T,N}, comm::MPI.Comm; root=0) where {T,N}
Gather local array src
into a global array dst
. Size of the global array size(dst)
should be equal to the product of the size of a local array size(src)
and the dimensions of a Cartesian communicator comm
. The array will be gathered on the process with id root
(root=0
by default). Note that the memory for a global array should be allocated only on the process with id root
, on other processes dst
can be set to nothing
.
Chmy.Distributed.global_rank
— Methodglobal_rank(t::CartesianTopology)
Global id of a process in a Cartesian topology.
Chmy.Distributed.global_size
— Methodglobal_size(t::CartesianTopology)
Total number of processes withing the topology.
Chmy.Distributed.has_neighbor
— Methodhas_neighbor(t::CartesianTopology, dim, side)
Returns true if there a neighbor process in spatial direction dim
on the side side
, or false otherwise.
Chmy.Distributed.nallocs
— Methodnallocs(sa::StackAllocator)
Get the number of allocations made by the given StackAllocator
.
Chmy.Distributed.neighbor
— Methodneighbor(t::CartesianTopology, dim, side)
Returns id of a neighbor process in spatial direction dim
on the side side
, if this neighbor exists, or MPI.PROC_NULL otherwise.
Chmy.Distributed.neighbors
— Methodneighbors(t::CartesianTopology)
Neighbors of a current process.
Returns NTuple containing process ids of the two immediate neighbors in each spatial direction, or MPI.PROC_NULL if no neighbor on a corresponding side.
Chmy.Distributed.node_name
— Methodnode_name(t::CartesianTopology)
Name of a node according to MPI.Get_processor_name()
.
Chmy.Distributed.node_size
— Methodnode_size(t::CartesianTopology)
Number of processes sharing the same node.
Chmy.Distributed.reset!
— Methodreset!(sa::StackAllocator)
Reset the stack allocator by resetting the pointer. Doesn't free the internal memory buffer.
Chmy.Distributed.shared_comm
— Methodshared_comm(t::CartesianTopology)
MPI communicator for the processes sharing the same node.
Chmy.Distributed.shared_rank
— Methodshared_rank(t::CartesianTopology)
Local id of a process within a single node. Can be used to set the GPU device.
Chmy.Workers.Worker
— Typemutable struct Worker{T}
A worker that performs tasks asynchronously.
Constructor
Worker{T}(; setup=nothing, teardown=nothing) where {T}
Constructs a new Worker
object.
Arguments
setup
: A function to be executed before the worker starts processing tasks. (optional)teardown
: A function to be executed after the worker finishes processing tasks. (optional)Settings
This document was generated with Documenter.jl version 1.2.1 on Wednesday 7 February 2024. Using Julia version 1.10.0.
To run the Chmy test suite on the CPU, simple run test
from within the package mode or using Pkg
:
using Pkg
Pkg.test("Chmy")
To run the Chmy test suite on CUDA or ROC backend (Nvidia or AMD GPUs), respectively, run the tests using Pkg
adding following test_args
:
using Pkg
Pkg.test("Chmy"; test_args=["--backend=CUDA"])
using Pkg
-Pkg.test("Chmy"; test_args=["--backend=AMDGPU"])
Settings
This document was generated with Documenter.jl version 1.2.1 on Wednesday 7 February 2024. Using Julia version 1.10.0.
Settings
This document was generated with Documenter.jl version 1.2.1 on Wednesday 7 February 2024. Using Julia version 1.10.0.