![]() |
GPUart
1.01
Prototype of GPUart, an application-based limited preemptive GPU scheduler for embedded real-time systems
|
Implementation of the GPUart Scheduling layer. More...
#include "GPUart_Scheduler.h"#include "../GPUart_Impl/GPUart_Impl_Sched_IF.h"#include "../SW-C/Scheduler/SWC_Scheduler.h"#include <string.h>#include <pthread.h>
Classes | |
| struct | job_s |
| Data type for job (kernel instance), including the kernel ID and the jobs priority. More... | |
| struct | job_priority_list_s |
| Data type for the priority list (gpuS_JobList_s) which holds all active jobs (kernel instances). More... | |
| struct | job_stack_s |
| Data type for the priority stacks (gpuS_JobStackShared_s and gpuS_JobStack_s) which hold new jobs (kernel instances). More... | |
Macros | |
| #define | S_POLICY_EDF (1) |
| Scheduling policy: Gang Earliest Deadline First (Gang-EDF) More... | |
| #define | S_POLICY_FTP (2) |
| Scheduling policy: Gang Fixed Task Priority (Gang-FTP). Set deadlines in gpuS_relDeadlines_u32 to the period times to get Gang Rate Monotonic scheduling (Gang-RM). More... | |
| #define | S_SCHED_POLICY S_POLICY_EDF |
| Set S_SCHED_POLICY to either S_POLICY_EDF or S_POLICY_FTP. More... | |
| #define | C_GPUS_RESOURCE_FACTOR 1 |
| Defines the resource factor µ, that is, how many thread blocks are allowed per Streaming Multiprocessor. More... | |
Functions | |
| static GPUart_Retval | gpuS_priorityList_insert (job_priority_list_s *pJobList, job_s pJob) |
| Insert a job into a priority based list. More... | |
| static GPUart_Retval | gpuS_priorityList_delete (job_priority_list_s *pJobList, uint8 pId) |
| Delete a job from a priority based list. More... | |
| static GPUart_Retval | gpuS_jobStack_push (job_stack_s *pJobStack, job_s pJob) |
| Push a new kernel instance to the shared job stack. More... | |
| static GPUart_Retval | gpuS_jobStack_copy (job_stack_s *pJobStackDest, job_stack_s *pJobStackSrc) |
| Copies a job stack job_stack_s. More... | |
| static GPUart_Retval | gpuS_jobStack_pull (job_stack_s *pJobStack, job_s *pJob) |
| Pull a job from a job stack. More... | |
| static GPUart_Retval | gpuS_getPriority (kernel_task_id_e task_id_e, uint32 *priority) |
| Get the priority of a job (kernel instance). More... | |
| static GPUart_Retval | gpuS_updateListWithNewJobs (void) |
| Updates a priority based job list with all new released jobs. More... | |
| static GPUart_Retval | gpuS_updateRunningStatus (void) |
| Updates a the scheduling state (gpuS_kernelTaskStatus_e) of each kernel. More... | |
| GPUart_Retval | gpuS_schedule (void) |
| Executes the scheduling decision. More... | |
| GPUart_Retval | gpuS_new_Job (kernel_task_id_e task_id_e) |
| Releases a new job and pushes it to the shared job stack gpuS_JobStackShared_s. More... | |
| GPUart_Retval | gpuS_query_terminated (kernel_task_id_e task_id_e) |
| Queries whether a job has terminated. More... | |
| GPUart_Retval | gpuS_query_ready_to_call (kernel_task_id_e task_id_e) |
| Queries whether a kernel is ready to get instantiated. More... | |
| GPUart_Retval | gpuS_init (void) |
| Initializes the GPUart Scheduling layer. More... | |
| GPUart_Retval | gpuS_destroy (void) |
| Destroys the GPUart Scheduling layer. More... | |
Variables | |
| static job_priority_list_s | gpuS_JobList_s |
| The priority ordered list which manages all active jobs. More... | |
| static job_stack_s | gpuS_JobStackShared_s |
| The shared stack which holds all new jobs. More... | |
| static job_stack_s | gpuS_JobStack_s |
| The private stack which holds all new jobs. It is a copy of gpuS_JobStackShared_s. More... | |
| static sint8 | gpuS_ktRunFlags_new_s8 [E_KTID_NUMBER_OF_KERNEL_TASKS] = {0} |
| An array which holds the current running status of each kernel. More... | |
| static sint8 | gpuS_ktRunFlags_old_s8 [E_KTID_NUMBER_OF_KERNEL_TASKS] = {0} |
| An array which holds the running status of each kernel from the last scheduling decision. More... | |
| static uint32 | gpuS_relDeadlines_u32 [E_KTID_NUMBER_OF_KERNEL_TASKS] |
| An array for the configuration of the kernels' relative deadlines in µs. More... | |
| static enum gpuS_kernelTask_status_e | gpuS_kernelTaskStatus_e [E_KTID_NUMBER_OF_KERNEL_TASKS] |
| An array which represents the state machine for each kernel. More... | |
| static uint32 | gpuS_nrOfMultiprocessor_u32 = 0u |
| Represents the number of Streaming Multiprocessors m on the GPU. More... | |
Implementation of the GPUart Scheduling layer.
| #define C_GPUS_RESOURCE_FACTOR 1 |
Defines the resource factor µ, that is, how many thread blocks are allowed per Streaming Multiprocessor.
| #define S_POLICY_EDF (1) |
Scheduling policy: Gang Earliest Deadline First (Gang-EDF)
| #define S_POLICY_FTP (2) |
Scheduling policy: Gang Fixed Task Priority (Gang-FTP). Set deadlines in gpuS_relDeadlines_u32 to the period times to get Gang Rate Monotonic scheduling (Gang-RM).
| #define S_SCHED_POLICY S_POLICY_EDF |
Set S_SCHED_POLICY to either S_POLICY_EDF or S_POLICY_FTP.
| GPUart_Retval gpuS_destroy | ( | void | ) |
Destroys the GPUart Scheduling layer.
Destroys the mutex of each job_stack_s.

|
static |
Get the priority of a job (kernel instance).
Returns the priority of a job. The smaller the value, the higher the priority.
| [in] | kernel_task_id_e | task_id_e, -> The kernel for which the priority should be returned. |
| [out] | uint8 | pId -> The priority of the kernel instance. |


| GPUart_Retval gpuS_init | ( | void | ) |
Initializes the GPUart Scheduling layer.
Initializes all variables of the Scheduling layer.


|
static |
Copies a job stack job_stack_s.
Make a copy of the shared job stack an save its content into the non-shared job stack of the GPUart scheduling host.
| [in] | job_stack_s | * pJobStackDest -> The job_stack_s to be copied. |
| [out] | job_stack_s | * pJobStackSrc -> The copy of pJobStackDest |

|
static |
Pull a job from a job stack.
Befor each scheduling decision, the scheduler pulls all jobs from gpuS_JobStack_s and insert them into gpuS_JobList_s in priority based order.
| [in] | job_stack_s | * pJobStack -> The job_stack_s from which this function pulls a job_s. |
| [out] | job_s | * pJob -> The job_s to be pulled. |

|
static |
Push a new kernel instance to the shared job stack.
This function is called, when a new kernel instance has been activated due to a call to a kernel's call-function in GPUart_Service_IF.h. The new job is pushed on the shared job stack, which is accessed in a mutual exlusive manner.
| [out] | job_stack_s | * pJobStack -> The shared job stack |
| [in] | job_s | pJob -> The new job to be released |

| GPUart_Retval gpuS_new_Job | ( | kernel_task_id_e | task_id_e | ) |
Releases a new job and pushes it to the shared job stack gpuS_JobStackShared_s.
| kernel_task_id_e | task_id_e -> The ID of the kernel which this function instatiates. |


|
static |
Delete a job from a priority based list.
After a job (kernel instance) has been completed, it is deleted from the list gpuS_JobList_s
| [out] | job_priority_list_s | * pJobList -> The job_priority_list_s from which this function deletes a job. |
| [in] | uint8 | pId -> The index of the list element wich is deleted by this function. |

|
static |
Insert a job into a priority based list.
Befor each scheduling decision, the scheduler pulls all jobs from gpuS_JobStack_s and insert them into gpuS_JobList_s in priority based order. The job list gpuS_JobList_s contains all active kernels.
| [out] | job_priority_list_s | * pJobList -> The job_priority_list_s in which this function inserts a job. |
| [in] | job_s | pJob -> The job_s to be inserted. |

| GPUart_Retval gpuS_query_ready_to_call | ( | kernel_task_id_e | task_id_e | ) |
Queries whether a kernel is ready to get instantiated.
| kernel_task_id_e | task_id_e -> The ID of the kernel. |

| GPUart_Retval gpuS_query_terminated | ( | kernel_task_id_e | task_id_e | ) |
Queries whether a job has terminated.
| kernel_task_id_e | task_id_e -> The ID of the kernel. |

| GPUart_Retval gpuS_schedule | ( | void | ) |
Executes the scheduling decision.
If the compiler switch S_NON_PREEMPTIVE is defined, this function schedules kernel non-preemptively, otherwise it schedules them in a limited preemptive manner. First this function updates the kernel's scheduling state and deletes completed kernels form gpuS_JobList_s, then it updates the job list gpuS_JobList_s with all new released kernels. After that, this function iterates through gpuS_JobList_s and executes the scheduling decision according to the scheduling policy defined in S_SCHED_POLICY.


|
static |
Updates a priority based job list with all new released jobs.
Befor each scheduling decision, the scheduler pulls all jobs from gpuS_JobStack_s and insert them into gpuS_JobList_s in priority based order. The job list gpuS_JobList_s contains all active kernels.


|
static |
Updates a the scheduling state (gpuS_kernelTaskStatus_e) of each kernel.
Befor each scheduling decision the scheduler polls each active job in gpuS_JobList_s if it has been terminated or preempted. Terminated jobs are deleted in gpuS_JobList_s by calling gpuS_priorityList_delete(). The state of the corresponding kernel instance is set to E_STATUS_TERMINATED. If a kernel has been preempted, its state set to E_STATUS_READY.


|
static |
The priority ordered list which manages all active jobs.
|
static |
The private stack which holds all new jobs. It is a copy of gpuS_JobStackShared_s.
This stack is used to reduce the blocking times, resulting by the mutual exclusive access, by copying the content of gpuS_JobStackShared_s into this stack. The scheduler periodically pulls new jobs from this stack and inserts them into gpuS_JobList_s in a priority order.
|
static |
The shared stack which holds all new jobs.
This stack can be accessed by any thread via the call-interface of a kernel in the Abstraction layer (GPUart_Service_IF.h). Data integrity is assured by mutual exclusion.
|
static |
An array which represents the state machine for each kernel.
The length of this array is equal to the number of kernels E_KTID_NUMBER_OF_KERNEL_TASKS. The i'th element represents the i'th kernel, according to the enum kernel_task_id_e. A kernel can be either INIT, READY, RUNNING, or TERMINATED.
|
static |
An array which holds the current running status of each kernel.
The length of this array is equal to the number of kernels E_KTID_NUMBER_OF_KERNEL_TASKS. The i'th element represents the i'th kernel, according to the enum kernel_task_id_e. If an element is equal to 0, then this kernel is NOT running currently. Otherwise, the corresponding kernel is running. The array gets updated with each scheduling decision.
|
static |
An array which holds the running status of each kernel from the last scheduling decision.
|
static |
Represents the number of Streaming Multiprocessors m on the GPU.
|
static |
An array for the configuration of the kernels' relative deadlines in µs.
The length of this array is equal to the number of kernels E_KTID_NUMBER_OF_KERNEL_TASKS. The i'th element represents the i'th kernel, according to the enum kernel_task_id_e.
1.8.6