From 49163e7e184a7d3a2033c52008ffba263d2f4f77 Mon Sep 17 00:00:00 2001 From: John E Date: Thu, 3 Dec 2026 09:35:35 -0500 Subject: [PATCH] docs: fix some typos Signed-off-by: John E --- src/FiniteDifferences.jl | 12 ++++++------ src/ParallelKernel/allocators.jl | 16 ++++++++-------- src/ParallelKernel/hide_communication.jl | 2 +- src/ParallelKernel/init_parallel_kernel.jl | 8 ++++---- src/ParallelKernel/shared.jl | 8 ++++---- src/init_parallel_stencil.jl | 4 ++-- test/ParallelKernel/test_parallel.jl | 4 ++-- test/test_parallel.jl | 16 ++++++++-------- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/FiniteDifferences.jl b/src/FiniteDifferences.jl index dafca44c..ba32acb4 100644 --- a/src/FiniteDifferences.jl +++ b/src/FiniteDifferences.jl @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/ParallelKernel/allocators.jl b/src/ParallelKernel/allocators.jl index b8b9614f..f68d1277 100644 --- a/src/ParallelKernel/allocators.jl +++ b/src/ParallelKernel/allocators.jl @@ -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) """ @@ -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) """ @@ -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) """ @@ -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) """ @@ -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) """ @@ -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) """ @@ -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. @@ -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...)) # ... diff --git a/src/ParallelKernel/hide_communication.jl b/src/ParallelKernel/hide_communication.jl index a1f5e0e5..ab20075b 100644 --- a/src/ParallelKernel/hide_communication.jl +++ b/src/ParallelKernel/hide_communication.jl @@ -17,7 +17,7 @@ Hide the communication behind the computation within the code `block`. # Arguments - `boundary_width::Tuple{Integer,Integer,Integer} | Tuple{Integer,Integer} | Tuple{Integer}`: width of the boundaries in each dimension. The boundaries must include (at least) all the data that is accessed in the communication performed. -- `block`: code block wich starts with one [`@parallel`](@ref) call to perform computations (for exceptions, see keyword `computation_calls`), followed by code to set boundary conditions and to perform communication (as e.g. `update_halo!` from the package `ImplicitGlobalGrid`). The [`@parallel`](@ref) call to perform computations can normally not contain any positional arguments (ranges, nblocks or nthreads) nor the stream keyword argument (stream=...) (for exceptions, see keyword `computation_calls`). The code to set boundary conditions and to perform communication must only access the elements in the boundary ranges of the fields modified in the [`@parallel`](@ref) call; all elements can be acccessed from other fields. Moreover, this code must not include statements in array broadcasting notation, because they are always run on the default stream in CUDA (for CUDA.jl < v2.0), which makes CUDA stream overlapping impossible. Instead, boundary region elements can, e.g., be accessed with [`@parallel`](@ref) calls passing a ranges argument that ensures that no threads mapping to elements outside of the boundary regions are launched. Note that these [`@parallel`](@ref) `ranges` calls cannot contain any other positional arguments (nblocks or nthreads) nor the stream keyword argument (stream=...). +- `block`: code block wich starts with one [`@parallel`](@ref) call to perform computations (for exceptions, see keyword `computation_calls`), followed by code to set boundary conditions and to perform communication (as e.g. `update_halo!` from the package `ImplicitGlobalGrid`). The [`@parallel`](@ref) call to perform computations can normally not contain any positional arguments (ranges, nblocks or nthreads) nor the stream keyword argument (stream=...) (for exceptions, see keyword `computation_calls`). The code to set boundary conditions and to perform communication must only access the elements in the boundary ranges of the fields modified in the [`@parallel`](@ref) call; all elements can be accessed from other fields. Moreover, this code must not include statements in array broadcasting notation, because they are always run on the default stream in CUDA (for CUDA.jl < v2.0), which makes CUDA stream overlapping impossible. Instead, boundary region elements can, e.g., be accessed with [`@parallel`](@ref) calls passing a ranges argument that ensures that no threads mapping to elements outside of the boundary regions are launched. Note that these [`@parallel`](@ref) `ranges` calls cannot contain any other positional arguments (nblocks or nthreads) nor the stream keyword argument (stream=...). !!! note "Advanced" - `ranges_outer::`Tuple with one or multiple `ranges` as required by the corresponding argument of [`@parallel`](@ref): the `ranges` must together span (at least) all the data that is accessed in the communication and boundary conditions performed. diff --git a/src/ParallelKernel/init_parallel_kernel.jl b/src/ParallelKernel/init_parallel_kernel.jl index 846274a5..075c6496 100644 --- a/src/ParallelKernel/init_parallel_kernel.jl +++ b/src/ParallelKernel/init_parallel_kernel.jl @@ -2,7 +2,7 @@ @init_parallel_kernel(package, numbertype) @init_parallel_kernel(package, numbertype, inbounds=..., padding=...) -Initialize the package ParallelKernel, giving access to its main functionality. Creates a module `Data` in the module where `@init_parallel_kernel` is called from; the module `Data` contains the types `Data.Number`, `Data.Array` and `Data.CellArray` (type `?Data` *after* calling `@init_parallel_kernel` to see the full description of the module). +Initialize the package ParallelKernel, giving access to its main functionality. Creates a module `Data` in the module where `@init_parallel_kernel` is called from; the module `Data` contains the types `Data.Number`, `Data.Array` and `Data.CellArray` (type `?Data` *after* calling `@init_parallel_kernel` to see the full description of the module). When the abstraction-layer backend KernelAbstractions is selected, the concrete runtime hardware is chosen later via [`select_hardware`](@ref) and inspected with [`current_hardware`](@ref); consult the [interactive prototyping runtime selection section](@ref interactive-prototyping-runtime-hardware-selection) for an end-to-end workflow. !!! note "Convenience modules" @@ -27,7 +27,7 @@ macro init_parallel_kernel(args...) else package, numbertype_val = extract_kwargs_init(__module__, kwargs) end inbounds_val, padding_val = extract_kwargs_nopos(__module__, kwargs) - if (package == PKG_NONE) @ArgumentError("the package argument cannot be ommited.") end #TODO: this error message will disappear, once the package can be defined at runtime. + if (package == PKG_NONE) @ArgumentError("the package argument cannot be omitted.") end #TODO: this error message will disappear, once the package can be defined at runtime. esc(init_parallel_kernel(__module__, package, numbertype_val, inbounds_val, padding_val)) end @@ -141,7 +141,7 @@ macro get_hardware() quote_expr(get_hardware(__module__)) end macro get_inbounds() get_inbounds(__module__) end macro get_padding() get_padding(__module__) end let - global is_initialized, set_initialized, set_package, get_package, set_numbertype, get_numbertype, set_inbounds, get_inbounds, set_padding, get_padding, set_hardware, get_hardware, reset_hardware!, check_initialized, check_already_initialized + global is_initialized, set_initialized, set_package, get_package, set_numbertype, get_numbertype, set_inbounds, get_inbounds, set_padding, get_padding, set_hardware, get_hardware, reset_hardware!, check_initialized, check_already_initialized set_initialized(caller::Module, flag::Bool) = (createmeta_PK(caller); @eval(caller, $MOD_METADATA_PK.set_initialized($flag))) is_initialized(caller::Module) = hasmeta_PK(caller) && @eval(caller, $MOD_METADATA_PK.is_initialized()) set_package(caller::Module, pkg::Symbol) = (createmeta_PK(caller); @eval(caller, $MOD_METADATA_PK.set_package($(quote_expr(pkg))))) @@ -189,7 +189,7 @@ end function define_import(caller::Module, package::Symbol, parent_module::String) if package == PKG_THREADS return :() - else + else error_msg = "package $caller is missing $package in its (weak) dependencies ($package was selected as package for parallelization using $parent_module; $package functionality is provided as an extension of $parent_module and $(package).jl needs therefore to be added as an explicit (weak) dependency)." return :( try diff --git a/src/ParallelKernel/shared.jl b/src/ParallelKernel/shared.jl index a66a2f1d..b781a7f5 100644 --- a/src/ParallelKernel/shared.jl +++ b/src/ParallelKernel/shared.jl @@ -137,7 +137,7 @@ end ## FUNCTIONS TO CHECK EXTENSIONS SUPPORT -is_loaded(arg) = false +is_loaded(arg) = false is_installed(package::String) = (Base.find_package(package)!==nothing) @@ -204,7 +204,7 @@ function remove_return(body::Expr; disguise_nested=true) remainder = copy(body) remainder.args = body.args[1:end-2] remainder = handle_nested_returns(remainder; disguise=disguise_nested) - if inexpr_walk(remainder, :return) @ArgumentError("invalid kernel in @parallel kernel definition: only one return statement is allowed in the kernel (exception: nested function definitions) and it must return nothing and be the last statement (required to ensure equal behaviour with different packages for parallellization).") end + if inexpr_walk(remainder, :return) @ArgumentError("invalid kernel in @parallel kernel definition: only one return statement is allowed in the kernel (exception: nested function definitions) and it must return nothing and be the last statement (required to ensure equal behaviour with different packages for parallelization).") end return remainder end @@ -368,7 +368,7 @@ function is_kwarg(arg; in_kernelcall=false, separator=:(=), keyword_type=Symbol) end Base.haskey(::Array{Union{}}, ::Symbol) = return false - + function Base.haskey(kwargs_expr::Array{Expr}, key::Symbol) kwargs = split_kwargs(kwargs_expr) return key in keys(kwargs) @@ -601,7 +601,7 @@ function extract_tuple(t::Union{Expr,Symbol}; nested=false) # NOTE: this could r if (nested) return t.args else return extract_tuple_arg.(t.args) end - else + else return [extract_tuple_arg(t)] end end diff --git a/src/init_parallel_stencil.jl b/src/init_parallel_stencil.jl index 1f71651c..fda78949 100644 --- a/src/init_parallel_stencil.jl +++ b/src/init_parallel_stencil.jl @@ -29,7 +29,7 @@ macro init_parallel_stencil(args...) else package, numbertype_val, ndims_val = extract_kwargs_init(__module__, kwargs) end inbounds_val, padding_val, memopt_val, double_buffering_opt_val, nonconst_metadata_val = extract_kwargs_nopos(__module__, kwargs) - if (package == PKG_NONE) @ArgumentError("the package argument cannot be ommited.") end #TODO: this error message will disappear, once the package can be defined at runtime. + if (package == PKG_NONE) @ArgumentError("the package argument cannot be omitted.") end #TODO: this error message will disappear, once the package can be defined at runtime. if (package == PKG_POLYESTER && padding_val) @ArgumentError("padding is not yet supported for Polyester.") end check_already_initialized(__module__, package, numbertype_val, ndims_val, inbounds_val, padding_val, memopt_val, double_buffering_opt_val, nonconst_metadata_val) esc(init_parallel_stencil(__module__, package, numbertype_val, ndims_val, inbounds_val, padding_val, memopt_val, double_buffering_opt_val, nonconst_metadata_val)) @@ -161,4 +161,4 @@ function extract_kwargs_nopos(caller::Module, kwargs::Dict) else nonconst_metadata_val = false end return inbounds_val, padding_val, memopt_val, double_buffering_opt_val, nonconst_metadata_val -end \ No newline at end of file +end diff --git a/test/ParallelKernel/test_parallel.jl b/test/ParallelKernel/test_parallel.jl index 74afd1a6..73c32439 100644 --- a/test/ParallelKernel/test_parallel.jl +++ b/test/ParallelKernel/test_parallel.jl @@ -527,7 +527,7 @@ eval(:( @reset_parallel_kernel() end; end; - @testset "4. parallel macros (numbertype ommited)" begin + @testset "4. parallel macros (numbertype omitted)" begin @require !@is_initialized() @init_parallel_kernel(package = $package) @require @is_initialized @@ -587,7 +587,7 @@ eval(:( end; end; )) end; - + end # Optional single-init-once / no-reset "xPU" second block (requires runtime-reachable Data/TData submodules). diff --git a/test/test_parallel.jl b/test/test_parallel.jl index 452fcc9f..4d2020c3 100644 --- a/test/test_parallel.jl +++ b/test/test_parallel.jl @@ -757,7 +757,7 @@ eval(:( end @parallel memopt=true copy_memopt!(A2, A, B); @test all(Array(A2) .== Array(A) .+ Array(B)) - end + end @testset "@parallel_indices (3D, memopt; 2 arrays, z-stencil)" begin A = @Field(nxyz); A2 = @Field(nxyz); @@ -1204,7 +1204,7 @@ eval(:( end end ))) - end + end end; @testset "@within" begin @test @prettystring(@within("@all", A)) == string(:(firstindex(A, 1) <= $ix <= lastindex(A, 1) && (firstindex(A, 2) <= $iy <= lastindex(A, 2) && firstindex(A, 3) <= $iz <= lastindex(A, 3)))) @@ -1527,7 +1527,7 @@ eval(:( @reset_parallel_stencil() end; end; - @testset "5. parallel macros (numbertype and ndims ommited)" begin + @testset "5. parallel macros (numbertype and ndims omitted)" begin @require !@is_initialized() @init_parallel_stencil(package = $package, nonconst_metadata=true) @require @is_initialized @@ -1822,12 +1822,12 @@ eval(:( @test_throws ArgumentError validate_body(:(A = @all(B) + 1; @all(A) = @all(B) + 1)) end; @testset "automatic ranges: error if not all parallel indices are used" begin - @test_throws ArgumentError parallel_indices(:((ix, iy, iz)), + @test_throws ArgumentError parallel_indices(:((ix, iy, iz)), :(function write_xy_plane!(A) A[ix, iy, 1] = 2.0 * A[ix, iy, 1] return end)) - @test_throws ArgumentError parallel_indices(:((ix, iy)), + @test_throws ArgumentError parallel_indices(:((ix, iy)), :(function write_y_line!(A) A[1, iy] = 2.0 * A[1, iy] return @@ -1854,12 +1854,12 @@ eval(:( @test A2 == $FloatDefault(2) .* @ones(4, 2) end; @testset "automatic ranges (memopt): error if not all parallel indices are used" begin - @test_throws ArgumentError parallel_indices(:((ix, iy, iz)), :(memopt=true), + @test_throws ArgumentError parallel_indices(:((ix, iy, iz)), :(memopt=true), :(function write_xy_plane!(A, B) A[ix, iy, 1] = 2.0 * A[ix, iy, 1] + B[ix, iy, 1] return end)) - @test_throws ArgumentError parallel_indices(:((ix, iy)), :(memopt=true), + @test_throws ArgumentError parallel_indices(:((ix, iy)), :(memopt=true), :(function write_y_line!(A, B) A[1, iy] = 2.0 * A[1, iy] + B[1, iy] return @@ -1904,7 +1904,7 @@ eval(:( end; end; )) end; - + end # Optional single-init-once / no-reset "xPU" second block (requires runtime-reachable Data/TData submodules). The macro-expansion + runtime-launch halves of the Field type use verification cannot be exercised in the dominant reset-driven loop on GPU backends after the first `@reset_parallel_stencil`, so they are merged here. Each runtime launch follows the established `@parallel_indices (1D/2D/3D) → @parallel ; @test all(Array(...) .== ...)` idiom; VectorField/BVectorField use the shared single parameter (components == per-component dim) and TensorField uses separate parameters (components = N*(N+1)/2 vs per-component dim = N).