aboutsummaryrefslogtreecommitdiff
path: root/mapper.lv2/test
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-07-07 09:05:20 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-07-07 09:05:20 +0200
commitfb48baf7da6d551b79f34e5afec7e9ff4f21d593 (patch)
tree439e9b09784184849c3688e67b604edf751b6d1c /mapper.lv2/test
parent3afe2cb1d962d02d2f94cdf75034c8c104bbd4da (diff)
parentb47fedb55c04fc21b6bd488425a77ae3479f979a (diff)
downloadsynthpod-fb48baf7da6d551b79f34e5afec7e9ff4f21d593.tar.xz
Merge commit 'b47fedb55c04fc21b6bd488425a77ae3479f979a'
Diffstat (limited to 'mapper.lv2/test')
-rw-r--r--mapper.lv2/test/Makefile16
-rw-r--r--mapper.lv2/test/mapper_test.c40
2 files changed, 19 insertions, 37 deletions
diff --git a/mapper.lv2/test/Makefile b/mapper.lv2/test/Makefile
index 3858e0ac..b8c56429 100644
--- a/mapper.lv2/test/Makefile
+++ b/mapper.lv2/test/Makefile
@@ -10,18 +10,18 @@ mapper_speed: mapper_test.c ../mapper.lv2/mapper.h
test_assert: mapper_assert
./$< 1 0
- ./$< 2 0
- ./$< 4 1
+ ./$< 2 1
+ ./$< 4 0
./$< 8 1
- ./$< 16 2
- ./$< 32 2
+ ./$< 16 0
+ ./$< 32 1
test_speed: mapper_speed
./$< 1 0
- ./$< 2 0
- ./$< 4 1
+ ./$< 2 1
+ ./$< 4 0
./$< 8 1
- ./$< 16 2
- ./$< 32 2
+ ./$< 16 0
+ ./$< 32 1
test: test_assert test_speed
diff --git a/mapper.lv2/test/mapper_test.c b/mapper.lv2/test/mapper_test.c
index 5eb0a10e..e605b077 100644
--- a/mapper.lv2/test/mapper_test.c
+++ b/mapper.lv2/test/mapper_test.c
@@ -53,7 +53,6 @@ struct _nrtmem_t {
// per-thread properties
struct _pool_t {
pthread_t thread;
- mapper_pool_t mapper_pool;
};
static rtmem_t *
@@ -128,9 +127,9 @@ static atomic_bool rolling = ATOMIC_VAR_INIT(false);
static void *
_thread(void *data)
{
- mapper_pool_t *mapper_pool = data;
- LV2_URID_Map *map = mapper_pool_get_map(mapper_pool);
- LV2_URID_Unmap *unmap = mapper_pool_get_unmap(mapper_pool);
+ mapper_t *mapper = data;
+ LV2_URID_Map *map = mapper_get_map(mapper);
+ LV2_URID_Unmap *unmap = mapper_get_unmap(mapper);
while(!atomic_load_explicit(&rolling, memory_order_relaxed))
{} // wait for go signal
@@ -163,18 +162,19 @@ main(int argc, char **argv)
assert(argc > 2);
const uint32_t n = atoi(argv[1]); // number of concurrent threads
- const uint32_t r = atoi(argv[2]); // number of threads using rt memory
- assert(r < n);
+ const bool is_rt = atoi(argv[2]); // whether to use rt-memory
// create rt memory
- rtmem_t *rtmem = rtmem_new(r);
+ rtmem_t *rtmem = rtmem_new(n);
assert(rtmem);
// initialize non-rt memory
nrtmem_init(&nrtmem);
// create mapper
- mapper_t *mapper = mapper_new(MAX_ITEMS);
+ mapper_t *mapper = is_rt
+ ? mapper_new(MAX_ITEMS, _rtmem_alloc, _rtmem_free, rtmem)
+ : mapper_new(MAX_ITEMS, _nrtmem_alloc, _nrtmem_free, &nrtmem);
assert(mapper);
// create array of threads
@@ -185,14 +185,8 @@ main(int argc, char **argv)
for(uint32_t p = 0; p < n; p++)
{
pool_t *pool = &pools[p];
- mapper_pool_t *mapper_pool = &pool->mapper_pool;
- if(p < r) // let thread use real-time memory
- mapper_pool_init(mapper_pool, mapper, _rtmem_alloc, _rtmem_free, rtmem);
- else
- mapper_pool_init(mapper_pool, mapper, _nrtmem_alloc, _nrtmem_free, &nrtmem);
-
- pthread_create(&pool->thread, NULL, _thread, mapper_pool);
+ pthread_create(&pool->thread, NULL, _thread, mapper);
}
// signal rolling
@@ -223,24 +217,12 @@ main(int argc, char **argv)
const uint32_t tot_nfree = rt_nfree + nrt_nfree;
assert(tot_nalloc - tot_nfree == usage);
- // deinit threads
- for(uint32_t p = 0; p < n; p++)
- {
- pool_t *pool = &pools[p];
- mapper_pool_t *mapper_pool = &pool->mapper_pool;
-
- mapper_pool_deinit(mapper_pool);
- }
-
- // query usage after freeing elements
- assert(mapper_get_usage(mapper) == 0);
+ // free mapper
+ mapper_free(mapper);
// free threads
free(pools);
- // free mapper
- mapper_free(mapper);
-
// check if all rt memory has been cleared
for(uint32_t i = 0; i < rt_nalloc; i++)
{