linux-par.h 2.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*******************************************************************************
 * Copyright 2019 UChicago Argonne, LLC.
 * (c.f. AUTHORS, LICENSE)
 *
 * This file is part of the AML project.
 * For more info, see https://xgitlab.cels.anl.gov/argo/aml
 *
 * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/

#ifndef AML_DMA_LINUX_PAR_H
#define AML_DMA_LINUX_PAR_H 1

14
/**
15
 * @defgroup aml_dma_linux_par "AML Parallel DMA"
16 17 18 19 20 21 22
 * @brief Parallel DMA implementation.
 *
 * DMA logic implemented based on general linux API, asynchronous execution
 * threads. This DMA implementation moves between pointers allocated with an
 * aml_area_linux.
 * @{
 **/
23

24 25 26 27
/**
 * Default table of dma request operations for linux
 * parallel dma.
 **/
28 29
extern struct aml_dma_ops aml_dma_linux_par_ops;

30
/** Request handle for clients of the DMA. **/
31
struct aml_dma_request_linux_par {
32 33 34 35 36 37
	/** 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 {
38 39 40 41
	/**
	 * The type of dma request
	 * @see <aml.h>
	 **/
42
	int type;
43
	/** The destination pointer of the data movement **/
44
	struct aml_layout *dest;
45
	/** The source pointer of the data movement **/
46 47 48 49 50
	struct aml_layout *src;
	/** The dma containing sequential operations **/
	struct aml_dma_linux_par *dma;
	/** The actual thread in charge for the request progress**/
	pthread_t thread;
51 52
};

Swann Perarnau's avatar
Swann Perarnau committed
53
/** Inside of a parallel dma for linux movement. **/
54
struct aml_dma_linux_par_data {
55
	struct aml_vector *requests;
56 57 58
	pthread_mutex_t lock;
};

59
/** Declaration of linux parallel dma operations **/
60
struct aml_dma_linux_par_ops {
61
	void *(*do_thread)(void *data);
62 63
};

64 65
/**
 * aml_dma structure for linux based, parallel dma movement
66
 * Needs to be initialized with aml_dma_linux_par_create().
67 68
 * Can be passed to generic aml_dma_*() functions.
 **/
69 70 71 72 73
struct aml_dma_linux_par {
	struct aml_dma_linux_par_ops ops;
	struct aml_dma_linux_par_data data;
};

74
/**
75
 * Allocates and initializes a new parallel DMA.
76 77 78 79 80 81 82 83 84
 *
 * @param dma an address where the pointer to the newly allocated DMA structure
 * will be stored.
 * @param nbreqs the initial number of slots for asynchronous requests that are
 * in-flight (will be increased automatically if necessary).
 * @param nbthreads the number of threads to launch for each request.
 *
 * @return 0 if successful; an error code otherwise.
 **/
85
int aml_dma_linux_par_create(struct aml_dma **dma, size_t nbreqs);
86 87 88 89

/**
 * Tears down a parallel DMA created with aml_dma_linux_par_create.
 * @param dma the address of a pointer to a parallel dma. Will be NULL after.
90
 **/
91
void aml_dma_linux_par_destroy(struct aml_dma **dma);
92

93 94 95
/**
 * @}
 **/
96
#endif // AML_LINUX_DMA_LINUX_PAR_H