int gpucomm_broadcast(gpudata* array, size_t offset, size_t count, int typecode,
                      int root, gpucomm* comm) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return error_set(ctx->err, GA_DEVSUP_ERROR, "Collectives unavailable");
  return ctx->comm_ops->broadcast(array, offset, count, typecode, root, comm);
}
void gpucomm_free(gpucomm* comm) {
  gpucontext* ctx;
  if (comm == NULL) return;
  ctx = gpucomm_context(comm);
  if (ctx->comm_ops != NULL)
    ctx->comm_ops->comm_free(comm);
}
int gpucomm_broadcast(gpudata* array, size_t offset, size_t count, int typecode,
                      int root, gpucomm* comm) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return GA_COMM_ERROR;
  return ctx->comm_ops->broadcast(array, offset, count, typecode, root, comm);
}
int gpucomm_all_gather(gpudata* src, size_t offsrc, gpudata* dest,
                       size_t offdest, size_t count, int typecode,
                       gpucomm* comm) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return error_set(ctx->err, GA_DEVSUP_ERROR, "Collectives unavailable");
  return ctx->comm_ops->all_gather(src, offsrc, dest, offdest, count, typecode,
                                   comm);
}
int gpucomm_all_gather(gpudata* src, size_t offsrc, gpudata* dest,
                       size_t offdest, size_t count, int typecode,
                       gpucomm* comm) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return GA_COMM_ERROR;
  return ctx->comm_ops->all_gather(src, offsrc, dest, offdest, count, typecode,
                                   comm);
}
int gpucomm_reduce(gpudata* src, size_t offsrc, gpudata* dest, size_t offdest,
                   size_t count, int typecode, int opcode, int root,
                   gpucomm* comm) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return GA_COMM_ERROR;
  return ctx->comm_ops->reduce(src, offsrc, dest, offdest, count, typecode,
                               opcode, root, comm);
}
int gpucomm_get_rank(gpucomm* comm, int* rank) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return error_set(ctx->err, GA_DEVSUP_ERROR, "Collectives unavailable");
  return ctx->comm_ops->get_rank(comm, rank);
}
int gpucomm_get_rank(gpucomm* comm, int* rank) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return GA_COMM_ERROR;
  return ctx->comm_ops->get_rank(comm, rank);
}
int gpucomm_get_count(gpucomm* comm, int* gpucount) {
  gpucontext* ctx = gpucomm_context(comm);
  if (ctx->comm_ops == NULL)
    return GA_COMM_ERROR;
  return ctx->comm_ops->get_count(comm, gpucount);
}