Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
async.c File Reference
#include "conf.h"
#include "async.h"
#include "utils/config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
+ Include dependency graph for ivshmem/async.c:

Go to the source code of this file.

Data Structures

struct  ivshmem
 

Enumerations

enum  RegisterOffsets { ISR_REG = 0 , IMR_REG = 1 , VM_ID_REG = 2 , BELL_REG = 3 }
 

Functions

void wakeupVm (async_meta_s *meta, unsigned int vm_id)
 
unsigned int getVmID (async_meta_s *meta)
 
void * async_thread (void *data)
 
void _add_completion (async_meta_s *meta, async_completion_s *completion)
 
void async_meta_init_once (async_meta_s *meta, arch_alloc_s *alloc)
 
void async_meta_init_always (async_meta_s *meta)
 
void async_completion_init (async_meta_s *meta, async_completion_s *completion)
 
void async_completion_complete (async_completion_s *completion)
 
void async_completion_wait (async_completion_s *completion)
 
int async_completion_check (async_completion_s *completion)
 
void async_semaphore_init (async_meta_s *meta, async_semaphore_s *sem)
 
int async_semaphore_value (async_semaphore_s *sem)
 
void async_semaphore_inc (async_semaphore_s *sem)
 
void async_semaphore_dec (async_semaphore_s *sem)
 
void async_condition_init (async_meta_s *meta, async_condition_s *cond)
 
void async_condition_lock (async_condition_s *cond)
 
void async_condition_wait (async_condition_s *cond)
 
void async_condition_notify (async_condition_s *cond)
 
void async_condition_unlock (async_condition_s *cond)
 
void async_meta_exit (async_meta_s *meta)
 

Variables

static int reg_fd = 0
 

Enumeration Type Documentation

◆ RegisterOffsets

Enumerator
ISR_REG 
IMR_REG 
VM_ID_REG 
BELL_REG 

Definition at line 13 of file ivshmem/async.c.

Function Documentation

◆ _add_completion()

void _add_completion ( async_meta_s * meta,
async_completion_s * completion )

Definition at line 64 of file ivshmem/async.c.

References async_meta_s::lock, async_completion_s::outstanding, async_meta_s::outstanding, utils_list_add(), utils_spinlock_lock, and utils_spinlock_unlock.

Referenced by async_completion_wait(), and async_semaphore_inc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ async_completion_check()

int async_completion_check ( async_completion_s * completion)

Check if completion has been marked as completed.

Parameters
completionCompletion to be checked.
Returns
0 if not completed, !0 if completed.

Definition at line 144 of file ivshmem/async.c.

Referenced by async_thread().

+ Here is the caller graph for this function:

◆ async_completion_complete()

void async_completion_complete ( async_completion_s * completion)

Mark compl as completed and notify pending async_completion_wait() callers.

Parameters
completionCompletion to be marked as completed.

Definition at line 129 of file ivshmem/async.c.

Referenced by async_condition_init(), async_condition_unlock(), async_condition_wait(), and async_semaphore_inc().

+ Here is the caller graph for this function:

◆ async_completion_init()

void async_completion_init ( async_meta_s * meta,
async_completion_s * completion )

Create and register async_completion_s objects created in buff.

Parameters
metaPointer to async_meta_s that will 'own' this completion.
completionCompletion to be initialized
Returns
Number of objects created, should be buff_size/async_completion_size().

Definition at line 118 of file ivshmem/async.c.

Referenced by async_condition_init(), and async_semaphore_dec().

+ Here is the caller graph for this function:

◆ async_completion_wait()

void async_completion_wait ( async_completion_s * completion)

Wait for compl to be completed with async_completion_complete().

Parameters
completionSleep untill it has been completed with async_completion_complete.

Definition at line 135 of file ivshmem/async.c.

Referenced by async_condition_lock(), async_condition_wait(), and async_semaphore_dec().

+ Here is the caller graph for this function:

◆ async_condition_init()

void async_condition_init ( async_meta_s * meta,
async_condition_s * cond )

Initialize semaphore.

Parameters
metaPointer to async_meta_s that will 'own' this semaphore.
condCondition to be initialized

Definition at line 206 of file ivshmem/async.c.

◆ async_condition_lock()

void async_condition_lock ( async_condition_s * cond)

Lock on condition cond.

Parameters
condCondition to be read.

Definition at line 213 of file ivshmem/async.c.

◆ async_condition_notify()

void async_condition_notify ( async_condition_s * cond)

Notify cond.

Note
Prior to this call cond must be locked using async_condition_lock().
Parameters
condCondition to be notified.

Definition at line 225 of file ivshmem/async.c.

◆ async_condition_unlock()

void async_condition_unlock ( async_condition_s * cond)

Lock on condition cond.

Note
Prior to this call cond must be locked using async_condition_lock().
Parameters
condCondition to be read.

Definition at line 230 of file ivshmem/async.c.

◆ async_condition_wait()

void async_condition_wait ( async_condition_s * cond)

Wait on cond.

Note
Prior to this call cond must be locked using async_condition_lock().
Parameters
condCondition to be read.

Definition at line 218 of file ivshmem/async.c.

◆ async_meta_exit()

void async_meta_exit ( async_meta_s * meta)

De initialize an async_meta_s object.

Parameters
metaThe async_meta_s object to be uninitialized.

Definition at line 235 of file ivshmem/async.c.

◆ async_meta_init_always()

void async_meta_init_always ( async_meta_s * meta)

Initialize a async_meta_s object on every node.

This will be called multiple times, once for every node.

Parameters
metaAn uninitialized async_meta_s object.

Definition at line 89 of file ivshmem/async.c.

◆ async_meta_init_once()

void async_meta_init_once ( async_meta_s * meta,
arch_alloc_s * alloc )

Initialize a async_meta_s object once.

This will be called only once, on the first node.

Parameters
metaAn uninitialized async_meta_s object.
allocAllocator instance to be used for internall allocations.

Definition at line 71 of file ivshmem/async.c.

◆ async_semaphore_dec()

void async_semaphore_dec ( async_semaphore_s * sem)

Decrease semaphore.

Decrease(ie consume) sem by one. This function will block if async_semaphore_value() == 0.

Parameters
semSemaphore to be increased.

Definition at line 181 of file ivshmem/async.c.

Referenced by async_condition_wait().

+ Here is the caller graph for this function:

◆ async_semaphore_inc()

void async_semaphore_inc ( async_semaphore_s * sem)

Increase semaphore.

Increase(ie produce) sem by one. This function will never block.

Parameters
semSemaphore to be increased.

Definition at line 161 of file ivshmem/async.c.

Referenced by async_condition_notify().

+ Here is the caller graph for this function:

◆ async_semaphore_init()

void async_semaphore_init ( async_meta_s * meta,
async_semaphore_s * sem )

Initialize semaphore.

Parameters
metaPointer to async_meta_s that will 'own' this semaphore.
semSemaphore to be initialized

Definition at line 149 of file ivshmem/async.c.

Referenced by async_condition_init().

+ Here is the caller graph for this function:

◆ async_semaphore_value()

int async_semaphore_value ( async_semaphore_s * sem)

Return value of sem.

Parameters
semSemaphore to be initialized

Definition at line 156 of file ivshmem/async.c.

◆ async_thread()

void * async_thread ( void * data)

Definition at line 37 of file ivshmem/async.c.

References async_completion_check(), getVmID(), async_completion_s::mutex, async_meta_s::outstanding, utils_list_node::owner, reg_fd, utils_list_del(), and utils_list_for_each_safe.

Referenced by async_meta_init_always().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVmID()

unsigned int getVmID ( async_meta_s * meta)

Definition at line 31 of file ivshmem/async.c.

References async_meta_s::regs, ivshmem::regs, and VM_ID_REG.

Referenced by async_completion_wait(), async_meta_exit(), async_semaphore_dec(), and async_thread().

+ Here is the caller graph for this function:

◆ wakeupVm()

void wakeupVm ( async_meta_s * meta,
unsigned int vm_id )

Definition at line 26 of file ivshmem/async.c.

References BELL_REG, async_meta_s::regs, and ivshmem::regs.

Referenced by async_completion_complete(), async_meta_exit(), and async_semaphore_dec().

+ Here is the caller graph for this function:

Variable Documentation

◆ reg_fd

int reg_fd = 0
static

Definition at line 36 of file ivshmem/async.c.

Referenced by async_meta_init_always(), and async_thread().