linux-par.h 2.57 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
/** Inside of a parallel request for linux movement. **/
31
struct aml_dma_request_linux_par {
32
33
34
35
	/**
	 * The type of dma request
	 * @see <aml.h>
	 **/
36
	int type;
37
	/** The destination pointer of the data movement **/
38
	struct aml_layout *dest;
39
	/** The source pointer of the data movement **/
40
41
42
43
44
	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;
45
46
};

47
/** Inside of a parallel request for linux movement. **/
48
struct aml_dma_linux_par_data {
49
	struct aml_vector *requests;
50
51
52
	pthread_mutex_t lock;
};

53
/** Declaration of linux parallel dma operations **/
54
struct aml_dma_linux_par_ops {
55
	void *(*do_thread)(void *data);
56
57
};

58
59
/**
 * aml_dma structure for linux based, parallel dma movement
60
 * Needs to be initialized with aml_dma_linux_par_create().
61
62
 * Can be passed to generic aml_dma_*() functions.
 **/
63
64
65
66
67
struct aml_dma_linux_par {
	struct aml_dma_linux_par_ops ops;
	struct aml_dma_linux_par_data data;
};

68
/**
69
 * Allocates and initializes a new parallel DMA.
70
71
72
73
74
75
76
77
78
 *
 * @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.
 **/
79
int aml_dma_linux_par_create(struct aml_dma **dma, size_t nbreqs);
80
81
82
83

/**
 * 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.
84
 **/
85
void aml_dma_linux_par_destroy(struct aml_dma **dma);
86

87
88
89
/**
 * @}
 **/
90
#endif // AML_LINUX_DMA_LINUX_PAR_H