Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
masync: make vdm operation accessible in the future
Browse files Browse the repository at this point in the history
Right now the vdm_operation_future hides all operation
details behind a mover-specific data pointer. This
makes it impossible to alter the operation arguments
inside of a chained future. This patch moves all operation
data to the the externally visible vdm_operation_data.
  • Loading branch information
pbalcer committed Mar 21, 2022
1 parent df37843 commit 1197a67
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 155 deletions.
9 changes: 8 additions & 1 deletion doc/data_mover_dml_new.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ data mover structure
struct data_mover_dml;
struct data_mover_dml *data_mover_dml_new(void);
enum data_mover_dml_type {
DATA_MOVER_DML_SOFTWARE,
DATA_MOVER_DML_HARDWARE,
DATA_MOVER_DML_AUTO,
};
struct data_mover_dml *data_mover_dml_new(enum data_mover_dml_type type);
void data_mover_dml_delete(struct data_mover_dml *dmd);
```

Expand All @@ -39,6 +45,7 @@ For general description of **DML** data mover API, see **miniasync_vdm_dml**(7).
# DESCRIPTION #

The **data_mover_dml_new**() function allocates and initializes a new **DML** data mover structure.
The **type** argument maps directly onto the **DML** path types. See the **DML** documentation for more details.

The **data_mover_dml_delete**() function frees and finalizes the **DML** data mover structure
pointed by *dmd*.
Expand Down
16 changes: 10 additions & 6 deletions doc/miniasync_vdm.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ secondary_title: miniasync
#include <libminiasync.h>
typedef void *(*vdm_operation_new)
(struct vdm *vdm, const struct vdm_operation *operation);
typedef int (*vdm_operation_start)(void *op, struct future_notifier *n);
typedef enum future_state (*vdm_operation_check)(void *op);
typedef void (*vdm_operation_delete)(void *op,
(struct vdm *vdm, const enum vdm_operation_type type);
typedef int (*vdm_operation_start)(void *data,
const struct vdm_operation *operation,
struct future_notifier *n);
typedef enum future_state (*vdm_operation_check)(void *data,
const struct vdm_operation *operation);
typedef void (*vdm_operation_delete)(void *data,
const struct vdm_operation *operation,
struct vdm_operation_output *output);
struct vdm {
Expand All @@ -57,11 +61,11 @@ compatibility with the **miniasync_future**(7) feature.
*struct vdm* is a structure required by every virtual data mover operation, for
example **vdm_memcpy**(3). *struct vdm* has following members:

* *op_new* - allocations and initializations needed by operation
* *op_new* - allocations needed for the specified operation type

* *op_delete* - deallocations and finalizations of operation

* *op_start* - data mover task that should be executed
* *op_start* - populates operation data and starts the execution of the task

* *op_check* - data mover task status check

Expand Down
7 changes: 2 additions & 5 deletions doc/miniasync_vdm_dml.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ by the **miniasync-vdm-dml**(7) library that has dependency on the **DML** libra
For information about **miniasync_vdm_dml**() library compilation, see *extras/dml/README.md* file.

**DML** data mover supports offloading certain computations to the hardware
accelerators (e.g. Intel® Data Streaming Accelerator) by using **MINIASYNC_DML_F_PATH_HW**
flag. To use this feature, make sure that **DML** library is installed with **DML_HW** option.
accelerators (e.g. Intel® Data Streaming Accelerator). To use this feature, make
sure that **DML** library is installed with **DML_HW** option.
For more information about **DML**, see **<https://github.com/intel/DML>**.
An example of **DML** data mover API usage with flags can be found in **EXAMPLE** section.

Expand All @@ -57,9 +57,6 @@ To create a new **DML** data mover instance, use **data_mover_dml_new**(3) funct

* **MINIASYNC_DML_F_MEM_DURABLE** - write to destination is identified as write to durable memory

* **MINIASYNC_DML_F_PATH_HW** - use hardware accelerators (e.g. Intel® Data Streaming Accelerator)
for operation execution

**DML** data mover supports following operations:

* **vdm_memcpy**(3) - memory copy operation
Expand Down
93 changes: 53 additions & 40 deletions extras/dml/data_mover_dml.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@

struct data_mover_dml {
struct vdm base; /* must be first */

dml_path_t path;
struct membuf *membuf;
};

/*
* data_mover_dml_translate_flags -- translate miniasync-vdm-dml flags
*/
static void
data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags,
dml_path_t *path)
data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags)
{
ASSERTeq((flags & ~MINIASYNC_DML_F_VALID_FLAGS), 0);

*dml_flags = 0;
*path = DML_PATH_SW; /* default path */
for (uint64_t iflag = 1; flags > 0; iflag = iflag << 1) {
if ((flags & iflag) == 0)
continue;
Expand All @@ -40,10 +38,6 @@ data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags,
case MINIASYNC_DML_F_MEM_DURABLE:
*dml_flags |= DML_FLAG_DST1_DURABLE;
break;
/* perform operation using hardware path */
case MINIASYNC_DML_F_PATH_HW:
*path = DML_PATH_HW;
break;
default: /* shouldn't be possible */
ASSERT(0);
}
Expand All @@ -54,27 +48,14 @@ data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags,
}

/*
* data_mover_dml_memcpy_job_new -- create a new memcpy job struct
* data_mover_dml_memcpy_job_init -- initializes new memcpy dml job
*/
static dml_job_t *
data_mover_dml_memcpy_job_new(struct data_mover_dml *vdm_dml,
data_mover_dml_memcpy_job_init(dml_job_t *dml_job,
void *dest, void *src, size_t n, uint64_t flags)
{
dml_status_t status;
uint32_t job_size;
dml_job_t *dml_job = NULL;

uint64_t dml_flags = 0;
dml_path_t path;
data_mover_dml_translate_flags(flags, &dml_flags, &path);

status = dml_get_job_size(path, &job_size);
ASSERTeq(status, DML_STATUS_OK);

dml_job = (dml_job_t *)membuf_alloc(vdm_dml->membuf, job_size);

status = dml_init_job(path, dml_job);
ASSERTeq(status, DML_STATUS_OK);
data_mover_dml_translate_flags(flags, &dml_flags);

dml_job->operation = DML_OP_MEM_MOVE;
dml_job->source_first_ptr = (uint8_t *)src;
Expand Down Expand Up @@ -113,17 +94,25 @@ data_mover_dml_memcpy_job_submit(dml_job_t *dml_job)
*/
static void *
data_mover_dml_operation_new(struct vdm *vdm,
const struct vdm_operation *operation)
const enum vdm_operation_type type)
{
struct data_mover_dml *vdm_dml = (struct data_mover_dml *)vdm;
dml_status_t status;
uint32_t job_size;
dml_job_t *dml_job;

switch (operation->type) {
case VDM_OPERATION_MEMCPY:
return data_mover_dml_memcpy_job_new(vdm_dml,
operation->data.memcpy.dest,
operation->data.memcpy.src,
operation->data.memcpy.n,
operation->data.memcpy.flags);
switch (type) {
case VDM_OPERATION_MEMCPY: {
status = dml_get_job_size(vdm_dml->path, &job_size);
ASSERTeq(status, DML_STATUS_OK);

dml_job = membuf_alloc(vdm_dml->membuf, job_size);
dml_status_t status =
dml_init_job(vdm_dml->path, dml_job);
ASSERTeq(status, DML_STATUS_OK);

return dml_job;
}
default:
ASSERT(0); /* unreachable */
}
Expand All @@ -134,9 +123,11 @@ data_mover_dml_operation_new(struct vdm *vdm,
* data_mover_dml_operation_delete -- delete a DML job
*/
static void
data_mover_dml_operation_delete(void *op, struct vdm_operation_output *output)
data_mover_dml_operation_delete(void *data,
const struct vdm_operation *operation,
struct vdm_operation_output *output)
{
dml_job_t *job = (dml_job_t *)op;
dml_job_t *job = (dml_job_t *)data;

switch (job->operation) {
case DML_OP_MEM_MOVE:
Expand All @@ -150,16 +141,19 @@ data_mover_dml_operation_delete(void *op, struct vdm_operation_output *output)

data_mover_dml_memcpy_job_delete(&job);

membuf_free(op);
membuf_free(data);
}

/*
* data_mover_dml_operation_check -- checks the status of a DML job
*/
enum future_state
data_mover_dml_operation_check(void *op)
data_mover_dml_operation_check(void *data,
const struct vdm_operation *operation)
{
dml_job_t *job = (dml_job_t *)op;
SUPPRESS_UNUSED(operation);

dml_job_t *job = (dml_job_t *)data;

dml_status_t status = dml_check_job(job);
ASSERTne(status, DML_STATUS_JOB_CORRUPTED);
Expand All @@ -172,11 +166,17 @@ data_mover_dml_operation_check(void *op)
* data_mover_dml_operation_start -- start ('submit') asynchronous dml job
*/
int
data_mover_dml_operation_start(void *op, struct future_notifier *n)
data_mover_dml_operation_start(void *data,
const struct vdm_operation *operation, struct future_notifier *n)
{
n->notifier_used = FUTURE_NOTIFIER_NONE;

dml_job_t *job = (dml_job_t *)op;
dml_job_t *job = (dml_job_t *)data;
data_mover_dml_memcpy_job_init(job,
operation->data.memcpy.dest,
operation->data.memcpy.src,
operation->data.memcpy.n,
operation->data.memcpy.flags);

data_mover_dml_memcpy_job_submit(job);

Expand All @@ -197,14 +197,27 @@ static struct vdm data_mover_dml_vdm = {
* data_mover_dml_new -- creates a new dml-based data mover instance
*/
struct data_mover_dml *
data_mover_dml_new(void)
data_mover_dml_new(enum data_mover_dml_type type)
{
struct data_mover_dml *vdm_dml = malloc(sizeof(struct data_mover_dml));
if (vdm_dml == NULL)
return NULL;

vdm_dml->membuf = membuf_new(vdm_dml);
vdm_dml->base = data_mover_dml_vdm;
switch (type) {
case DATA_MOVER_DML_HARDWARE:
vdm_dml->path = DML_PATH_HW;
break;
case DATA_MOVER_DML_SOFTWARE:
vdm_dml->path = DML_PATH_SW;
break;
case DATA_MOVER_DML_AUTO:
vdm_dml->path = DML_PATH_AUTO;
break;
default:
ASSERT(0);
}

return vdm_dml;
}
Expand Down
6 changes: 3 additions & 3 deletions extras/dml/include/libminiasync-vdm-dml.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ extern "C" {
#endif

/* MINIASYNC_DML flags */
/* XXX: these flags need to be unified across all vdms */

#define MINIASYNC_DML_F_MEM_DURABLE (1U << 0)
#define MINIASYNC_DML_F_PATH_HW (1U << 1)
#define MINIASYNC_DML_F_VALID_FLAGS (MINIASYNC_DML_F_MEM_DURABLE | \
MINIASYNC_DML_F_PATH_HW)
#define MINIASYNC_DML_F_VALID_FLAGS (MINIASYNC_DML_F_MEM_DURABLE)

#ifdef __cplusplus
}
Expand Down
8 changes: 7 additions & 1 deletion extras/dml/include/libminiasync-vdm-dml/data_mover_dml.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ extern "C" {

struct data_mover_dml;

struct data_mover_dml *data_mover_dml_new(void);
enum data_mover_dml_type {
DATA_MOVER_DML_SOFTWARE,
DATA_MOVER_DML_HARDWARE,
DATA_MOVER_DML_AUTO,
};

struct data_mover_dml *data_mover_dml_new(enum data_mover_dml_type type);
struct vdm *data_mover_dml_get_vdm(struct data_mover_dml *dmd);
void data_mover_dml_delete(struct data_mover_dml *dmd);

Expand Down
Loading

0 comments on commit 1197a67

Please sign in to comment.