File: communicator.c

package info (click to toggle)
libgpuarray 0.7.6-13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,176 kB
  • sloc: ansic: 19,235; python: 4,591; makefile: 208; javascript: 71; sh: 15
file content (46 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (3)
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
#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)
{
  int err;
  gpucommCliqueId comm_id;

  setup();

  MPI_Barrier(MPI_COMM_WORLD);

  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();
}