forked from Theano/libgpuarray
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunicator.c
More file actions
44 lines (37 loc) · 1.08 KB
/
communicator.c
File metadata and controls
44 lines (37 loc) · 1.08 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
#include <check.h>
#include <mpi.h>
#include "gpuarray/buffer.h"
#include "gpuarray/buffer_collectives.h"
#include "gpuarray/error.h"
extern gpucontext* ctx;
int comm_ndev; //!< number of devices in the comm
int comm_rank; //!< comm's rank in the world
// (for the tests it's the same as process rank in MPI_COMM_WORLD)
gpucomm* comm;
extern void setup(void);
extern void teardown(void);
/**
* \brief Setup for `check_buffer_collectives.c` and `check_collectives.c`.
*
* Includes tests for `gpucomm_new` and `gpucomm_gen_clique_id`
*/
void setup_comm(void)
{
setup();
int err;
MPI_Barrier(MPI_COMM_WORLD);
gpucommCliqueId comm_id;
err = gpucomm_gen_clique_id(ctx, &comm_id);
// Has successfully got a unique comm id.
ck_assert_int_eq(err, GA_NO_ERROR);
MPI_Bcast(&comm_id, GA_COMM_ID_BYTES, MPI_CHAR, 0, MPI_COMM_WORLD);
err = gpucomm_new(&comm, ctx, comm_id, comm_ndev, comm_rank % comm_ndev);
// Has successfully created a new gpucomm.
ck_assert_int_eq(err, GA_NO_ERROR);
ck_assert_ptr_ne(comm, NULL);
}
void teardown_comm(void)
{
gpucomm_free(comm);
teardown();
}