1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef __DADA_CLIENT_H
#define __DADA_CLIENT_H
/* ************************************************************************
dada_client_t - a struct and associated routines for creation and
execution of a dada read or write client main loop
************************************************************************ */
#include "multilog.h"
#include "ipcio.h"
#ifdef __cplusplus
extern "C" {
#endif
enum { dada_client_undefined, dada_client_reader, dada_client_writer };
typedef struct dada_client {
/*! The status and error logging interface */
multilog_t* log;
/*! The Data Block interface */
ipcio_t* data_block;
/*! The Header Block interface */
ipcbuf_t* header_block;
/*! Pointer to the function that opens the data transfer target */
int (*open_function) (struct dada_client*);
/*! Pointer to the function that transfers data to/from the target */
int64_t (*io_function) (struct dada_client*,
void* data, uint64_t data_size);
/*! Pointer to the function that directly operates on shared memory blocks */
int64_t (*io_block_function) (struct dada_client*, void* data, uint64_t data_size, uint64_t block_id);
/*! Pointer to the function that directly operations on device memory */
int64_t (*io_block_function_cuda) (struct dada_client*, void* data, uint64_t data_size, uint64_t block_id);
/*! Pointer to the function that closes the data transfer target */
int (*close_function) (struct dada_client*, uint64_t bytes_written);
/*! Additional context information */
void* context;
/* The header to be transfered to the target */
char* header;
/* The size of the header */
uint64_t header_size;
/* When set, the header is transfered to/from the target */
char header_transfer;
/* The direction of data transfer */
char direction;
/* The open function should set the following three attributes */
/*! The file descriptor of the data transfer target */
int fd;
/*! The total number of bytes to be transfered to/from the target */
uint64_t transfer_bytes;
/*! The optimal number of bytes to transfer to/from the target buffer */
uint64_t optimal_bytes;
/*! The quit flag */
char quit;
/*! The quiet flag */
int quiet;
} dada_client_t;
/*! Create a new DADA client main loop */
dada_client_t* dada_client_create ();
/*! Destroy a DADA client main loop */
void dada_client_destroy (dada_client_t* client);
/*! Run the DADA client read loop */
int dada_client_read (dada_client_t* client);
/*! Run the DADA client write loop */
int dada_client_write (dada_client_t* client);
/*! Close the dada client */
int dada_client_close (dada_client_t* client);
#ifdef __cplusplus
}
#endif
#endif