diff --git a/include/villas/sample.h b/include/villas/sample.h index 25660aace..ce345a19c 100644 --- a/include/villas/sample.h +++ b/include/villas/sample.h @@ -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)) diff --git a/lib/nodes/iec61850_sv.c b/lib/nodes/iec61850_sv.c index 5f2730e71..1ed940e56 100644 --- a/lib/nodes/iec61850_sv.c +++ b/lib/nodes/iec61850_sv.c @@ -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; diff --git a/lib/nodes/infiniband.c b/lib/nodes/infiniband.c index 258d0517c..f3c561a5b 100644 --- a/lib/nodes/infiniband.c +++ b/lib/nodes/infiniband.c @@ -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++; diff --git a/lib/nodes/loopback.c b/lib/nodes/loopback.c index cf200e1d4..8d4673ea1 100644 --- a/lib/nodes/loopback.c +++ b/lib/nodes/loopback.c @@ -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; diff --git a/lib/nodes/mqtt.c b/lib/nodes/mqtt.c index 03992e531..86fd1e78e 100644 --- a/lib/nodes/mqtt.c +++ b/lib/nodes/mqtt.c @@ -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; diff --git a/lib/nodes/websocket.c b/lib/nodes/websocket.c index 2946c5922..472a60a31 100644 --- a/lib/nodes/websocket.c +++ b/lib/nodes/websocket.c @@ -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; diff --git a/lib/path.c b/lib/path.c index 6c3ac29d4..a1c3e96c1 100644 --- a/lib/path.c +++ b/lib/path.c @@ -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; diff --git a/lib/sample.c b/lib/sample.c index d06e91eeb..9b3cd77f5 100644 --- a/lib/sample.c +++ b/lib/sample.c @@ -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; } diff --git a/lib/shmem.c b/lib/shmem.c index 294e7ae67..89fef51b3 100644 --- a/lib/shmem.c +++ b/lib/shmem.c @@ -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; diff --git a/src/villas-hook.cpp b/src/villas-hook.cpp index 5cbdf2f45..9665b2699 100644 --- a/src/villas-hook.cpp +++ b/src/villas-hook.cpp @@ -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"); diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index bd063bea0..cb83733c6 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -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."); diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index ac12613e7..c397eb970 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -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"); diff --git a/src/villas-test-cmp.cpp b/src/villas-test-cmp.cpp index 94666d026..ca3d61e0d 100644 --- a/src/villas-test-cmp.cpp +++ b/src/villas-test-cmp.cpp @@ -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"); diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index f7aecedd0..8815f8949 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -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); diff --git a/src/villas-test-shmem.cpp b/src/villas-test-shmem.cpp index 03d9f866d..8deaafb6a 100644 --- a/src/villas-test-shmem.cpp +++ b/src/villas-test-shmem.cpp @@ -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; } diff --git a/tests/unit/advio.c b/tests/unit/advio.c index c74aa4cb7..d69d63542 100644 --- a/tests/unit/advio.c +++ b/tests/unit/advio.c @@ -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"); diff --git a/tests/unit/io.c b/tests/unit/io.c index e2bab96dd..b10854dff 100644 --- a/tests/unit/io.c +++ b/tests/unit/io.c @@ -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);