Ginkgo: gko::CudaExecutor Class Reference

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
gko::CudaExecutor Class Reference
Executors » CUDA Executor | Executors

This is the Executor subclass which represents the CUDA device. More...

`#include <ginkgo/core/base/executor.hpp>`

Inheritance diagram for gko::CudaExecutor:
[legend]
Collaboration diagram for gko::CudaExecutor:
[legend]

## Public Member Functions
std::shared_ptr< Executor > | get_master () noexcept override
| Returns the master OmpExecutor of this Executor.
std::shared_ptr< const Executor > | get_master () const noexcept override
| Returns the master OmpExecutor of this Executor.
void | synchronize () const override
| Synchronize the operations launched on the executor with its master.
scoped_device_id_guard | get_scoped_device_id_guard () const override
std::string | get_description () const override
int | get_device_id () const noexcept
| Get the CUDA device id of the device associated to this executor.
int | get_num_warps_per_sm () const noexcept
| Get the number of warps per SM of this executor.
int | get_num_multiprocessor () const noexcept
| Get the number of multiprocessor of this executor.
int | get_num_warps () const noexcept
| Get the number of warps of this executor.
int | get_warp_size () const noexcept
| Get the warp size of this executor.
int | get_major_version () const noexcept
| Get the major version of compute capability.
int | get_minor_version () const noexcept
| Get the minor version of compute capability.
int | get_compute_capability () const noexcept
| Get the compute capability.
cublasContext * | get_cublas_handle () const
| Get the cublas handle for this executor.
cublasContext * | get_blas_handle () const
| Get the cublas handle for this executor.
cusparseContext * | get_cusparse_handle () const
| Get the cusparse handle for this executor.
cusparseContext * | get_sparselib_handle () const
| Get the cusparse handle for this executor.
std::vector< int > | get_closest_pus () const
| Get the closest PUs.
int | get_closest_numa () const
| Get the closest NUMA node.
CUstream_st * | get_stream () const
| Returns the CUDA stream used by this executor.
virtual void | run (const Operation &op) const=0
| Runs the specified Operation using this Executor.
template<typename ClosureOmp, typename ClosureCuda, typename ClosureHip, typename ClosureDpcpp>
void | run (const ClosureOmp &op_omp, const ClosureCuda &op_cuda, const ClosureHip &op_hip, const ClosureDpcpp &op_dpcpp) const
| Runs one of the passed in functors, depending on the Executor type.
template<typename ClosureReference, typename ClosureOmp, typename ClosureCuda, typename ClosureHip, typename ClosureDpcpp>
void | run (std::string name, const ClosureReference &op_ref, const ClosureOmp &op_omp, const ClosureCuda &op_cuda, const ClosureHip &op_hip, const ClosureDpcpp &op_dpcpp) const
| Runs one of the passed in functors, depending on the Executor type.

## Static Public Member Functions
static std::shared_ptr< CudaExecutor > | create (int device_id, std::shared_ptr< Executor > master, bool device_reset, allocation_mode alloc_mode=default_cuda_alloc_mode, CUstream_st *stream=nullptr)
| Creates a new CudaExecutor.
static std::shared_ptr< CudaExecutor > | create (int device_id, std::shared_ptr< Executor > master, std::shared_ptr< CudaAllocatorBase > alloc=std::make_shared< CudaAllocator >(), CUstream_st *stream=nullptr)
| Creates a new CudaExecutor with a custom allocator and device stream.
static int | get_num_devices ()
| Get the number of devices present on the system.

## Detailed Description

This is the Executor subclass which represents the CUDA device.

## Member Function Documentation

## ◆ create() [1/2]

std::shared_ptr< CudaExecutor > gko::CudaExecutor::create | ( | int | device_id,
|  | std::shared_ptr< Executor > | master,
|  | bool | device_reset,
|  | allocation_mode | alloc_mode = default_cuda_alloc_mode,
|  | CUstream_st * | stream = nullptr )
| static

Creates a new CudaExecutor.

Parameters

  device_id | the CUDA device id of this device
  master | an executor on the host that is used to invoke the device kernels
  device_reset | this option no longer has any effect.
  alloc_mode | the allocation mode that the executor should operate on. See @allocation_mode for more details
  stream | the stream to execute operations on.

References create().

Referenced by create(), and create().

## ◆ create() [2/2]

std::shared_ptr< CudaExecutor > gko::CudaExecutor::create | ( | int | device_id,
|  | std::shared_ptr< Executor > | master,
|  | std::shared_ptr< CudaAllocatorBase > | alloc = std::make_shared< CudaAllocator >(),
|  | CUstream_st * | stream = nullptr )
| static

Creates a new CudaExecutor with a custom allocator and device stream.

Parameters

  device_id | the CUDA device id of this device
  master | an executor on the host that is used to invoke the device kernels.
  alloc | the allocator to use for device memory allocations.
  stream | the stream to execute operations on.

References gko::Executor::alloc(), and create().

## ◆ get_blas_handle()

cublasContext * gko::CudaExecutor::get_blas_handle | ( |  | ) | const
| inline

Get the cublas handle for this executor.

Returns
  the cublas handle (cublasContext*) for this executor

Referenced by get_cublas_handle().

## ◆ get_closest_numa()

int gko::CudaExecutor::get_closest_numa | ( |  | ) | const
| inline

Get the closest NUMA node.

Returns
  the closest NUMA node closest to this device

## ◆ get_closest_pus()

std::vector< int > gko::CudaExecutor::get_closest_pus | ( |  | ) | const
| inline

Get the closest PUs.

Returns
  the array of PUs closest to this device

## ◆ get_cublas_handle()

cublasContext * gko::CudaExecutor::get_cublas_handle | ( |  | ) | const
| inline

Get the cublas handle for this executor.

Returns
  the cublas handle (cublasContext*) for this executor

References get_blas_handle(), and get_cublas_handle().

Referenced by get_cublas_handle().

## ◆ get_cusparse_handle()

cusparseContext * gko::CudaExecutor::get_cusparse_handle | ( |  | ) | const
| inline

Get the cusparse handle for this executor.

Returns
  the cusparse handle (cusparseContext*) for this executor

References get_cusparse_handle(), and get_sparselib_handle().

Referenced by get_cusparse_handle().

## ◆ get_description()

std::string gko::CudaExecutor::get_description | ( |  | ) | const
| overridevirtual

Returns
  a textual representation of the executor and its device.

Implements gko::Executor.

References get_description().

Referenced by get_description().

## ◆ get_master() [1/2]

std::shared_ptr< const Executor > gko::CudaExecutor::get_master | ( |  | ) | const
| overridevirtualnoexcept

Returns the master OmpExecutor of this Executor.

Returns
  the master OmpExecutor of this Executor.

Implements gko::Executor.

References get_master().

## ◆ get_master() [2/2]

std::shared_ptr< Executor > gko::CudaExecutor::get_master | ( |  | ) |
| overridevirtualnoexcept

Returns the master OmpExecutor of this Executor.

Returns
  the master OmpExecutor of this Executor.

Implements gko::Executor.

References get_master().

Referenced by get_master(), and get_master().

## ◆ get_scoped_device_id_guard()

scoped_device_id_guard gko::CudaExecutor::get_scoped_device_id_guard | ( |  | ) | const
| overridevirtual

Implements gko::Executor.

## ◆ get_sparselib_handle()

cusparseContext * gko::CudaExecutor::get_sparselib_handle | ( |  | ) | const
| inline

Get the cusparse handle for this executor.

Returns
  the cusparse handle (cusparseContext*) for this executor

Referenced by get_cusparse_handle().

## ◆ get_stream()

CUstream_st * gko::CudaExecutor::get_stream | ( |  | ) | const
| inline

Returns the CUDA stream used by this executor.

Can be nullptr for the default stream.

Returns
  the stream used to execute kernels and memory operations.

## ◆ run() [1/3]

template<typename ClosureOmp, typename ClosureCuda, typename ClosureHip, typename ClosureDpcpp>

void gko::Executor::run | ( | const ClosureOmp & | op_omp,
|  | const ClosureCuda & | op_cuda,
|  | const ClosureHip & | op_hip,
|  | const ClosureDpcpp & | op_dpcpp ) const
| inline

Runs one of the passed in functors, depending on the Executor type.

Template Parameters

  ClosureOmp | type of op_omp
  ClosureCuda | type of op_cuda
  ClosureHip | type of op_hip
  ClosureDpcpp | type of op_dpcpp

Parameters

  op_omp | functor to run in case of a OmpExecutor or ReferenceExecutor
  op_cuda | functor to run in case of a CudaExecutor
  op_hip | functor to run in case of a HipExecutor
  op_dpcpp | functor to run in case of a DpcppExecutor

## ◆ run() [2/3]

virtual void gko::Executor::run | ( | const Operation & | op | ) | const
| virtual

Runs the specified Operation using this Executor.

Parameters

  op | the operation to run

Implements gko::Executor.

## ◆ run() [3/3]

template<typename ClosureReference, typename ClosureOmp, typename ClosureCuda, typename ClosureHip, typename ClosureDpcpp>

void gko::Executor::run | ( | std::string | name,
|  | const ClosureReference & | op_ref,
|  | const ClosureOmp & | op_omp,
|  | const ClosureCuda & | op_cuda,
|  | const ClosureHip & | op_hip,
|  | const ClosureDpcpp & | op_dpcpp ) const
| inline

Runs one of the passed in functors, depending on the Executor type.

Template Parameters

  ClosureReference | type of op_ref
  ClosureOmp | type of op_omp
  ClosureCuda | type of op_cuda
  ClosureHip | type of op_hip
  ClosureDpcpp | type of op_dpcpp

Parameters

  name | the name of the operation
  op_ref | functor to run in case of a ReferenceExecutor
  op_omp | functor to run in case of a OmpExecutor
  op_cuda | functor to run in case of a CudaExecutor
  op_hip | functor to run in case of a HipExecutor
  op_dpcpp | functor to run in case of a DpcppExecutor

## ◆ synchronize()

void gko::CudaExecutor::synchronize | ( |  | ) | const
| overridevirtual

Synchronize the operations launched on the executor with its master.

Implements gko::Executor.

References synchronize().

Referenced by synchronize().

The documentation for this class was generated from the following file:

- ginkgo/core/base/executor.hpp