Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
inject.cpp File Reference
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <dlfcn.h>
#include <adaptyst/inject.h>
#include <adaptyst/hw_inject.h>
#include <adaptyst/socket.hpp>
#include <time.h>
#include <iostream>
#include <mutex>

Classes

class  adaptyst::Injection
 

Namespaces

namespace  adaptyst
 

Macros

#define _GNU_SOURCE
 

Functions

int handle_error_if_any (int code, const char *type)
 
int _adaptyst_init_custom_buf_size (unsigned int size)
 
int _adaptyst_init ()
 
const char ** adaptyst_get_runtime_info ()
 
charadaptyst_get_error_msg ()
 
int _adaptyst_region_start (const char *name)
 
int _adaptyst_region_end (const char *name)
 
void adaptyst_close ()
 
int _adaptyst_send_data (amod_t id, char *buf, unsigned int n)
 
int _adaptyst_receive_data (amod_t id, char *buf, unsigned int buf_size, int *n)
 
int _adaptyst_receive_data_timeout (amod_t id, char *buf, unsigned int buf_size, int *n, long timeout_seconds)
 
int _adaptyst_send_string (amod_t id, const char *str)
 
int _adaptyst_receive_string (amod_t id, const char **str)
 
int _adaptyst_receive_string_timeout (amod_t id, const char **str, long timeout_seconds)
 
int adaptyst_send_data (amod_t id, char *buf, unsigned int n)
 
int adaptyst_receive_data (amod_t id, char *buf, unsigned int buf_size, int *n)
 
int adaptyst_receive_data_timeout (amod_t id, char *buf, unsigned int buf_size, int *n, long timeout_seconds)
 
int adaptyst_send_string (amod_t id, const char *str)
 
int adaptyst_receive_string (amod_t id, const char **str)
 
int adaptyst_receive_string_timeout (amod_t id, const char **str, long timeout_seconds)
 
int adaptyst_send_data_nl (amod_t id, char *buf, unsigned int n)
 
int adaptyst_receive_data_nl (amod_t id, char *buf, unsigned int buf_size, int *n)
 
int adaptyst_receive_data_timeout_nl (amod_t id, char *buf, unsigned int buf_size, int *n, long timeout_seconds)
 
int adaptyst_send_string_nl (amod_t id, const char *str)
 
int adaptyst_receive_string_nl (amod_t id, const char **str)
 
int adaptyst_receive_string_timeout_nl (amod_t id, const char **str, long timeout_seconds)
 
void adaptyst_set_print_errors (unsigned int print)
 
int adaptyst_init ()
 
int adaptyst_init_custom_buf_size (unsigned int size)
 
int adaptyst_region_start (const char *name)
 
int adaptyst_region_end (const char *name)
 
void adaptyst_set_error (const char *msg)
 
void adaptyst_set_error_nl (const char *msg)
 
unsigned long long adaptyst_get_timestamp (int *err)
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Function Documentation

◆ _adaptyst_init()

int _adaptyst_init ( )

◆ _adaptyst_init_custom_buf_size()

int _adaptyst_init_custom_buf_size ( unsigned int  size)

◆ _adaptyst_receive_data()

int _adaptyst_receive_data ( amod_t  id,
char buf,
unsigned int  buf_size,
int n 
)

◆ _adaptyst_receive_data_timeout()

int _adaptyst_receive_data_timeout ( amod_t  id,
char buf,
unsigned int  buf_size,
int n,
long  timeout_seconds 
)

◆ _adaptyst_receive_string()

int _adaptyst_receive_string ( amod_t  id,
const char **  str 
)

◆ _adaptyst_receive_string_timeout()

int _adaptyst_receive_string_timeout ( amod_t  id,
const char **  str,
long  timeout_seconds 
)

◆ _adaptyst_region_end()

int _adaptyst_region_end ( const char name)

◆ _adaptyst_region_start()

int _adaptyst_region_start ( const char name)

◆ _adaptyst_send_data()

int _adaptyst_send_data ( amod_t  id,
char buf,
unsigned int  n 
)

◆ _adaptyst_send_string()

int _adaptyst_send_string ( amod_t  id,
const char str 
)

◆ adaptyst_close()

void adaptyst_close ( )

◆ adaptyst_get_error_msg()

char * adaptyst_get_error_msg ( )

◆ adaptyst_get_runtime_info()

const char ** adaptyst_get_runtime_info ( )

◆ adaptyst_get_timestamp()

unsigned long long adaptyst_get_timestamp ( int err)

◆ adaptyst_init()

int adaptyst_init ( )

◆ adaptyst_init_custom_buf_size()

int adaptyst_init_custom_buf_size ( unsigned int  size)

◆ adaptyst_receive_data()

int adaptyst_receive_data ( amod_t  id,
char buf,
unsigned int  buf_size,
int n 
)

Receives data from the injection part of the module in a workflow, with no timeout.

Parameters
idThe module ID (use module_id).
bufBuffer where received data should be stored.
buf_sizeSize of the buffer in bytes.
nPointer to a variable where the number of received bytes should be stored.
Returns
Whether the operation has been successful.

◆ adaptyst_receive_data_nl()

int adaptyst_receive_data_nl ( amod_t  id,
char buf,
unsigned int  buf_size,
int n 
)

◆ adaptyst_receive_data_timeout()

int adaptyst_receive_data_timeout ( amod_t  id,
char buf,
unsigned int  buf_size,
int n,
long  timeout_seconds 
)

Receives data from the injection part of the module in a workflow, with a specific timeout.

Parameters
idThe module ID (use module_id).
bufBuffer where received data should be stored.
buf_sizeSize of the buffer in bytes.
nPointer to a variable where the number of received bytes should be stored.
timeout_secondsTimeout in seconds.
Returns
Whether the operation has been successful (it's false with adaptyst_get_internal_error_code() returning ADAPTYST_ERR_TIMEOUT in case of timeout).

◆ adaptyst_receive_data_timeout_nl()

int adaptyst_receive_data_timeout_nl ( amod_t  id,
char buf,
unsigned int  buf_size,
int n,
long  timeout_seconds 
)

◆ adaptyst_receive_string()

int adaptyst_receive_string ( amod_t  id,
const char **  str 
)

Receives a string from the injection part of the module in a workflow, with no timeout.

If the sender has sent n strings using adaptyst_send_string() (where n is a positive integer), adaptyst_receive_string() or its timeout variant must be called n times to receive all of these, in the order they have been sent in.

Parameters
idThe module ID (use module_id).
strPointer to a variable where the received string should be stored. If 0 bytes are received, the variable is set to a null pointer.
Returns
Whether the operation has been successful.

◆ adaptyst_receive_string_nl()

int adaptyst_receive_string_nl ( amod_t  id,
const char **  str 
)

◆ adaptyst_receive_string_timeout()

int adaptyst_receive_string_timeout ( amod_t  id,
const char **  str,
long  timeout_seconds 
)

Receives a string from the injection part of the module in a workflow, with a specific timeout.

If the sender has sent n strings using adaptyst_send_string() (where n is a positive integer), adaptyst_receive_string_timeout() or its non-timeout variant must be called n times to receive all of these, in the order they have been sent in.

Parameters
idThe module ID (use module_id).
strPointer to a variable where the received string should be stored. If 0 bytes are received, the variable is set to a null pointer.
timeout_secondsTimeout in seconds.
Returns
Whether the operation has been successful (it's false with adaptyst_get_internal_error_code() returning ADAPTYST_ERR_TIMEOUT in case of timeout).

◆ adaptyst_receive_string_timeout_nl()

int adaptyst_receive_string_timeout_nl ( amod_t  id,
const char **  str,
long  timeout_seconds 
)

◆ adaptyst_region_end()

int adaptyst_region_end ( const char name)

◆ adaptyst_region_start()

int adaptyst_region_start ( const char name)

◆ adaptyst_send_data()

int adaptyst_send_data ( amod_t  id,
char buf,
unsigned int  n 
)

Sends data to the injection part of the module in a workflow.

Parameters
idThe module ID (use module_id).
bufData to send.
nNumber of bytes to send.
Returns
Whether the operation has been successful.

◆ adaptyst_send_data_nl()

int adaptyst_send_data_nl ( amod_t  id,
char buf,
unsigned int  n 
)

◆ adaptyst_send_string()

int adaptyst_send_string ( amod_t  id,
const char str 
)

Sends a string to the injection part of the module in a workflow.

The recipient receives strings in the same order they are sent in as long as the sender uses adaptyst_send_string() and the receiver uses adaptyst_receive_string() or its timeout variant.

Parameters
idThe module ID (use module_id).
strString to send.
Returns
Whether the operation has been successful.

◆ adaptyst_send_string_nl()

int adaptyst_send_string_nl ( amod_t  id,
const char str 
)

◆ adaptyst_set_error()

void adaptyst_set_error ( const char msg)

◆ adaptyst_set_error_nl()

void adaptyst_set_error_nl ( const char msg)

◆ adaptyst_set_print_errors()

void adaptyst_set_print_errors ( unsigned int  print)

◆ handle_error_if_any()

int handle_error_if_any ( int  code,
const char type 
)