mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
refactor:
- SAMPLE_LEN() -> SAMPLE_LENGTH() - SAMPLE_DATA_LEN() -> SAMPLE_DATA_LENGTH()
This commit is contained in:
parent
ae8d576b4a
commit
f35588aad8
17 changed files with 24 additions and 24 deletions
|
@ -40,10 +40,10 @@ extern "C"{
|
|||
struct pool;
|
||||
|
||||
/** The length of a sample datastructure with \p values values in bytes. */
|
||||
#define SAMPLE_LEN(len) (sizeof(struct sample) + SAMPLE_DATA_LEN(len))
|
||||
#define SAMPLE_LENGTH(len) (sizeof(struct sample) + SAMPLE_DATA_LENGTH(len))
|
||||
|
||||
/** The length of a sample data portion of a sample datastructure with \p values values in bytes. */
|
||||
#define SAMPLE_DATA_LEN(len) ((len) * sizeof(double))
|
||||
#define SAMPLE_DATA_LENGTH(len) ((len) * sizeof(double))
|
||||
|
||||
/** The offset to the beginning of the data section. */
|
||||
#define SAMPLE_DATA_OFFSET(smp) ((char *) (smp) + offsetof(struct sample, data))
|
||||
|
|
|
@ -299,7 +299,7 @@ int iec61850_sv_start(struct node *n)
|
|||
SVReceiver_addSubscriber(i->subscriber.receiver, i->subscriber.subscriber);
|
||||
|
||||
/* Initialize pool and queue to pass samples between threads */
|
||||
ret = pool_init(&i->subscriber.pool, 1024, SAMPLE_LEN(n->samplelen), &memory_hugepage);
|
||||
ret = pool_init(&i->subscriber.pool, 1024, SAMPLE_LENGTH(n->samplelen), &memory_hugepage);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -841,7 +841,7 @@ int ib_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *relea
|
|||
j++;
|
||||
|
||||
sge[i][j].addr = (uint64_t) &smps[i]->data;
|
||||
sge[i][j].length = SAMPLE_DATA_LEN(DEFAULT_SAMPLELEN);
|
||||
sge[i][j].length = SAMPLE_DATA_LENGTH(DEFAULT_SAMPLELEN);
|
||||
sge[i][j].lkey = mr->lkey;
|
||||
|
||||
j++;
|
||||
|
|
|
@ -50,7 +50,7 @@ int loopback_open(struct node *n)
|
|||
int ret;
|
||||
struct loopback *l = (struct loopback *) n->_vd;
|
||||
|
||||
ret = pool_init(&l->pool, l->queuelen, SAMPLE_LEN(n->samplelen), &memory_hugepage);
|
||||
ret = pool_init(&l->pool, l->queuelen, SAMPLE_LENGTH(n->samplelen), &memory_hugepage);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ int mqtt_start(struct node *n)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = pool_init(&m->pool, 1024, SAMPLE_LEN(n->samplelen), &memory_hugepage);
|
||||
ret = pool_init(&m->pool, 1024, SAMPLE_LENGTH(n->samplelen), &memory_hugepage);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -402,7 +402,7 @@ int websocket_start(struct node *n)
|
|||
int ret;
|
||||
struct websocket *w = (struct websocket *) n->_vd;
|
||||
|
||||
ret = pool_init(&w->pool, DEFAULT_WEBSOCKET_QUEUELEN, SAMPLE_LEN(DEFAULT_WEBSOCKET_SAMPLELEN), &memory_hugepage);
|
||||
ret = pool_init(&w->pool, DEFAULT_WEBSOCKET_QUEUELEN, SAMPLE_LENGTH(DEFAULT_WEBSOCKET_SAMPLELEN), &memory_hugepage);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ static int path_source_init(struct path_source *ps)
|
|||
int ret;
|
||||
unsigned pool_cnt = (strcmp(node_type_name(ps->node->_vt), "infiniband") == 0 ? 8192 : (unsigned) MAX(DEFAULT_QUEUELEN, ps->node->in.vectorize));
|
||||
|
||||
ret = pool_init(&ps->pool, pool_cnt, SAMPLE_LEN(ps->node->samplelen), node_memory_type(ps->node, &memory_hugepage));
|
||||
ret = pool_init(&ps->pool, pool_cnt, SAMPLE_LENGTH(ps->node->samplelen), node_memory_type(ps->node, &memory_hugepage));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -448,7 +448,7 @@ int path_init2(struct path *p)
|
|||
if (!p->samplelen)
|
||||
p->samplelen = DEFAULT_SAMPLELEN;
|
||||
|
||||
ret = pool_init(&p->pool, pool_cnt, SAMPLE_LEN(p->samplelen), pool_mem_type);
|
||||
ret = pool_init(&p->pool, pool_cnt, SAMPLE_LENGTH(p->samplelen), pool_mem_type);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ struct sample * sample_alloc(struct pool *p)
|
|||
|
||||
struct sample * sample_alloc_mem(int capacity)
|
||||
{
|
||||
size_t sz = SAMPLE_LEN(capacity);
|
||||
size_t sz = SAMPLE_LENGTH(capacity);
|
||||
|
||||
char *b = alloc(sz);
|
||||
if (!b)
|
||||
|
@ -152,7 +152,7 @@ int sample_copy(struct sample *dst, struct sample *src)
|
|||
dst->flags = src->flags;
|
||||
dst->ts = src->ts;
|
||||
|
||||
memcpy(&dst->data, &src->data, SAMPLE_DATA_LEN(dst->length));
|
||||
memcpy(&dst->data, &src->data, SAMPLE_DATA_LENGTH(dst->length));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ size_t shmem_total_size(int queuelen, int samplelen)
|
|||
/* the size of the actual queue and the queue for the pool */
|
||||
+ queuelen * (2 * sizeof(struct queue_cell))
|
||||
/* the size of the pool */
|
||||
+ queuelen * kernel_get_cacheline_size() * CEIL(SAMPLE_LEN(samplelen), kernel_get_cacheline_size())
|
||||
+ queuelen * kernel_get_cacheline_size() * CEIL(SAMPLE_LENGTH(samplelen), kernel_get_cacheline_size())
|
||||
/* a memblock for each allocation (1 shmem_shared, 2 queues, 1 pool) */
|
||||
+ 4 * sizeof(struct memory_block)
|
||||
/* and some extra buffer for alignment */
|
||||
|
@ -114,7 +114,7 @@ retry: fd = shm_open(wname, O_RDWR|O_CREAT|O_EXCL, 0600);
|
|||
return -6;
|
||||
}
|
||||
|
||||
ret = pool_init(&shared->pool, conf->queuelen, SAMPLE_LEN(conf->samplelen), manager);
|
||||
ret = pool_init(&shared->pool, conf->queuelen, SAMPLE_LENGTH(conf->samplelen), manager);
|
||||
if (ret) {
|
||||
errno = ENOMEM;
|
||||
return -7;
|
||||
|
|
|
@ -186,7 +186,7 @@ check: if (optarg == endptr)
|
|||
|
||||
smps = (struct sample **) alloc(cnt * sizeof(struct sample *));
|
||||
|
||||
ret = pool_init(&q, 10 * cnt, SAMPLE_LEN(DEFAULT_SAMPLELEN), &memory_hugepage);
|
||||
ret = pool_init(&q, 10 * cnt, SAMPLE_LENGTH(DEFAULT_SAMPLELEN), &memory_hugepage);
|
||||
if (ret)
|
||||
error("Failed to initilize memory pool");
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ static void * send_loop(void *ctx)
|
|||
/* Initialize memory */
|
||||
unsigned pool_cnt = (strcmp(node_type_name(node->_vt), "infiniband") == 0 ? 8192 : LOG2_CEIL(node->out.vectorize));
|
||||
|
||||
ret = pool_init(&sendd.pool, pool_cnt, SAMPLE_LEN(DEFAULT_SAMPLELEN), node_memory_type(node, &memory_hugepage));
|
||||
ret = pool_init(&sendd.pool, pool_cnt, SAMPLE_LENGTH(DEFAULT_SAMPLELEN), node_memory_type(node, &memory_hugepage));
|
||||
|
||||
if (ret < 0)
|
||||
error("Failed to allocate memory for receive pool.");
|
||||
|
@ -205,7 +205,7 @@ static void * recv_loop(void *ctx)
|
|||
/* Initialize memory */
|
||||
unsigned pool_cnt = (strcmp(node_type_name(node->_vt), "infiniband") == 0 ? 8192 : LOG2_CEIL(node->in.vectorize));
|
||||
|
||||
ret = pool_init(&recvv.pool, pool_cnt, SAMPLE_LEN(DEFAULT_SAMPLELEN), node_memory_type(node, &memory_hugepage));
|
||||
ret = pool_init(&recvv.pool, pool_cnt, SAMPLE_LENGTH(DEFAULT_SAMPLELEN), node_memory_type(node, &memory_hugepage));
|
||||
|
||||
if (ret < 0)
|
||||
error("Failed to allocate memory for receive pool.");
|
||||
|
|
|
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
|||
if (ret)
|
||||
error("Failed to verify node configuration");
|
||||
|
||||
ret = pool_init(&q, 16, SAMPLE_LEN(n.samplelen), &memory_type_heap);
|
||||
ret = pool_init(&q, 16, SAMPLE_LENGTH(n.samplelen), &memory_type_heap);
|
||||
if (ret)
|
||||
error("Failed to initialize pool");
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ check: if (optarg == endptr)
|
|||
struct side s[n];
|
||||
|
||||
memory_init(0);
|
||||
ret = pool_init(&pool, n, SAMPLE_LEN(DEFAULT_SAMPLELEN), &memory_type_heap);
|
||||
ret = pool_init(&pool, n, SAMPLE_LENGTH(DEFAULT_SAMPLELEN), &memory_type_heap);
|
||||
if (ret)
|
||||
error("Failed to initialize pool");
|
||||
|
||||
|
|
|
@ -156,8 +156,8 @@ void test_rtt() {
|
|||
|
||||
struct timespec send, recv;
|
||||
|
||||
struct sample *smp_send = (struct sample *) alloc(SAMPLE_LEN(2));
|
||||
struct sample *smp_recv = (struct sample *) alloc(SAMPLE_LEN(2));
|
||||
struct sample *smp_send = (struct sample *) alloc(SAMPLE_LENGTH(2));
|
||||
struct sample *smp_recv = (struct sample *) alloc(SAMPLE_LENGTH(2));
|
||||
|
||||
hist_init(&hist, 20, 100);
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ int main(int argc, char* argv[])
|
|||
outsmps[i]->ts = insmps[i]->ts;
|
||||
|
||||
int len = MIN(insmps[i]->length, outsmps[i]->capacity);
|
||||
memcpy(outsmps[i]->data, insmps[i]->data, SAMPLE_DATA_LEN(len));
|
||||
memcpy(outsmps[i]->data, insmps[i]->data, SAMPLE_DATA_LENGTH(len));
|
||||
|
||||
outsmps[i]->length = len;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ Test(advio, download_large)
|
|||
AFILE *af;
|
||||
int ret, len = 16;
|
||||
|
||||
struct sample *smp = (struct sample *) alloc(SAMPLE_LEN(len));
|
||||
struct sample *smp = (struct sample *) alloc(SAMPLE_LENGTH(len));
|
||||
smp->capacity = len;
|
||||
|
||||
af = afopen(BASE_URI "/download-large" , "r");
|
||||
|
|
|
@ -185,7 +185,7 @@ ParameterizedTest(char *fmt, io, lowlevel)
|
|||
struct sample *smps[NUM_SAMPLES];
|
||||
struct sample *smpt[NUM_SAMPLES];
|
||||
|
||||
ret = pool_init(&p, 2 * NUM_SAMPLES, SAMPLE_LEN(NUM_VALUES), &memory_hugepage);
|
||||
ret = pool_init(&p, 2 * NUM_SAMPLES, SAMPLE_LENGTH(NUM_VALUES), &memory_hugepage);
|
||||
cr_assert_eq(ret, 0);
|
||||
|
||||
info("Running test for format = %s", fmt);
|
||||
|
@ -232,7 +232,7 @@ ParameterizedTest(char *fmt, io, highlevel)
|
|||
|
||||
info("Running test for format = %s", fmt);
|
||||
|
||||
ret = pool_init(&p, 2 * NUM_SAMPLES, SAMPLE_LEN(NUM_VALUES), &memory_hugepage);
|
||||
ret = pool_init(&p, 2 * NUM_SAMPLES, SAMPLE_LENGTH(NUM_VALUES), &memory_hugepage);
|
||||
cr_assert_eq(ret, 0);
|
||||
|
||||
generate_samples(&p, smps, smpt, NUM_SAMPLES, NUM_VALUES);
|
||||
|
|
Loading…
Add table
Reference in a new issue