Commit e62db7b2 authored by Swann Perarnau's avatar Swann Perarnau

Revert "[refactor/fix] use uuid in user-side request type"

This reverts commit 04315e6e.

Not needed since vector doesn't contain the actual inner type.
parent 27460a5f
......@@ -27,14 +27,8 @@
**/
extern struct aml_dma_ops aml_dma_linux_par_ops;
/** Request handle for clients of the DMA. **/
struct aml_dma_request_linux_par {
/** internal request uuid, index in the request vector. **/
int uuid;
};
/** Inside of a parallel request for linux movement. **/
struct aml_dma_linux_par_request_data {
struct aml_dma_request_linux_par {
/**
* The type of dma request
* @see <aml.h>
......
......@@ -27,14 +27,8 @@
**/
extern struct aml_dma_ops aml_dma_linux_seq_ops;
/** Request handle for clients of the DMA. **/
struct aml_dma_request_linux_seq {
/** internal request uuid, index in the request vector. **/
int uuid;
};
/** Inside of a sequential request for linux movement. **/
struct aml_dma_linux_seq_request_data {
struct aml_dma_request_linux_seq {
/**
* The type of dma request
* @see <aml.h>
......@@ -66,7 +60,7 @@ struct aml_dma_linux_seq_ops {
* @see aml_area
**/
int (*do_copy)(struct aml_dma_linux_seq_data *dma,
struct aml_dma_linux_seq_request_data *req);
struct aml_dma_request_linux_seq *req);
};
/**
......@@ -105,7 +99,7 @@ void aml_dma_linux_seq_destroy(struct aml_dma **dma);
* @return 0 if successful; an error code otherwise.
**/
int aml_dma_linux_seq_do_copy(struct aml_dma_linux_seq_data *dma,
struct aml_dma_linux_seq_request_data *req);
struct aml_dma_request_linux_seq *req);
/**
* @}
......
......@@ -25,14 +25,8 @@
**/
extern struct aml_scratch_ops aml_scratch_par_ops;
/** Request handle for clients of the scratch. **/
struct aml_scratch_request_par {
/** internal request uuid, index in the request vector. **/
int uuid;
};
/** Inside of a parallel scratch request with linux dma. **/
struct aml_scratch_par_request_data {
struct aml_scratch_request_par {
/**
* The type of scratchpad request
* @see <aml.h>
......
......@@ -25,14 +25,8 @@
**/
extern struct aml_scratch_ops aml_scratch_seq_ops;
/** Request handle for clients of the scratch. **/
/** Inside of a sequential scratch request with linux dma. **/
struct aml_scratch_request_seq {
/** internal request uuid, index in the request vector. **/
int uuid;
};
/** Inside of a sequential scratch request. **/
struct aml_scratch_seq_request_data {
/**
* The type of scratchpad request
* @see <aml.h>
......@@ -85,7 +79,7 @@ struct aml_scratch_seq_ops {
* @param req: The request to execute.
**/
int (*doit)(struct aml_scratch_seq_data *scratch,
struct aml_scratch_seq_request_data *req);
struct aml_scratch_request_seq *req);
};
/** Sequential implementation of a scratchpad **/
......
......@@ -28,29 +28,11 @@
/*******************************************************************************
* Requests:
******************************************************************************/
int aml_dma_request_linux_par_create(struct aml_dma_request_linux_par **req,
int uuid)
{
assert(req != NULL);
*req = calloc(1, sizeof(struct aml_dma_request_linux_par));
if (*req == NULL)
return -AML_ENOMEM;
(*req)->uuid = uuid;
return 0;
}
void aml_dma_request_linux_par_destroy(struct aml_dma_request_linux_par **req)
{
assert(req != NULL);
free(*req);
*req = NULL;
}
int aml_dma_linux_par_request_data_init(
struct aml_dma_linux_par_request_data *req,
int type,
struct aml_layout *dest,
struct aml_layout *src)
int aml_dma_request_linux_par_copy_init(struct aml_dma_request_linux_par *req,
int type,
struct aml_layout *dest,
struct aml_layout *src)
{
assert(req != NULL);
req->type = type;
......@@ -59,14 +41,24 @@ int aml_dma_linux_par_request_data_init(
return 0;
}
int aml_dma_request_linux_par_copy_destroy(struct aml_dma_request_linux_par *r)
{
assert(r != NULL);
if (r->type == AML_DMA_REQUEST_TYPE_PTR) {
aml_layout_dense_destroy(&r->dest);
aml_layout_dense_destroy(&r->src);
}
return 0;
}
/*******************************************************************************
* Internal functions
******************************************************************************/
void *aml_dma_linux_par_do_thread(void *arg)
{
struct aml_dma_linux_par_request_data *req =
(struct aml_dma_linux_par_request_data *)arg;
struct aml_dma_request_linux_par *req =
(struct aml_dma_request_linux_par *)arg;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID)
......@@ -90,8 +82,7 @@ int aml_dma_linux_par_create_request(struct aml_dma_data *d,
assert(r != NULL);
struct aml_dma_linux_par *dma =
(struct aml_dma_linux_par *)d;
struct aml_dma_request_linux_par *ret;
struct aml_dma_linux_par_request_data *req;
struct aml_dma_request_linux_par *req;
int err = AML_SUCCESS;
pthread_mutex_lock(&dma->data.lock);
......@@ -107,7 +98,7 @@ int aml_dma_linux_par_create_request(struct aml_dma_data *d,
err = -AML_EINVAL;
goto unlock;
}
aml_dma_linux_par_request_data_init(req,
aml_dma_request_linux_par_copy_init(req,
AML_DMA_REQUEST_TYPE_LAYOUT,
dl, sl);
} else if (type == AML_DMA_REQUEST_TYPE_PTR) {
......@@ -127,7 +118,7 @@ int aml_dma_linux_par_create_request(struct aml_dma_data *d,
*/
aml_layout_dense_create(&dl, dp, 0, 1, 1, &sz, NULL, NULL);
aml_layout_dense_create(&sl, sp, 0, 1, 1, &sz, NULL, NULL);
aml_dma_linux_par_request_data_init(req,
aml_dma_request_linux_par_copy_init(req,
AML_DMA_REQUEST_TYPE_PTR,
dl, sl);
} else
......@@ -135,11 +126,8 @@ int aml_dma_linux_par_create_request(struct aml_dma_data *d,
unlock:
pthread_mutex_unlock(&dma->data.lock);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID) {
int uuid = aml_vector_getid(dma->data.requests, req);
pthread_create(&req->thread, NULL, dma->ops.do_thread, req);
aml_dma_request_linux_par_create(&ret, uuid);
*r = (struct aml_dma_request *)ret;
*r = (struct aml_dma_request *)req;
}
return err;
}
......@@ -152,30 +140,24 @@ int aml_dma_linux_par_destroy_request(struct aml_dma_data *d,
struct aml_dma_linux_par *dma =
(struct aml_dma_linux_par *)d;
struct aml_dma_request_linux_par *req;
struct aml_dma_linux_par_request_data *inner_req;
if (*r == NULL)
return -AML_EINVAL;
req = (struct aml_dma_request_linux_par *)*r;
inner_req = aml_vector_get(dma->data.requests, req->uuid);
if (inner_req == NULL)
return -AML_EINVAL;
/* we cancel and join, instead of killing, for a cleaner result */
if (inner_req->type != AML_DMA_REQUEST_TYPE_INVALID) {
pthread_cancel(inner_req->thread);
pthread_join(inner_req->thread, NULL);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID) {
pthread_cancel(req->thread);
pthread_join(req->thread, NULL);
}
if (inner_req->type == AML_DMA_REQUEST_TYPE_PTR) {
aml_layout_dense_destroy(&inner_req->dest);
aml_layout_dense_destroy(&inner_req->src);
}
/* make sure to destroy layouts before putting the request back in the
* vector
*/
aml_dma_request_linux_par_copy_destroy(req);
pthread_mutex_lock(&dma->data.lock);
aml_vector_remove(dma->data.requests, inner_req);
aml_vector_remove(dma->data.requests, req);
pthread_mutex_unlock(&dma->data.lock);
aml_dma_request_linux_par_destroy(&req);
*r = NULL;
return 0;
}
......@@ -187,27 +169,18 @@ int aml_dma_linux_par_wait_request(struct aml_dma_data *d,
assert(r != NULL);
struct aml_dma_linux_par *dma = (struct aml_dma_linux_par *)d;
struct aml_dma_request_linux_par *req;
struct aml_dma_linux_par_request_data *inner_req;
if (*r == NULL)
return -AML_EINVAL;
req = (struct aml_dma_request_linux_par *)*r;
inner_req = aml_vector_get(dma->data.requests, req->uuid);
if (inner_req == NULL)
return -AML_EINVAL;
if (inner_req->type != AML_DMA_REQUEST_TYPE_INVALID)
pthread_join(inner_req->thread, NULL);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID)
pthread_join(req->thread, NULL);
if (inner_req->type == AML_DMA_REQUEST_TYPE_PTR) {
aml_layout_dense_destroy(&inner_req->dest);
aml_layout_dense_destroy(&inner_req->src);
}
aml_dma_request_linux_par_copy_destroy(req);
pthread_mutex_lock(&dma->data.lock);
aml_vector_remove(dma->data.requests, inner_req);
aml_vector_remove(dma->data.requests, req);
pthread_mutex_unlock(&dma->data.lock);
aml_dma_request_linux_par_destroy(&req);
*r = NULL;
return 0;
}
......@@ -244,8 +217,8 @@ int aml_dma_linux_par_create(struct aml_dma **dma, size_t nbreqs)
/* allocate request array */
aml_vector_create(&d->data.requests, nbreqs,
sizeof(struct aml_dma_linux_par_request_data),
offsetof(struct aml_dma_linux_par_request_data, type),
sizeof(struct aml_dma_request_linux_par),
offsetof(struct aml_dma_request_linux_par, type),
AML_DMA_REQUEST_TYPE_INVALID);
pthread_mutex_init(&d->data.lock, NULL);
......@@ -261,17 +234,14 @@ void aml_dma_linux_par_destroy(struct aml_dma **d)
return;
dma = (struct aml_dma_linux_par *)(*d)->data;
for (size_t i = 0; i < aml_vector_size(dma->data.requests); i++) {
struct aml_dma_linux_par_request_data *req;
struct aml_dma_request_linux_par *req;
req = aml_vector_get(dma->data.requests, i);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID) {
pthread_cancel(req->thread);
pthread_join(req->thread, NULL);
}
if (req->type == AML_DMA_REQUEST_TYPE_PTR) {
aml_layout_dense_destroy(&req->dest);
aml_layout_dense_destroy(&req->src);
}
aml_dma_request_linux_par_copy_destroy(req);
}
aml_vector_destroy(&dma->data.requests);
pthread_mutex_destroy(&dma->data.lock);
......
......@@ -29,34 +29,22 @@
* Requests:
******************************************************************************/
int aml_dma_request_linux_seq_create(struct aml_dma_request_linux_seq **req,
int uuid)
int aml_dma_request_linux_seq_copy_init(struct aml_dma_request_linux_seq *req,
int type,
struct aml_layout *dest,
struct aml_layout *src)
{
assert(req != NULL);
*req = calloc(1, sizeof(struct aml_dma_request_linux_seq));
if (*req == NULL)
return -AML_ENOMEM;
(*req)->uuid = uuid;
req->type = type;
req->dest = dest;
req->src = src;
return 0;
}
void aml_dma_request_linux_seq_destroy(struct aml_dma_request_linux_seq **req)
{
assert(req != NULL);
free(*req);
*req = NULL;
}
void aml_dma_linux_seq_request_data_init(
struct aml_dma_linux_seq_request_data *req,
int type,
struct aml_layout *dest,
struct aml_layout *src)
int aml_dma_request_linux_seq_copy_destroy(struct aml_dma_request_linux_seq *r)
{
assert(req != NULL);
req->type = type;
req->dest = dest;
req->src = src;
assert(r != NULL);
return 0;
}
/*******************************************************************************
......@@ -64,7 +52,7 @@ void aml_dma_linux_seq_request_data_init(
******************************************************************************/
int aml_dma_linux_seq_do_copy(struct aml_dma_linux_seq_data *dma,
struct aml_dma_linux_seq_request_data *req)
struct aml_dma_request_linux_seq *req)
{
assert(dma != NULL);
assert(req != NULL);
......@@ -88,8 +76,7 @@ int aml_dma_linux_seq_create_request(struct aml_dma_data *d,
assert(r != NULL);
struct aml_dma_linux_seq *dma =
(struct aml_dma_linux_seq *)d;
struct aml_dma_request_linux_seq *ret;
struct aml_dma_linux_seq_request_data *req;
struct aml_dma_request_linux_seq *req;
int err = AML_SUCCESS;
pthread_mutex_lock(&dma->data.lock);
......@@ -105,7 +92,7 @@ int aml_dma_linux_seq_create_request(struct aml_dma_data *d,
err = -AML_EINVAL;
goto unlock;
}
aml_dma_linux_seq_request_data_init(req,
aml_dma_request_linux_seq_copy_init(req,
AML_DMA_REQUEST_TYPE_LAYOUT,
dl, sl);
} else if (type == AML_DMA_REQUEST_TYPE_PTR) {
......@@ -125,20 +112,15 @@ int aml_dma_linux_seq_create_request(struct aml_dma_data *d,
*/
aml_layout_dense_create(&dl, dp, 0, 1, 1, &sz, NULL, NULL);
aml_layout_dense_create(&sl, sp, 0, 1, 1, &sz, NULL, NULL);
aml_dma_linux_seq_request_data_init(req,
aml_dma_request_linux_seq_copy_init(req,
AML_DMA_REQUEST_TYPE_PTR,
dl, sl);
} else
err = -AML_EINVAL;
unlock:
pthread_mutex_unlock(&dma->data.lock);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID) {
int uuid = aml_vector_getid(dma->data.requests, req);
assert(uuid != AML_DMA_REQUEST_TYPE_INVALID);
aml_dma_request_linux_seq_create(&ret, uuid);
*r = (struct aml_dma_request *)ret;
}
if (req->type != AML_DMA_REQUEST_TYPE_INVALID)
*r = (struct aml_dma_request *)req;
return err;
}
......@@ -150,25 +132,22 @@ int aml_dma_linux_seq_destroy_request(struct aml_dma_data *d,
struct aml_dma_linux_seq *dma =
(struct aml_dma_linux_seq *)d;
struct aml_dma_request_linux_seq *req;
struct aml_dma_linux_seq_request_data *inner_req;
if (*r == NULL)
return -AML_EINVAL;
req = (struct aml_dma_request_linux_seq *)*r;
inner_req = aml_vector_get(dma->data.requests, req->uuid);
if (inner_req == NULL)
return -AML_EINVAL;
pthread_mutex_lock(&dma->data.lock);
if (inner_req->type == AML_DMA_REQUEST_TYPE_PTR) {
aml_layout_dense_destroy(&inner_req->dest);
aml_layout_dense_destroy(&inner_req->src);
if (req->type == AML_DMA_REQUEST_TYPE_LAYOUT)
aml_dma_request_linux_seq_copy_destroy(req);
else if (req->type == AML_DMA_REQUEST_TYPE_PTR) {
aml_layout_dense_destroy(&req->dest);
aml_layout_dense_destroy(&req->src);
aml_dma_request_linux_seq_copy_destroy(req);
}
aml_vector_remove(dma->data.requests, inner_req);
pthread_mutex_lock(&dma->data.lock);
aml_vector_remove(dma->data.requests, req);
pthread_mutex_unlock(&dma->data.lock);
aml_dma_request_linux_seq_destroy(&req);
*r = NULL;
return 0;
}
......@@ -180,19 +159,14 @@ int aml_dma_linux_seq_wait_request(struct aml_dma_data *d,
assert(r != NULL);
struct aml_dma_linux_seq *dma = (struct aml_dma_linux_seq *)d;
struct aml_dma_request_linux_seq *req;
struct aml_dma_linux_seq_request_data *inner_req;
if (*r == NULL)
return -AML_EINVAL;
req = (struct aml_dma_request_linux_seq *)*r;
inner_req = aml_vector_get(dma->data.requests, req->uuid);
if (inner_req == NULL)
return -AML_EINVAL;
/* execute */
if (inner_req->type != AML_DMA_REQUEST_TYPE_INVALID)
dma->ops.do_copy(&dma->data, inner_req);
if (req->type != AML_DMA_REQUEST_TYPE_INVALID)
dma->ops.do_copy(&dma->data, req);
/* destroy a completed request */
aml_dma_linux_seq_destroy_request(d, r);
......@@ -230,8 +204,8 @@ int aml_dma_linux_seq_create(struct aml_dma **dma, size_t nbreqs)
d->ops = aml_dma_linux_seq_inner_ops;
aml_vector_create(&d->data.requests, nbreqs,
sizeof(struct aml_dma_linux_seq_request_data),
offsetof(struct aml_dma_linux_seq_request_data, type),
sizeof(struct aml_dma_request_linux_seq),
offsetof(struct aml_dma_request_linux_seq, type),
AML_DMA_REQUEST_TYPE_INVALID);
pthread_mutex_init(&d->data.lock, NULL);
......
......@@ -24,28 +24,12 @@
/*******************************************************************************
* Requests:
******************************************************************************/
int aml_scratch_request_par_create(struct aml_scratch_request_par **req,
int uuid)
{
assert(req != NULL);
*req = calloc(1, sizeof(struct aml_scratch_request_par));
if (*req == NULL)
return -AML_ENOMEM;
(*req)->uuid = uuid;
return 0;
}
void aml_scratch_request_par_destroy(struct aml_scratch_request_par **req)
{
assert(req != NULL);
free(*req);
*req = NULL;
}
int aml_scratch_request_par_init(struct aml_scratch_request_par *req, int type,
struct aml_scratch_par *scratch,
void *dstptr, int dstid, void *srcptr,
int srcid)
int aml_scratch_par_request_data_init(struct aml_scratch_par_request_data *req,
int type, struct aml_scratch_par *scratch,
void *dstptr, int dstid, void *srcptr,
int srcid)
{
assert(req != NULL);
req->type = type;
......@@ -57,13 +41,19 @@ int aml_scratch_par_request_data_init(struct aml_scratch_par_request_data *req,
return 0;
}
int aml_scratch_request_par_destroy(struct aml_scratch_request_par *r)
{
assert(r != NULL);
return 0;
}
/*******************************************************************************
* Internal functions
******************************************************************************/
void *aml_scratch_par_do_thread(void *arg)
{
struct aml_scratch_par_request_data *req =
(struct aml_scratch_par_request_data *)arg;
struct aml_scratch_request_par *req =
(struct aml_scratch_request_par *)arg;
struct aml_scratch_par *scratch = req->scratch;
void *dest, *src;
......@@ -96,12 +86,11 @@ int aml_scratch_par_create_request(struct aml_scratch_data *d,
assert(r != NULL);
struct aml_scratch_par *scratch =
(struct aml_scratch_par *)d;
struct aml_scratch_request_par *ret;
struct aml_scratch_par_request_data *req;
struct aml_scratch_request_par *req;
pthread_mutex_lock(&scratch->data.lock);
req = aml_vector_add(scratch->data.requests);
/* init the request */
if (type == AML_SCRATCH_REQUEST_TYPE_PUSH) {
int scratchid;
......@@ -121,9 +110,8 @@ int aml_scratch_par_create_request(struct aml_scratch_data *d,
*srcid = *slot;
/* init request */
aml_scratch_par_request_data_init(req, type, scratch, srcptr,
*srcid, scratchptr,
scratchid);
aml_scratch_request_par_init(req, type, scratch, srcptr, *srcid,
scratchptr, scratchid);
} else if (type == AML_SCRATCH_REQUEST_TYPE_PULL) {
int *scratchid;
int srcid;
......@@ -152,54 +140,46 @@ int aml_scratch_par_create_request(struct aml_scratch_data *d,
*scratchid = slot;
/* init request */
aml_scratch_par_request_data_init(req, type, scratch,
scratchptr, *scratchid,
srcptr, srcid);
aml_scratch_request_par_init(req, type, scratch,
scratchptr, *scratchid,
srcptr, srcid);
}
int uuid = aml_vector_getid(scratch->data.requests, req);
assert(uuid != AML_SCRATCH_REQUEST_TYPE_INVALID);
aml_scratch_request_par_create(&ret, uuid);
pthread_mutex_unlock(&scratch->data.lock);
/* thread creation */
if (req->type != AML_SCRATCH_REQUEST_TYPE_NOOP)
pthread_create(&req->thread, NULL, scratch->ops.do_thread, req);
*r = (struct aml_scratch_request *)ret;
*r = (struct aml_scratch_request *)req;
return 0;
}
int aml_scratch_par_destroy_request(struct aml_scratch_data *d,
struct aml_scratch_request *r)
struct aml_scratch_request *r)
{
assert(d != NULL);
assert(r != NULL);
struct aml_scratch_par *scratch =
(struct aml_scratch_par *)d;
struct aml_scratch_par_request_data *inner_req;
struct aml_scratch_request_par *req =
(struct aml_scratch_request_par *)r;
int *tile;
inner_req = aml_vector_get(scratch->data.requests, req->uuid);
if (inner_req == NULL)
return -AML_EINVAL;
if (inner_req->type != AML_SCRATCH_REQUEST_TYPE_NOOP) {
pthread_cancel(inner_req->thread);
pthread_join(inner_req->thread, NULL);
if (req->type != AML_SCRATCH_REQUEST_TYPE_NOOP) {
pthread_cancel(req->thread);
pthread_join(req->thread, NULL);
}
aml_scratch_request_par_destroy(req);
/* destroy removes the tile from the scratch */
if (inner_req->type == AML_SCRATCH_REQUEST_TYPE_PUSH)
tile = aml_vector_get(scratch->data.tilemap, inner_req->srcid);
else if (inner_req->type == AML_SCRATCH_REQUEST_TYPE_PULL)
tile = aml_vector_get(scratch->data.tilemap, inner_req->dstid);
pthread_mutex_lock(&scratch->data.lock);
if (req->type == AML_SCRATCH_REQUEST_TYPE_PUSH)
tile = aml_vector_get(scratch->data.tilemap, req->srcid);
else if (req->type == AML_SCRATCH_REQUEST_TYPE_PULL)
tile = aml_vector_get(scratch->data.tilemap, req->dstid);
aml_vector_remove(scratch->data.tilemap, tile);
aml_vector_remove(scratch->data.requests, inner_req);
aml_vector_remove(scratch->data.requests, req);
pthread_mutex_unlock(&scratch->data.lock);
aml_scratch_request_par_destroy(&req);
return 0;
}
......@@ -209,28 +189,23 @@ int aml_scratch_par_wait_request(struct aml_scratch_data *d,
assert(d != NULL);
assert(r != NULL);
struct aml_scratch_par *scratch = (struct aml_scratch_par *)d;
struct aml_scratch_par_request_data *inner_req;
struct aml_scratch_request_par *req =
(struct aml_scratch_request_par *)r;
int *tile;
inner_req = aml_vector_get(scratch->data.requests, req->uuid);
if (inner_req == NULL)
return -AML_EINVAL;
/* wait for completion of the request */
if (inner_req->type != AML_SCRATCH_REQUEST_TYPE_NOOP)
pthread_join(inner_req->thread, NULL);
if (req->type != AML_SCRATCH_REQUEST_TYPE_NOOP)
pthread_join(req->thread, NULL);
/* cleanup a completed request. In case of push, free up the tile */
aml_scratch_request_par_destroy(req);
pthread_mutex_lock(&scratch->data.lock);
if (inner_req->type == AML_SCRATCH_REQUEST_TYPE_PUSH) {
tile = aml_vector_get(scratch->data.tilemap, inner_req->srcid);
if (req->type == AML_SCRATCH_REQUEST_TYPE_PUSH) {
tile = aml_vector_get(scratch->data.tilemap, req->srcid);
aml_vector_remove(scratch->data.tilemap, tile);
}
aml_vector_remove(scratch->data.requests, inner_req);
aml_vector_remove(scratch->data.requests, req);
pthread_mutex_unlock(&scratch->data.lock);
aml_scratch_request_par_destroy(&req);
return 0;
}
......@@ -302,8 +277,8 @@ int aml_scratch_par_create(struct aml_scratch **scratch,
/* allocate request array */
aml_vector_create(&s->data.requests, nbreqs,
sizeof(struct aml_scratch_par_request_data),
offsetof(struct aml_scratch_par_request_data, type),
sizeof(struct aml_scratch_request_par),
offsetof(struct aml_scratch_request_par, type),
AML_SCRATCH_REQUEST_TYPE_INVALID);
/* s init */
......
......@@ -24,28 +24,11 @@
/*******************************************************************************
* Requests:
******************************************************************************/
int aml_scratch_request_seq_create(struct aml_scratch_request_seq **req,
int uuid)
{
assert(req != NULL);
*req = calloc(1, sizeof(struct aml_scratch_request_seq));
if (*req == NULL)
return -AML_ENOMEM;
(*req)->uuid = uuid;
return 0;
}
void aml_scratch_request_seq_destroy(struct aml_scratch_request_seq **req)
{
assert(req != NULL);
free(*req);
*req = NULL;
}
int aml_scratch_request_seq_init(struct aml_scratch_request_seq *req, int type,
struct aml_tiling *t, void *dstptr, int dstid,
void *srcptr, int srcid)
void aml_scratch_seq_request_data_init(struct aml_scratch_seq_request_data *req,
int type, struct aml_tiling *t,
void *dstptr, int dstid,
void *srcptr, int srcid)
{
assert(req != NULL);
req->type = type;
......@@ -54,13 +37,20 @@ void aml_scratch_seq_request_data_init(struct aml_scratch_seq_request_data *req,
req->srcid = srcid;
req->dstptr = dstptr;
req->dstid = dstid;
return 0;
}
int aml_scratch_request_seq_destroy(struct aml_scratch_request_seq *r)
{
assert(r != NULL);
return 0;
}
/*******************************************************************************
* Internal functions
******************************************************************************/
int aml_scratch_seq_doit(struct aml_scratch_seq_data *scratch,
struct aml_scratch_seq_request_data *req)
struct aml_scratch_request_seq *req)
{
assert(scratch != NULL);
assert(req != NULL);
......@@ -82,6 +72,8 @@ struct aml_scratch_seq_ops aml_scratch_seq_inner_ops = {
* Public API
******************************************************************************/
/* TODO: not thread-safe */
int aml_scratch_seq_create_request(struct aml_scratch_data *d,
struct aml_scratch_request **r,
int type, va_list ap)
......@@ -90,12 +82,11 @@ int aml_scratch_seq_create_request(struct aml_scratch_data *d,
assert(r != NULL);
struct aml_scratch_seq *scratch =
(struct aml_scratch_seq *)d;
struct aml_scratch_request_seq *ret;
struct aml_scratch_seq_request_data *req;
struct aml_scratch_request_seq *req;
pthread_mutex_lock(&scratch->data.lock);
req = aml_vector_add(scratch->data.requests);
/* init the request */
if (type == AML_SCRATCH_REQUEST_TYPE_PUSH) {
int scratchid;
......@@ -115,7 +106,7 @@ int aml_scratch_seq_create_request(struct aml_scratch_data *d,
*srcid = *slot;
/* init request */
aml_scratch_seq_request_data_init(req, type,
aml_scratch_request_seq_init(req, type,
scratch->data.tiling,
srcptr, *srcid,
scratchptr, scratchid);
......@@ -150,19 +141,15 @@ int aml_scratch_seq_create_request(struct aml_scratch_data *d,
*scratchid = slot;
/* init request */
aml_scratch_seq_request_data_init(req, type,