Commit 052c70e7 authored by Brice Videau's avatar Brice Videau

Added cpuset to aml_dma_linux_spin_create.

parent 8ba4dd1a
Pipeline #8433 failed with stages
in 3 minutes and 40 seconds
......@@ -84,7 +84,7 @@ struct aml_dma_linux_spin {
* @param op: default operator
* @return 0 if successful; an error code otherwise.
**/
int aml_dma_linux_spin_create(struct aml_dma **dma,
int aml_dma_linux_spin_create(struct aml_dma **dma, const cpu_set_t *cpuset,
aml_dma_operator op, void *op_arg);
/**
......
......@@ -8,6 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#include "config.h"
#include "aml.h"
#include "aml/dma/linux-spin.h"
#include "aml/layout/dense.h"
......@@ -153,7 +154,7 @@ struct aml_dma_ops aml_dma_linux_spin_ops = {
* Init functions:
******************************************************************************/
int aml_dma_linux_spin_create(struct aml_dma **dma,
int aml_dma_linux_spin_create(struct aml_dma **dma, const cpu_set_t *cpuset,
aml_dma_operator op, void *op_arg)
{
struct aml_dma *ret = NULL;
......@@ -186,6 +187,8 @@ int aml_dma_linux_spin_create(struct aml_dma **dma,
pthread_spin_init(&d->data.req.lock, PTHREAD_PROCESS_PRIVATE);
pthread_create(&d->data.req.thread, NULL, d->ops.do_thread, &d->data.req);
if (cpuset)
pthread_setaffinity_np(d->data.req.thread, sizeof(cpu_set_t), cpuset);
*dma = ret;
return 0;
......
......@@ -7,11 +7,14 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
#define _GNU_SOURCE
#include "aml.h"
#include "aml/layout/dense.h"
#include "aml/dma/linux-spin.h"
#include <assert.h>
#include <sched.h>
int main(int argc, char *argv[])
{
......@@ -34,10 +37,15 @@ int main(int argc, char *argv[])
isrc[i] = 24;
}
/* invalid create input */
assert(aml_dma_linux_spin_create(NULL, NULL, NULL) == -AML_EINVAL);
assert(aml_dma_linux_spin_create(NULL, NULL, NULL, NULL) == -AML_EINVAL);
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(3, &cpuset);
/* invalid requests */
assert(!aml_dma_linux_spin_create(&dma, NULL, NULL));
assert(!aml_dma_linux_spin_create(&dma, &cpuset, NULL, NULL));
sleep(1);
assert(aml_dma_copy(dma, NULL, isl) == -AML_EINVAL);
assert(aml_dma_copy(dma, idl, NULL) == -AML_EINVAL);
......@@ -53,7 +61,7 @@ int main(int argc, char *argv[])
aml_dma_linux_spin_destroy(&dma);
/* destroy a running dma */
assert(!aml_dma_linux_spin_create(&dma, NULL, NULL));
assert(!aml_dma_linux_spin_create(&dma, &cpuset, NULL, NULL));
assert(!aml_dma_async_copy(dma, &r1, idl, isl));
aml_dma_linux_spin_destroy(&dma);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment