Nebula
Loading...
Searching...
No Matches
jobs.h File Reference
#include "ids/id.h"
#include "ids/idallocator.h"
#include "threading/thread.h"
#include "threading/event.h"
#include "threading/safequeue.h"
#include "util/stringatom.h"
#include <atomic>

Go to the source code of this file.

Classes

struct  Jobs::JobFuncContext
 This class describes the size of a workload for a single thread (can be multiple items). More...
struct  Jobs::JobIOData
struct  Jobs::JobUniformData
struct  Jobs::JobContext
class  Jobs::JobThread
struct  Jobs::JobThread::JobThreadCommand
struct  Jobs::JobId
struct  Jobs::JobPortId
struct  Jobs::JobSyncId
struct  Jobs::CreateJobPortInfo
struct  Jobs::CreateJobInfo
struct  Jobs::PrivateMemory
struct  Jobs::CreateJobSyncInfo

Namespaces

namespace  Jobs
 Job system allows for scheduling and execution of a parallel task.

Macros

#define JOBFUNCCONTEXT_MAXIO   8
#define JOBFUNCCONTEXT_MAXUNIFORMS   4
#define N_JOB_INPUT(ctx, slice, index)
#define N_JOB_OUTPUT(ctx, slice, index)

Typedefs

typedef Ids::IdAllocator< Util::StringAtom, Util::FixedArray< Ptr< JobThread > >, uintJobs::JobPortAllocator
typedef Ids::IdAllocator< CreateJobInfo, std::function< void()>, PrivateMemoryJobs::JobAllocator
typedef Ids::IdAllocator< std::function< void()>, Threading::Event *, std::atomic_uint *, bool > Jobs::JobSyncAllocator

Enumerations

enum  { Jobs::JobPort_Name , Jobs::JobPort_Threads , Jobs::JobPort_NextThreadIndex }
enum  { Jobs::Job_CreateInfo , Jobs::Job_CallbackFunc , Jobs::Job_ScratchMemory }
enum  { Jobs::SyncCallback , Jobs::SyncCompletionEvent , Jobs::SyncCompletionCounter , Jobs::SyncPendingSignal }

Functions

JobPortId Jobs::CreateJobPort (const CreateJobPortInfo &info)
 create a new job port
void Jobs::DestroyJobPort (const JobPortId &id)
 destroy job port
bool Jobs::JobPortBusy (const JobPortId &id)
 check to see if port is idle
JobId Jobs::CreateJob (const CreateJobInfo &info)
 create job
void Jobs::DestroyJob (const JobId &id)
 delete job
void Jobs::JobSchedule (const JobId &job, const JobPortId &port, const JobContext &ctx, const bool cycleThreads=true)
 schedule job to be executed
void Jobs::JobSchedule (const JobId &job, const JobPortId &port, const JobContext &ctx, const std::function< void()> &callback, const bool cycleThreads=true)
 schedule job with callback when finished
void Jobs::JobSchedule (const JobId &job, const JobPortId &port)
 schedule job without a context
void Jobs::JobSchedule (const JobId &job, const JobPortId &port, void *ctx, SizeT count, SizeT groupSize, const bool cycleThreads=true)
 schedule a job with a poiunter as context and a work group size and item count
void Jobs::JobScheduleSequence (const Util::Array< JobId > &jobs, const JobPortId &port, const Util::Array< JobContext > &contexts)
 schedule a sequence of jobs
void Jobs::JobScheduleSequence (const Util::Array< JobId > &jobs, const JobPortId &port, const Util::Array< JobContext > &contexts, const std::function< void()> &callback)
 schedule a sequence of jobs
void * Jobs::JobAllocateScratchMemory (const JobId &job, const Memory::HeapType heap, const SizeT size)
 allocate memory for job
JobSyncId Jobs::CreateJobSync (const CreateJobSyncInfo &info)
 create job sync
void Jobs::DestroyJobSync (const JobSyncId id)
 destroy job sync
void Jobs::JobSyncHostReset (const JobSyncId id)
 reset job sync on host
void Jobs::JobSyncHostSignal (const JobSyncId id, bool reset=true)
 signal job sync on host
void Jobs::JobSyncThreadSignal (const JobSyncId id, const JobPortId port, bool reset=true)
 put job sync on port, if reset is true, reset prior to signaling
void Jobs::JobSyncHostWait (const JobSyncId id, bool reset=false)
 wait for job on host side, if reset is true, resets after waiting
void Jobs::JobSyncThreadWait (const JobSyncId id, const JobPortId port, bool reset=false)
 wait for job on thread side, if reset is true, reset after waiting
bool Jobs::JobSyncSignaled (const JobSyncId id)
 returns true if sync object has been signaled

Macro Definition Documentation

◆ JOBFUNCCONTEXT_MAXIO

#define JOBFUNCCONTEXT_MAXIO   8

◆ JOBFUNCCONTEXT_MAXUNIFORMS

#define JOBFUNCCONTEXT_MAXUNIFORMS   4

◆ N_JOB_INPUT

#define N_JOB_INPUT ( ctx,
slice,
index )
Value:
(ctx.inputs[index] + slice * ctx.inputSizes[index])

◆ N_JOB_OUTPUT

#define N_JOB_OUTPUT ( ctx,
slice,
index )
Value:
(ctx.outputs[index] + slice * ctx.outputSizes[index])