Execution & Memory Spaces

Kokkos.SpaceType
Space

Abstract super type of all execution and memory spaces.

Main subtypes:

  • ExecutionSpaces: super type of all execution spaces
  • MemorySpaces: super type of all memory spaces

All Kokkos spaces have a main abstract type (Serial, Cuda, HostSpace, HIPSpace...) which are defined even if it has not been compiled on the C++ side. Those main abstract types should be the ones used when specifying a space. This allows methods like enabled to work independently from the wrapper library.

When a space is enabled, a sub-type of its main type is defined by CxxWrap, leading to the following type structure: SerialImplAllocated <: SerialImpl <: Serial <: ExecutionSpace <: Space. Below the main space type (here, Serial), the sub-types are only defined if they are enabled, and therefore they should not be relied upon.

Navigating the type tree can be made easier through main_space_type.

source
Kokkos.ExecutionSpaceType
ExecutionSpace <: Space

Abstract super-type of all execution spaces.

Sub-types:

  • Serial
  • OpenMP
  • OpenACC
  • OpenMPTarget
  • Threads
  • Cuda
  • HIP
  • HPX
  • SYCL

All sub-types are always defined, but only some of them are enabled. To enable an execution space, you must enable its related Kokkos backend, e.g. "-DKokkos_ENABLE_SERIAL=ON" for the Serial execution space.

To do this you can set the backends option with Kokkos.set_backends, or specify the option directly through kokkos_options.

source
Kokkos.MemorySpaceType
MemorySpace <: Space

Abstract super-type of all memory spaces.

Sub-types:

  • HostSpace
  • CudaSpace
  • CudaHostPinnedSpace
  • CudaUVMSpace
  • HIPSpace
  • HIPHostPinnedSpace
  • HIPManagedSpace

Sub-types work the same as for ExecutionSpace. They can be enabled by enabling their respective backend.

source
Kokkos.array_layoutMethod
array_layout(exec_space::Union{<:ExecutionSpace, Type{<:ExecutionSpace}})

Return the default array layout type of the given execution space.

source
Kokkos.enabledFunction
enabled(space::Union{Space, Type{<:Space}})

Return true if the given execution or memory space is enabled.

source
Kokkos.execution_spaceFunction
execution_space(space::Union{<:MemorySpace, Type{<:MemorySpace}})

Return the execution space associated by default to the given memory space.

source
Kokkos.memory_spaceMethod
memory_space(space::Union{<:ExecutionSpace, Type{<:ExecutionSpace}})

Return the memory space associated by default to the given execution space.

source
Kokkos.main_space_typeFunction
main_space_type(space::Union{<:Space, Type{<:Space}})

Return the main space type of space, e.g. for Serial, SerialImpl or SerialImplAllocated we get Serial.

source
Kokkos.impl_space_typeFunction
impl_space_type(::Type{<:Space})

Opposite of main_space_type: from the main space type (Serial, OpenMP, HostSpace...) return the implementation type (SerialImpl, OpenMPImpl, HostSpaceImpl...). The given space must be enabled.

source
Kokkos.kokkos_nameFunction
kokkos_name(space::Union{Space, Type{<:Space}})

Return the name of the execution or memory space as defined by Kokkos.

Equivalent to Kokkos::space::name()

source
Kokkos.fenceMethod
fence(exec_space::ExecutionSpace)

Wait for all asynchronous tasks operating on this execution space instance to complete.

Equivalent to exec_space.fence().

source

Constants

Kokkos.ENABLED_EXEC_SPACESConstant
ENABLED_EXEC_SPACES::Tuple{Vararg{Type{<:ExecutionSpace}}}

List of all enabled Kokkos execution spaces.

nothing if Kokkos is not yet loaded.

source
Kokkos.ENABLED_MEM_SPACESConstant
ENABLED_MEM_SPACES::Tuple{Vararg{Type{<:MemorySpace}}}

List of all enabled Kokkos memory spaces.

nothing if Kokkos is not yet loaded.

source

Default spaces

Kokkos.DEFAULT_DEVICE_SPACEConstant
DEFAULT_DEVICE_SPACE::Type{<:ExecutionSpace}

The default execution space where kernels are applied on the device.

Equivalent to Kokkos::DefaultExecutionSpace.

nothing if Kokkos is not yet loaded.

source
Kokkos.DEFAULT_DEVICE_MEM_SPACEConstant
DEFAULT_DEVICE_MEM_SPACE::Type{<:MemorySpace}

The default memory space where views are stored on the device.

Equivalent to Kokkos::DefaultExecutionSpace::memory_space.

nothing if Kokkos is not yet loaded.

source
Kokkos.DEFAULT_HOST_SPACEConstant
DEFAULT_HOST_SPACE::Type{<:ExecutionSpace}

The default execution space where kernels are applied on the host.

Equivalent to Kokkos::DefaultHostExecutionSpace.

nothing if Kokkos is not yet loaded.

source
Kokkos.DEFAULT_HOST_MEM_SPACEConstant
DEFAULT_HOST_MEM_SPACE::Type{<:MemorySpace}

The default memory space where views are stored on the host.

Equivalent to Kokkos::DefaultHostExecutionSpace::memory_space.

nothing if Kokkos is not yet loaded.

source
Kokkos.SHARED_MEMORY_SPACEConstant
SHARED_MEMORY_SPACE::Union{Nothing, Type{<:MemorySpace}}

The shared memory space between the host and device, or nothing if there is none.

Equivalent to Kokkos::SharedSpace if Kokkos::has_shared_space is true.

nothing if Kokkos is not yet loaded.

source
Kokkos.SHARED_HOST_PINNED_MEMORY_SPACEConstant
SHARED_HOST_PINNED_MEMORY_SPACE::Union{Nothing, Type{<:MemorySpace}}

The shared pinned memory space between the host and device, or nothing if there is none.

Equivalent to Kokkos::SharedHostPinnedSpace if Kokkos::has_shared_host_pinned_space is true.

nothing if Kokkos is not yet loaded.

source

Backend-specific methods

Those unexported methods are defined in the Kokkos.BackendFunctions module. They have methods only if their respective backend is enabled and Kokkos is initialized.

OpenMP

Some functions of the OpenMP runtime are made available through Kokkos.jl, mostly for debugging purposes and tracking thread affinity.

Cuda / HIP

Kokkos.device_idFunction
device_id([space::Kokkos.Cuda])
device_id([space::Kokkos.HIP])

Return the ID of the device associated with the given space. If space is not given, the ID of the default device used by Kokkos is returned.

The ID is a 0-index in the list of available devices (as used by cudaGetDeviceProperties or hipGetDeviceProperties for example).

Equivalent to Kokkos::Cuda().cuda_device() or Kokkos::HIP().hip_device().

source
Kokkos.BackendFunctions.wrap_streamFunction
wrap_stream(cuda_stream::Ptr{Cvoid})::Kokkos.Cuda
wrap_stream(hip_stream::Ptr{Cvoid})::Kokkos.HIP

Return a Kokkos.Cuda or Kokkos.HIP execution space operating on the given stream (a pointer to a cudaStream_t or hipStream_t respectively). Kokkos does not take ownership of the stream.

Equivalent to Kokkos::Cuda(cuda_stream) or Kokkos::HIP(hip_stream).

source
Kokkos.BackendFunctions.stream_ptrFunction
stream_ptr(space::Kokkos.Cuda)
stream_ptr(space::Kokkos.HIP)

Return the cudaStream_t or hipStream_t of the space as a Ptr{Cvoid}.

Equivalent to Kokkos::Cuda().cuda_stream() or Kokkos::HIP().hip_stream().

source