forked from Theano/libgpuarray
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollectives.h
More file actions
131 lines (120 loc) · 4.29 KB
/
Copy pathcollectives.h
File metadata and controls
131 lines (120 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef GPUARRAY_COLLECTIVES_H
#define GPUARRAY_COLLECTIVES_H
#include <gpuarray/array.h>
#include <gpuarray/buffer_collectives.h>
#include <gpuarray/config.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#ifdef CONFUSE_EMACS
}
#endif // CONFUSE_EMACS
/*****************************************************************************
* Multi-gpu collectives interface *
******************************************************************************/
/**
* Reduce collective operation for non root participant ranks in a
* communicator world.
*
* \param src array to be reduced
* \param opcode reduce operation code, see #gpucomm_reduce_ops
* \param root rank in `comm` which will collect result
* \param comm gpu communicator
*
* \note Root rank of reduce operation must call GpuArray_reduce().
* \note Must be called separately for each rank in `comm`, except root rank.
*
* \return error code or #GA_NO_ERROR if success
*/
GPUARRAY_PUBLIC int GpuArray_reduce_from(const GpuArray* src, int opcode,
int root, gpucomm* comm);
/**
* Reduce collective operation for ranks in a communicator world.
*
* \param src array to be reduced
* \param dest array to collect reduce operation result
* \param opcode reduce operation code, see #gpucomm_reduce_ops
* \param root rank in `comm` which will collect result
* \param comm gpu communicator
*
* \note Can be used by root and non root ranks alike.
*
* \note Non root ranks can call this, using a NULL `dest`.
* \note Must be called separately for each rank in `comm` (non root
* can call GpuArray_reduce_from() instead).
*
* \return error code or #GA_NO_ERROR if success
*/
GPUARRAY_PUBLIC int GpuArray_reduce(const GpuArray* src, GpuArray* dest,
int opcode, int root, gpucomm* comm);
/**
* AllReduce collective operation for ranks in a communicator world.
*
* Reduces `src` using op operation and leaves identical copies of
* result in `dest` on each rank of `comm`.
*
* \param src array to be reduced
* \param dest array to collect reduce operation result
* \param opcode reduce operation code, see #gpucomm_reduce_ops
* \param comm gpu communicator
*
* \note Must be called separately for each rank in `comm`.
*
* \return error code or #GA_NO_ERROR if success
*/
GPUARRAY_PUBLIC int GpuArray_all_reduce(const GpuArray* src, GpuArray* dest,
int opcode, gpucomm* comm);
/**
* ReduceScatter collective operation for ranks in a communicator world.
*
* Reduces data in `src` using `opcode` operation and leaves reduced
* result scattered over `dest` in the user-defined rank order in
* `comm`.
*
* \param src array to be reduced
* \param dest array to collect reduce operation scattered result
* \param opcode reduce operation code, see #gpucomm_reduce_ops
* \param comm gpu communicator
*
* \note Must be called separately for each rank in `comm`.
*
* \return error code or #GA_NO_ERROR if success
*/
GPUARRAY_PUBLIC int GpuArray_reduce_scatter(const GpuArray* src, GpuArray* dest,
int opcode, gpucomm* comm);
/**
* Broadcast collective operation for ranks in a communicator world.
*
* Copies `array` to all ranks in `comm`.
*
* \param array array to be broadcasted, if root rank, else to receive
* \param root rank in `comm` which broadcasts its array
* \param comm gpu communicator
*
* \note Must be called separately for each rank in `comm`.
*
* \return error code or #GA_NO_ERROR if success
*/
GPUARRAY_PUBLIC int GpuArray_broadcast(GpuArray* array, int root,
gpucomm* comm);
/**
* AllGather collective operation for ranks in a communicator world.
*
* Each rank receives all `src` arrays from every rank in the
* user-defined rank order in `comm`.
*
* \param src array to be gathered
* \param dest array to receive all gathered arrays from ranks in
* `comm`
* \param comm gpu communicator
*
* \note Must be called separately for each rank in `comm`.
*
* \return error code or #GA_NO_ERROR if success
*/
GPUARRAY_PUBLIC int GpuArray_all_gather(const GpuArray* src, GpuArray* dest,
gpucomm* comm);
#ifdef __cplusplus
}
#endif
#endif // GPUARRAY_COLLECTIVES_H