Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
PxSpuTask Class Reference

A task to be executed on one or more SPUs. More...

#include <PxSpuTask.h>

Inheritance diagram for PxSpuTask:
Inheritance graph
[legend]
Collaboration diagram for PxSpuTask:
Collaboration graph
[legend]

Public Member Functions

 PxSpuTask (const void *elfStart, PxU32 elfSize, PxU32 numSpus=1, const PxU32 *args=NULL)
 Construct a new PxSpuTask object. More...
 
virtual ~PxSpuTask ()
 
PX_INLINE PxU32 getSpuCount () const
 Return the number of SPUs used to run this task. More...
 
PX_INLINE void setSpuCount (PxU32 numSpusToRun)
 Set the number of SPUs to be used when running this task. More...
 
PX_INLINE const PxU32getArgs (PxU32 spuIndex) const
 Retrieve the per-SPU argument. More...
 
PX_INLINE void setArgs (PxU32 spuIndex, PxU32 arg0, PxU32 arg1)
 Set the arguments for a given SPU worker. More...
 
PX_INLINE const void * getElfStart () const
 Return the address to the start of the embedded elf binary for this task. More...
 
PX_INLINE PxU32 getElfSize () const
 Return the size of the embedded elf binary for this task. More...
 
PX_INLINE void notifySpuFinish ()
 Called by the SpuDispatcher when a SPU worker has completed, when all workers have completed the task is considered finished and the continuation will have it's ref count decremented. More...
 
virtual void removeReference ()
 Modifies PxLightCpuTask's behavior by submitting to the SpuDispatcher. More...
 
virtual void run ()
 Allow the task to perform PPU side intialization before the task is scheduled to the SPUs. More...
 
void runProfiled ()
 The same as run() but will emit PVD profile events. More...
 
- Public Member Functions inherited from PxLightCpuTask
 PxLightCpuTask ()
 
virtual ~PxLightCpuTask ()
 
PX_INLINE void setContinuation (PxTaskManager &tm, PxBaseTask *c)
 Initialize this task and specify the task that will have its ref count decremented on completion. More...
 
PX_INLINE void setContinuation (PxBaseTask *c)
 Initialize this task and specify the task that will have its ref count decremented on completion. More...
 
PX_INLINE PxBaseTaskgetContinuation () const
 Retrieves continuation task. More...
 
PX_INLINE void removeReference ()
 Manually decrement this task's reference count. If the reference count reaches zero, the task will be dispatched. More...
 
PX_INLINE PxI32 getReference () const
 Return the ref-count for this task. More...
 
PX_INLINE void addReference ()
 Manually increment this task's reference count. The task will not be allowed to run until removeReference() is called. More...
 
PX_INLINE void release ()
 called by CpuDispatcher after run method has completed More...
 
- Public Member Functions inherited from PxBaseTask
 PxBaseTask ()
 
virtual ~PxBaseTask ()
 
virtual const char * getName () const =0
 Return a user-provided task name for profiling purposes. More...
 
PX_INLINE void runProfiled (PxU32 threadId=0)
 Execute user run method with wrapping profiling events. More...
 
PX_INLINE void setProfileStat (PxU16 stat)
 Specify stop event statistic. More...
 
PX_INLINE PxTaskManagergetTaskManager () const
 Return PxTaskManager to which this task was submitted. More...
 

Static Public Attributes

static const PxU32 kMaxSpus = 6
 The maximum number of SPUs. More...
 
static const PxU32 kArgsPerSpu = 2
 Arguments per SPU. More...
 

Protected Attributes

const void * mElfStart
 A pointer to the start of the ELF image. More...
 
PxU32 mElfSize
 The size of the ELF image. More...
 
PxU32 mNbSpusToRun
 The number of SPUs to run. More...
 
PxU32 mNbSpusFinished
 The number of SPUs finished. More...
 
PxU32 mArgs [kMaxSpus][kArgsPerSpu]
 The arguments for the SPUs. More...
 
bool mEmitProfile
 Stores the profile event state if runProfiled() is used. More...
 
- Protected Attributes inherited from PxLightCpuTask
PxBaseTaskmCont
 Continuation task, can be NULL. More...
 
volatile PxI32 mRefCount
 PxTask is dispatched when reaches 0. More...
 
- Protected Attributes inherited from PxBaseTask
PxU16 mEventID
 Registered profile event ID. More...
 
PxU16 mProfileStat
 Profiling statistic. More...
 
PxTaskManagermTm
 Owning PxTaskManager instance. More...
 

Detailed Description

A task to be executed on one or more SPUs.

Each PxSpuTask can run in a data parallel fashion on up to 6 SPUs. To coordinate the workers, each SPU will be passed its own set of arguments.

When all SPU workers have completed their work, the task is considered complete and the SpuDispatcher will call release on the task, this in turn will call removeReference() on the task's continuation.

In this way LightCpuTasks may be launched automatically at PxSpuTask completion and vice versa.

Users should not need to implement or create SpuTasks directly. The SDK creates the tasks internally and will submit them to the TaskManager's SpuDispatcher for execution. The SpuDispatcher that will be used is configured on a per-scene basis through the PxSceneDesc.

See Also
SpuDispatcher
PxSceneDesc

Constructor & Destructor Documentation

PxSpuTask::PxSpuTask ( const void *  elfStart,
PxU32  elfSize,
PxU32  numSpus = 1,
const PxU32 args = NULL 
)
inline

Construct a new PxSpuTask object.

Parameters
[in]elfStartThe starting address of the embedded SPU binary
[in]elfSizeThe size in bytes of the embedded SPU binary
[in]numSpusThe number of SPU workers this task will run across
[in]argsA pointer to an array of arguments, must be at least kArgsPerSpu*numSpus big
virtual PxSpuTask::~PxSpuTask ( )
inlinevirtual

Member Function Documentation

PX_INLINE const PxU32* PxSpuTask::getArgs ( PxU32  spuIndex) const
inline

Retrieve the per-SPU argument.

Parameters
[in]spuIndexThe SPU that we want to retrieve the argument for
Returns
A pointer to the parameters for the given SPU index

References PX_ASSERT.

PX_INLINE PxU32 PxSpuTask::getElfSize ( ) const
inline

Return the size of the embedded elf binary for this task.

PX_INLINE const void* PxSpuTask::getElfStart ( ) const
inline

Return the address to the start of the embedded elf binary for this task.

PX_INLINE PxU32 PxSpuTask::getSpuCount ( ) const
inline

Return the number of SPUs used to run this task.

PX_INLINE void PxSpuTask::notifySpuFinish ( )
inline

Called by the SpuDispatcher when a SPU worker has completed, when all workers have completed the task is considered finished and the continuation will have it's ref count decremented.

virtual void PxSpuTask::removeReference ( )
inlinevirtual

Modifies PxLightCpuTask's behavior by submitting to the SpuDispatcher.

Implements PxBaseTask.

References PX_ASSERT.

virtual void PxSpuTask::run ( )
inlinevirtual

Allow the task to perform PPU side intialization before the task is scheduled to the SPUs.

This should be called by the SpuDispatcher from whichever thread calls submitTask(); the task should be scheduled to the SPUs immediately following this function returning.

Implements PxBaseTask.

void PxSpuTask::runProfiled ( )
inline

The same as run() but will emit PVD profile events.

PX_INLINE void PxSpuTask::setArgs ( PxU32  spuIndex,
PxU32  arg0,
PxU32  arg1 
)
inline

Set the arguments for a given SPU worker.

Parameters
[in]spuIndexThe index of the SPU worker whose arguments are to be set
[in]arg0The first argument to be passed to this worker
[in]arg1The second argument to be passed to this worker

References PX_ASSERT.

PX_INLINE void PxSpuTask::setSpuCount ( PxU32  numSpusToRun)
inline

Set the number of SPUs to be used when running this task.

References PX_ASSERT.

Member Data Documentation

const PxU32 PxSpuTask::kArgsPerSpu = 2
static

Arguments per SPU.

const PxU32 PxSpuTask::kMaxSpus = 6
static

The maximum number of SPUs.

PxU32 PxSpuTask::mArgs[kMaxSpus][kArgsPerSpu]
protected

The arguments for the SPUs.

PxU32 PxSpuTask::mElfSize
protected

The size of the ELF image.

const void* PxSpuTask::mElfStart
protected

A pointer to the start of the ELF image.

bool PxSpuTask::mEmitProfile
protected

Stores the profile event state if runProfiled() is used.

PxU32 PxSpuTask::mNbSpusFinished
protected

The number of SPUs finished.

PxU32 PxSpuTask::mNbSpusToRun
protected

The number of SPUs to run.


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


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com