tvm
Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
tvm::runtime::SessionObj Class Referenceabstract

A Disco interactive session. It allows users to interact with the Disco command queue with various ffi::Function calling convention. More...

#include <session.h>

Inheritance diagram for tvm::runtime::SessionObj:
Collaboration diagram for tvm::runtime::SessionObj:

Public Member Functions

virtual ~SessionObj ()=default
 
template<typename... Args>
DRef TVM_ALWAYS_INLINE CallPacked (const DRef &func, Args &&... args)
 Call a ffi::Function on workers providing variadic arguments. More...
 
virtual DRef CallWithPacked (const ffi::PackedArgs &args)=0
 Call packed function on each worker using a packed sequence. The calling convention: The first element must be DiscoAction::kCallPacked, The second element must be 0, which will later be updated by the session to return reg_id The thirtd element is the function to be called. More...
 
virtual int64_t GetNumWorkers ()=0
 Get the number of workers in the session. More...
 
virtual DRef GetGlobalFunc (const std::string &name)=0
 Get a global functions on workers. More...
 
virtual void CopyFromWorker0 (const NDArray &host_array, const DRef &remote_array)=0
 Copy an NDArray from worker-0 to the controler-side NDArray. More...
 
virtual void CopyToWorker0 (const NDArray &host_array, const DRef &remote_array)=0
 Copy the controler-side NDArray to worker-0. More...
 
virtual void SyncWorker (int worker_id)=0
 Synchrnoize the controler with a worker, and it will wait until worker finishes executing this instruction. More...
 
virtual void Shutdown ()=0
 Signal all the workers to shutdown. More...
 
virtual void InitCCL (String ccl, IntTuple device_ids)=0
 Initialize the data plane between workers. More...
 
virtual ffi::Any DebugGetFromRemote (int64_t reg_id, int worker_id)=0
 Get the value of a register from a remote worker. More...
 
virtual void DebugSetRegister (int64_t reg_id, ffi::AnyView value, int worker_id)=0
 Set the value of a register on a remote worker. More...
 
 TVM_DECLARE_BASE_OBJECT_INFO (SessionObj, Object)
 
template<typename... Args>
DRef CallPacked (const DRef &func, Args &&... args)
 

Static Public Attributes

static constexpr const char * _type_key = "runtime.disco.Session"
 

Protected Member Functions

virtual void DeallocReg (int reg_id)=0
 Deallocate a register id, kill it on all workers, and append it to free_regs_. More...
 

Friends

struct SessionObj::FFI
 
class DRefObj
 

Detailed Description

A Disco interactive session. It allows users to interact with the Disco command queue with various ffi::Function calling convention.

Constructor & Destructor Documentation

◆ ~SessionObj()

virtual tvm::runtime::SessionObj::~SessionObj ( )
virtualdefault

Member Function Documentation

◆ CallPacked() [1/2]

template<typename... Args>
DRef TVM_ALWAYS_INLINE tvm::runtime::SessionObj::CallPacked ( const DRef func,
Args &&...  args 
)

Call a ffi::Function on workers providing variadic arguments.

Template Parameters
ArgsIn the variadic arguments, the supported types include:
  • integers and floating point numbers;
  • DataType;
  • Device;
  • std::string;
  • DRef. Examples of unsupported types:
  • NDArray, DLTensor;
  • TVM Objects, including ffi::Function, Module and String;
Parameters
funcThe function to be called.
argsThe variadic arguments.
Returns
The return value of function call

◆ CallPacked() [2/2]

template<typename... Args>
DRef tvm::runtime::SessionObj::CallPacked ( const DRef func,
Args &&...  args 
)

◆ CallWithPacked()

virtual DRef tvm::runtime::SessionObj::CallWithPacked ( const ffi::PackedArgs &  args)
pure virtual

Call packed function on each worker using a packed sequence. The calling convention: The first element must be DiscoAction::kCallPacked, The second element must be 0, which will later be updated by the session to return reg_id The thirtd element is the function to be called.

◆ CopyFromWorker0()

virtual void tvm::runtime::SessionObj::CopyFromWorker0 ( const NDArray host_array,
const DRef remote_array 
)
pure virtual

Copy an NDArray from worker-0 to the controler-side NDArray.

Parameters
host_arrayThe array to be copied to worker-0
remote_arrayThe NDArray on worker-0

◆ CopyToWorker0()

virtual void tvm::runtime::SessionObj::CopyToWorker0 ( const NDArray host_array,
const DRef remote_array 
)
pure virtual

Copy the controler-side NDArray to worker-0.

Parameters
host_arrayThe array to be copied to worker-0
remote_arrayThe NDArray on worker-0

◆ DeallocReg()

virtual void tvm::runtime::SessionObj::DeallocReg ( int  reg_id)
protectedpure virtual

Deallocate a register id, kill it on all workers, and append it to free_regs_.

◆ DebugGetFromRemote()

virtual ffi::Any tvm::runtime::SessionObj::DebugGetFromRemote ( int64_t  reg_id,
int  worker_id 
)
pure virtual

Get the value of a register from a remote worker.

Parameters
reg_idThe id of the register to be fetched.
worker_idThe id of the worker to be fetched from.
Returns
The value of the register.

◆ DebugSetRegister()

virtual void tvm::runtime::SessionObj::DebugSetRegister ( int64_t  reg_id,
ffi::AnyView  value,
int  worker_id 
)
pure virtual

Set the value of a register on a remote worker.

Parameters
reg_idThe id of the register to be set.
valueThe value to be set.
worker_idThe id of the worker to be set.

◆ GetGlobalFunc()

virtual DRef tvm::runtime::SessionObj::GetGlobalFunc ( const std::string &  name)
pure virtual

Get a global functions on workers.

◆ GetNumWorkers()

virtual int64_t tvm::runtime::SessionObj::GetNumWorkers ( )
pure virtual

Get the number of workers in the session.

◆ InitCCL()

virtual void tvm::runtime::SessionObj::InitCCL ( String  ccl,
IntTuple  device_ids 
)
pure virtual

Initialize the data plane between workers.

Parameters
cclThe name of the communication backend, e.g., nccl, rccl, mpi.
device_idsThe device ids of the workers.

◆ Shutdown()

virtual void tvm::runtime::SessionObj::Shutdown ( )
pure virtual

Signal all the workers to shutdown.

◆ SyncWorker()

virtual void tvm::runtime::SessionObj::SyncWorker ( int  worker_id)
pure virtual

Synchrnoize the controler with a worker, and it will wait until worker finishes executing this instruction.

Parameters
worker_idThe id of the worker to be synced with.
Note
This function is usually used for worker-0, because it is the only worker that is assumed to collocate with the controler. Syncing with other workers may not be supported.

◆ TVM_DECLARE_BASE_OBJECT_INFO()

tvm::runtime::SessionObj::TVM_DECLARE_BASE_OBJECT_INFO ( SessionObj  ,
Object   
)

Friends And Related Function Documentation

◆ DRefObj

friend class DRefObj
friend

◆ SessionObj::FFI

friend struct SessionObj::FFI
friend

Member Data Documentation

◆ _type_key

constexpr const char* tvm::runtime::SessionObj::_type_key = "runtime.disco.Session"
staticconstexpr

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