Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/FiniteDifferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ macro within(macroname::String, A)
@expandargs(A)
if macroname == "@all" esc( :(firstindex($A,1) <= $ixa <= lastindex($A,1)) )
elseif macroname == "@inn" esc( :(firstindex($A,1) < $ixi < lastindex($A,1)) )
else error("unkown macroname: $macroname. If you want to add your own assignement macros, overwrite the macro 'within(macroname::String, A)'; to still use the exising macro within as well call ParallelStencil.FiniteDifferences{1|2|3}D.@within(macroname, A) at the end.")
else error("unknown macroname: $macroname. If you want to add your own assignement macros, overwrite the macro 'within(macroname::String, A)'; to still use the exising macro within as well call ParallelStencil.FiniteDifferences{1|2|3}D.@within(macroname, A) at the end.")
end
end

Expand Down Expand Up @@ -191,7 +191,7 @@ macro within(macroname::String, A)
elseif macroname == "@inn" esc( :(firstindex($A,1) < $ixi < lastindex($A,1) && firstindex($A,2) < $iyi < lastindex($A,2)) )
elseif macroname == "@inn_x" esc( :(firstindex($A,1) < $ixi < lastindex($A,1) && firstindex($A,2) <= $iya <= lastindex($A,2)) )
elseif macroname == "@inn_y" esc( :(firstindex($A,1) <= $ixa <= lastindex($A,1) && firstindex($A,2) < $iyi < lastindex($A,2)) )
else error("unkown macroname: $macroname. If you want to add your own assignement macros, overwrite the macro 'within(macroname::String, A)'; to still use the exising macro within as well call ParallelStencil.FiniteDifferences{1|2|3}D.@within(macroname, A) at the end.")
else error("unknown macroname: $macroname. If you want to add your own assignement macros, overwrite the macro 'within(macroname::String, A)'; to still use the exising macro within as well call ParallelStencil.FiniteDifferences{1|2|3}D.@within(macroname, A) at the end.")
end
end

Expand Down Expand Up @@ -269,7 +269,7 @@ module FiniteDifferences3D
export @d_xa, @d_ya, @d_za, @d_xi, @d_yi, @d_zi, @d2_xi, @d2_yi, @d2_zi
export @all, @inn, @inn_x, @inn_y, @inn_z, @inn_xy, @inn_xz, @inn_yz
export @av, @av_xa, @av_ya, @av_za, @av_xi, @av_yi, @av_zi, @av_xya, @av_xza, @av_yza, @av_xyi, @av_xzi, @av_yzi #, @av_xya2, @av_xza2, @av_yza2
export @harm, @harm_xa, @harm_ya, @harm_za, @harm_xi, @harm_yi, @harm_zi, @harm_xya, @harm_xza, @harm_yza, @harm_xyi, @harm_xzi, @harm_yzi
export @harm, @harm_xa, @harm_ya, @harm_za, @harm_xi, @harm_yi, @harm_zi, @harm_xya, @harm_xza, @harm_yza, @harm_xyi, @harm_xzi, @harm_yzi
export @maxloc, @minloc
export @within

Expand Down Expand Up @@ -342,9 +342,9 @@ macro inn_z(A) @expandargs(A); esc(:( $A[$ixa ,$iya ,$izi ] )) end
macro inn_xy(A) @expandargs(A); esc(:( $A[$ixi ,$iyi ,$iza ] )) end
macro inn_xz(A) @expandargs(A); esc(:( $A[$ixi ,$iya ,$izi ] )) end
macro inn_yz(A) @expandargs(A); esc(:( $A[$ixa ,$iyi ,$izi ] )) end
macro av(A) @expandargs(A); esc(:(($A[$ix ,$iy ,$iz ] + $A[$ix+1,$iy ,$iz ] +
$A[$ix ,$iy+1,$iz ] + $A[$ix+1,$iy+1,$iz ] +
$A[$ix ,$iy ,$iz+1] + $A[$ix+1,$iy ,$iz+1] +
macro av(A) @expandargs(A); esc(:(($A[$ix ,$iy ,$iz ] + $A[$ix+1,$iy ,$iz ] +
$A[$ix ,$iy+1,$iz ] + $A[$ix+1,$iy+1,$iz ] +
$A[$ix ,$iy ,$iz+1] + $A[$ix+1,$iy ,$iz+1] +
$A[$ix ,$iy+1,$iz+1] + $A[$ix+1,$iy+1,$iz+1])*0.125)) end
macro av_xa(A) @expandargs(A); esc(:(($A[$ix ,$iya ,$iza ] + $A[$ix+1,$iya ,$iza ] )*0.5 )) end
macro av_ya(A) @expandargs(A); esc(:(($A[$ixa ,$iy ,$iza ] + $A[$ixa ,$iy+1,$iza ] )*0.5 )) end
Expand Down
16 changes: 8 additions & 8 deletions src/ParallelKernel/allocators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Call `zeros(eltype, args...)`, where `eltype` is by default the `numbertype` sel
- `double_buffered::Bool=false`: when set to `true`, allocate two arrays and return them as a `NamedTuple{(:in, :out)}` for use with ParallelStencil's double-buffering optimization.
!!! note "Advanced"
- `celltype::DataType`: the type of each array cell; it must be generated with the macro `@CellType`. The keyword argument `celltype` is incompatible with the other keyword arguments: if any of them is set, then the `celltype` is automatically defined. The `celltype` needs only to be specified to use named cell fields. Note that values can always be addressed with array indices, even when cell field names are defined.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contigously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better peformance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contiguously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better performance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.

See also: [`@ones`](@ref), [`@rand`](@ref), [`@falses`](@ref), [`@trues`](@ref), [`@fill`](@ref), [`@CellType`](@ref)
"""
Expand Down Expand Up @@ -50,7 +50,7 @@ Call `ones(eltype, args...)`, where `eltype` is by default the `numbertype` sele
- `double_buffered::Bool=false`: when set to `true`, allocate two arrays and return them as a `NamedTuple{(:in, :out)}` for use with ParallelStencil's double-buffering optimization.
!!! note "Advanced"
- `celltype::DataType`: the type of each array cell; it must be generated with the macro `@CellType`. The keyword argument `celltype` is incompatible with the other keyword arguments: if any of them is set, then the `celltype` is automatically defined. The `celltype` needs only to be specified to use named cell fields. Note that values can always be addressed with array indices, even when cell field names are defined.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contigously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better peformance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contiguously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better performance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.

See also: [`@zeros`](@ref), [`@rand`](@ref), [`@falses`](@ref), [`@trues`](@ref), [`@fill`](@ref), [`@CellType`](@ref)
"""
Expand Down Expand Up @@ -86,7 +86,7 @@ Call `rand(eltype, args...)`, where `eltype` is by default the `numbertype` sele
- `double_buffered::Bool=false`: when set to `true`, allocate two arrays and return them as a `NamedTuple{(:in, :out)}` for use with ParallelStencil's double-buffering optimization.
!!! note "Advanced"
- `celltype::DataType`: the type of each array cell; it must be generated with the macro `@CellType`. The keyword argument `celltype` is incompatible with the other keyword arguments: if any of them is set, then the `celltype` is automatically defined. The `celltype` needs only to be specified to use named cell fields. Note that values can always be addressed with array indices, even when cell field names are defined.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contigously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better peformance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contiguously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better performance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.

See also: [`@zeros`](@ref), [`@ones`](@ref), [`@falses`](@ref), [`@trues`](@ref), [`@fill`](@ref), [`@CellType`](@ref)
"""
Expand Down Expand Up @@ -117,7 +117,7 @@ Call `falses(args...)`, where the function `falses` is chosen to be compatible w
- `celldims::Integer|NTuple{N,Integer}=1`: the dimensions of each array cell. Each cell can contain a single value (default) or an N-dimensional array of the specified dimensions.
- `double_buffered::Bool=false`: when set to `true`, allocate two arrays and return them as a `NamedTuple{(:in, :out)}` for use with ParallelStencil's double-buffering optimization.
!!! note "Advanced"
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contigously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better peformance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contiguously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better performance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.

See also: [`@zeros`](@ref), [`@ones`](@ref), [`@rand`](@ref), [`@trues`](@ref), [`@fill`](@ref), [`@CellType`](@ref)
"""
Expand Down Expand Up @@ -148,7 +148,7 @@ Call `trues(args...)`, where the function `trues` is chosen to be compatible wit
- `celldims::Integer|NTuple{N,Integer}=1`: the dimensions of each array cell. Each cell can contain a single value (default) or an N-dimensional array of the specified dimensions.
- `double_buffered::Bool=false`: when set to `true`, allocate two arrays and return them as a `NamedTuple{(:in, :out)}` for use with ParallelStencil's double-buffering optimization.
!!! note "Advanced"
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contigously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better peformance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contiguously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better performance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.

See also: [`@zeros`](@ref), [`@ones`](@ref), [`@rand`](@ref), [`@falses`](@ref), [`@fill`](@ref), [`@CellType`](@ref)
"""
Expand Down Expand Up @@ -184,7 +184,7 @@ Call `fill(convert(eltype, x), args...)`, where `eltype` is by default the `numb
- `double_buffered::Bool=false`: when set to `true`, allocate two arrays and return them as a `NamedTuple{(:in, :out)}` for use with ParallelStencil's double-buffering optimization.
!!! note "Advanced"
- `celltype::DataType`: the type of each array cell; it must be generated with the macro `@CellType`. The keyword argument `celltype` is incompatible with the other keyword arguments: if any of them is set, then the `celltype` is automatically defined. The `celltype` needs only to be specified to use named cell fields. Note that values can always be addressed with array indices, even when cell field names are defined.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contigously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better peformance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.
- `blocklength::Integer`: refers to the amount of values of a same `Cell` field that are stored contiguously (`blocklength=1` means array of struct like storage; `blocklength=prod(dims)` means array struct of array like storage; `blocklength=0` is an alias for `blocklength=prod(dims)`, enabling better performance thanks to more specialized dispatch). By default, `blocklength` is automatically set to `0` if a GPU package was chosen with [`@init_parallel_kernel`](@ref) and to `1` if a CPU package was chosen. Furthermore, the argument `blocklength` is only of effect if either `celldims` or `celltype` is set, else it is ignored.

See also: [`@fill!`](@ref), [`@zeros`](@ref), [`@ones`](@ref), [`@rand`](@ref), [`@falses`](@ref), [`@trues`](@ref), [`@CellType`](@ref)
"""
Expand Down Expand Up @@ -229,7 +229,7 @@ Create a cell type, which can then be passed to `@zeros`, `@ones`, `@rand`, `@fa
# Keyword arguments
- `eltype::DataType`: the type of the elements, which can be numbers, indices, booleans or enums.
- `fieldnames::String|NTuple{N,String}`: the names of the fields of the cell. Note that cell values can always be addressed with array indices, even when field names are defined.
- `dims::Integer|NTuple{N,Integer}=length(fieldnames)`: the dimensions of the cell. A cell can contain a single value or an N-dimensional array of the specified dimensions. A valid dims argument must fullfill `prod(dims)==length(fieldnames)`. If `dims` is omitted, then it will be automatically set as `dims=length(fieldnames)`, defining the cell to contain a 1-D array of appropriate length.
- `dims::Integer|NTuple{N,Integer}=length(fieldnames)`: the dimensions of the cell. A cell can contain a single value or an N-dimensional array of the specified dimensions. A valid dims argument must fulfill `prod(dims)==length(fieldnames)`. If `dims` is omitted, then it will be automatically set as `dims=length(fieldnames)`, defining the cell to contain a 1-D array of appropriate length.
!!! note "Advanced"
- `parametric::Bool=false`: whether the cell type has a fixed or parametrisable element type. If `parametric=true` is set, then the keyword argument `eltype` is invalid.

Expand Down Expand Up @@ -508,7 +508,7 @@ function determine_blocklength(blocklength, package)
end


## RUNTIME ALLOCATOR FUNCTIONS
## RUNTIME ALLOCATOR FUNCTIONS

zeros_cpu(::Type{T}, blocklength, args...) where {T<:Number} = (check_datatype_cpu(T); Base.zeros(T, args...)) # (blocklength is ignored if neither celldims nor celltype is set)
ones_cpu(::Type{T}, blocklength, args...) where {T<:Number} = (check_datatype_cpu(T); fill_cpu(T, blocklength, 1, args...)) # ...
Expand Down
Loading
Loading