/* Generated by Cython 0.26 */

#ifndef __PYX_HAVE_API__pygpu__collectives
#define __PYX_HAVE_API__pygpu__collectives
#include "Python.h"
#include "collectives.h"

static PyTypeObject *__pyx_ptype_5pygpu_11collectives_GpuCommCliqueId = 0;
#define PyGpuCliqueIdType (*__pyx_ptype_5pygpu_11collectives_GpuCommCliqueId)
static PyTypeObject *__pyx_ptype_5pygpu_11collectives_GpuComm = 0;
#define PyGpuCommType (*__pyx_ptype_5pygpu_11collectives_GpuComm)

static struct PyGpuArrayObject *(*__pyx_api_f_5pygpu_11collectives_pygpu_make_reduced)(struct PyGpuCommObject *, struct PyGpuArrayObject *, int) = 0;
#define pygpu_make_reduced __pyx_api_f_5pygpu_11collectives_pygpu_make_reduced
static struct PyGpuArrayObject *(*__pyx_api_f_5pygpu_11collectives_pygpu_make_all_reduced)(struct PyGpuCommObject *, struct PyGpuArrayObject *, int) = 0;
#define pygpu_make_all_reduced __pyx_api_f_5pygpu_11collectives_pygpu_make_all_reduced
static struct PyGpuArrayObject *(*__pyx_api_f_5pygpu_11collectives_pygpu_make_reduce_scattered)(struct PyGpuCommObject *, struct PyGpuArrayObject *, int) = 0;
#define pygpu_make_reduce_scattered __pyx_api_f_5pygpu_11collectives_pygpu_make_reduce_scattered
static struct PyGpuArrayObject *(*__pyx_api_f_5pygpu_11collectives_pygpu_make_all_gathered)(struct PyGpuCommObject *, struct PyGpuArrayObject *, unsigned int) = 0;
#define pygpu_make_all_gathered __pyx_api_f_5pygpu_11collectives_pygpu_make_all_gathered
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif


static int import_pygpu__collectives(void) {
  PyObject *module = 0;
  module = __Pyx_ImportModule("pygpu.collectives");
  if (!module) goto bad;
  if (__Pyx_ImportFunction(module, "pygpu_make_reduced", (void (**)(void))&__pyx_api_f_5pygpu_11collectives_pygpu_make_reduced, "struct PyGpuArrayObject *(struct PyGpuCommObject *, struct PyGpuArrayObject *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "pygpu_make_all_reduced", (void (**)(void))&__pyx_api_f_5pygpu_11collectives_pygpu_make_all_reduced, "struct PyGpuArrayObject *(struct PyGpuCommObject *, struct PyGpuArrayObject *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "pygpu_make_reduce_scattered", (void (**)(void))&__pyx_api_f_5pygpu_11collectives_pygpu_make_reduce_scattered, "struct PyGpuArrayObject *(struct PyGpuCommObject *, struct PyGpuArrayObject *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "pygpu_make_all_gathered", (void (**)(void))&__pyx_api_f_5pygpu_11collectives_pygpu_make_all_gathered, "struct PyGpuArrayObject *(struct PyGpuCommObject *, struct PyGpuArrayObject *, unsigned int)") < 0) goto bad;
  Py_DECREF(module); module = 0;
  __pyx_ptype_5pygpu_11collectives_GpuCommCliqueId = __Pyx_ImportType("pygpu.collectives", "GpuCommCliqueId", sizeof(struct PyGpuCliqueIdObject), 1); if (!__pyx_ptype_5pygpu_11collectives_GpuCommCliqueId) goto bad;
  __pyx_ptype_5pygpu_11collectives_GpuComm = __Pyx_ImportType("pygpu.collectives", "GpuComm", sizeof(struct PyGpuCommObject), 1); if (!__pyx_ptype_5pygpu_11collectives_GpuComm) goto bad;
  return 0;
  bad:
  Py_XDECREF(module);
  return -1;
}

#endif /* !__PYX_HAVE_API__pygpu__collectives */
