Skip to content
Snippets Groups Projects
Commit 56743af8 authored by rtekin's avatar rtekin
Browse files

add reschedFpSingle and prudaUsing code

parent 388a27d5
Branches
No related tags found
No related merge requests found
\documentclass[varwidth=10cm, border={0.5cm 0.1cm 0.1cm 0.1cm}]{standalone}
\documentclass[varwidth=15cm, border={0.5cm 0.1cm 0.1cm 0.1cm}]{standalone}
\usepackage{minted}
\begin{document}
%------------------------------------------------------------------------------
\begin{figure}
\centering
\begin{minted}[gobble=0,frame=lines]{c}
#define N 8
__global__ void add(int *a, int *b, int *c) {
int tid = blockDim.x * blockIdx.x + threadIdx.x;
while (tid < N) {
c[tid] = a[tid] + b[tid];
tid += blockDim.x;
}
}
int main(){
int *dev_a, *dev_b, *dev_c;
//Memory allocation and initializing
//Kernel initializing
init_kernel_listing();
create_kernel(std::get<0>(get_listing()), add, 2, 5, dev_a, dev_b, dev_c);
//Periodic task parameters
struct gpu_sched_param ga;
ga.period_us = 5000;
ga.deadline_us= 5000;
ga.priority = 3;
//Periodic task creation
struct pruda_task_t * p_task_a = create_pruda_task(0, ga, 1, 1);
//Using Fixed Priority algorithm with the Single-stream strategy
init_scheduler(SINGLE, FP);
add_pruda_task(p_task_a);
//One CPU thread per CUDA kernel (see pruda_task() function example above)
create_cpu_threads();
//CPU operations
//Memory free
return 0;
}
\end{minted}
\end{figure}
% \begin{figure}
% \centering
% \begin{minted}[gobble=0,frame=lines]{c}
%void pruda_resched_fp_single(){
% pthread_mutex_lock(&(scheduler->mut));
% if (scheduler->lsq_free == 1) {
% pthread_mutex_unlock(&(scheduler->mut));
% return;
% }
% sched_on_lsq();
% pthread_mutex_unlock(&(scheduler->mut));
%}
% \end{minted}
%
% %\caption{Pseudo-code of pruda\_resched\_fp\_single()}
%%\label{algo:reschedFpSingle}
%\end{figure}
%--------- ADD TASK
% \begin{figure}
% \centering
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment