Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 0 additions & 159 deletions numba_cuda/numba/cuda/cext/_devicearray.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions numba_cuda/numba/cuda/cext/_devicearray.h

This file was deleted.

38 changes: 0 additions & 38 deletions numba_cuda/numba/cuda/cext/_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "frameobject.h"
#include "traceback.h"
#include "typeconv.hpp"
#include "_devicearray.h"

/*
* Notes on the C_TRACE macro:
Expand Down Expand Up @@ -940,37 +939,6 @@ Dispatcher_cuda_call(Dispatcher *self, PyObject *args, PyObject *kws)
return retval;
}

static int
import_devicearray(void)
{
PyObject *devicearray = PyImport_ImportModule(NUMBA_DEVICEARRAY_IMPORT_NAME);
if (devicearray == NULL) {
return -1;
}

PyObject *d = PyModule_GetDict(devicearray);
if (d == NULL) {
Py_DECREF(devicearray);
return -1;
}

PyObject *key = PyUnicode_FromString("_DEVICEARRAY_API");
PyObject *c_api = PyDict_GetItemWithError(d, key);
int retcode = 0;
if (PyCapsule_IsValid(c_api, NUMBA_DEVICEARRAY_IMPORT_NAME "._DEVICEARRAY_API")) {
DeviceArray_API = (void**)PyCapsule_GetPointer(c_api, NUMBA_DEVICEARRAY_IMPORT_NAME "._DEVICEARRAY_API");
if (DeviceArray_API == NULL) {
retcode = -1;
}
} else {
retcode = -1;
}

Py_DECREF(key);
Py_DECREF(devicearray);
return retcode;
}

static PyMethodDef Dispatcher_methods[] = {
{ "_clear", (PyCFunction)Dispatcher_clear, METH_NOARGS, NULL },
{ "_insert", (PyCFunction)Dispatcher_Insert, METH_VARARGS | METH_KEYWORDS,
Expand Down Expand Up @@ -1076,12 +1044,6 @@ static PyMethodDef ext_methods[] = {


MOD_INIT(_dispatcher) {
if (import_devicearray() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, NUMBA_DEVICEARRAY_IMPORT_NAME " failed to import");
return MOD_ERROR_VAL;
}

PyObject *m;
MOD_DEF(m, "_dispatcher", "No docs", ext_methods)
if (m == NULL)
Expand Down
111 changes: 0 additions & 111 deletions numba_cuda/numba/cuda/cext/_typeof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "_typeof.h"
#include "_hashtable.h"
#include "_devicearray.h"
#include "pyerrors.h"

#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
Expand Down Expand Up @@ -56,9 +55,6 @@ static PyObject *str_typeof_pyval = NULL;
static PyObject *str_value = NULL;
static PyObject *str_numba_type = NULL;

/* CUDA device array API */
void **DeviceArray_API;

/*
* Type fingerprint computation.
*/
Expand Down Expand Up @@ -857,109 +853,6 @@ int typecode_arrayscalar(PyObject *dispatcher, PyObject* aryscalar) {
return BASIC_TYPECODES[typecode];
}

static
int typecode_devicendarray(PyObject *dispatcher, PyObject *ary)
{
int typecode;
int dtype;
int ndim;
int layout = 0;
PyObject *ndim_obj = nullptr;
PyObject *num_obj = nullptr;
PyObject *dtype_obj = nullptr;
int dtype_num = 0;

PyObject* flags = PyObject_GetAttrString(ary, "flags");
if (flags == NULL)
{
PyErr_Clear();
goto FALLBACK;
}

if (PyDict_GetItemString(flags, "C_CONTIGUOUS") == Py_True) {
layout = 1;
} else if (PyDict_GetItemString(flags, "F_CONTIGUOUS") == Py_True) {
layout = 2;
}

Py_DECREF(flags);

ndim_obj = PyObject_GetAttrString(ary, "ndim");
if (ndim_obj == NULL) {
/* If there's no ndim, try to proceed by clearing the error and using the
* fallback. */
PyErr_Clear();
goto FALLBACK;
}

ndim = PyLong_AsLong(ndim_obj);
Py_DECREF(ndim_obj);

if (PyErr_Occurred()) {
/* ndim wasn't an integer for some reason - unlikely to happen, but try
* the fallback. */
PyErr_Clear();
goto FALLBACK;
}

if (ndim <= 0 || ndim > N_NDIM)
goto FALLBACK;

dtype_obj = PyObject_GetAttrString(ary, "dtype");
if (dtype_obj == NULL) {
/* No dtype: try the fallback. */
PyErr_Clear();
goto FALLBACK;
}

num_obj = PyObject_GetAttrString(dtype_obj, "num");
Py_DECREF(dtype_obj);

if (num_obj == NULL) {
/* This strange dtype has no num - try the fallback. */
PyErr_Clear();
goto FALLBACK;
}

dtype_num = PyLong_AsLong(num_obj);
Py_DECREF(num_obj);

if (PyErr_Occurred()) {
/* num wasn't an integer for some reason - unlikely to happen, but try
* the fallback. */
PyErr_Clear();
goto FALLBACK;
}

dtype = dtype_num_to_typecode(dtype_num);
if (dtype == -1) {
/* Not a dtype we have in the global lookup table. */
goto FALLBACK;
}

/* Fast path, using direct table lookup */
assert(layout < N_LAYOUT);
assert(ndim <= N_NDIM);
assert(dtype < N_DTYPES);
typecode = cached_arycode[ndim - 1][layout][dtype];

if (typecode == -1) {
/* First use of this table entry, so it requires populating */
typecode = typecode_fallback_keep_ref(dispatcher, (PyObject*)ary);
cached_arycode[ndim - 1][layout][dtype] = typecode;
}

return typecode;

FALLBACK:
/* Slower path, for non-trivial array types. At present this always uses
the fingerprinting to get the typecode. Future optimization might
implement a cache, but this would require some fast equivalent of
PyArray_DESCR for a device array. */

return typecode_using_fingerprint(dispatcher, (PyObject *) ary);
}

extern "C" int
typeof_typecode(PyObject *dispatcher, PyObject *val)
{
Expand Down Expand Up @@ -994,10 +887,6 @@ typeof_typecode(PyObject *dispatcher, PyObject *val)
else if (tyobj == &PyArray_Type) {
return typecode_ndarray(dispatcher, (PyArrayObject*)val);
}
/* Subtype of CUDA device array */
else if (PyType_IsSubtype(tyobj, &DeviceArrayType)) {
return typecode_devicendarray(dispatcher, val);
}
/* Subtypes of Array handling */
else if (PyType_IsSubtype(tyobj, &PyArray_Type)) {
/* By default, Numba will treat all numpy.ndarray subtypes as if they
Expand Down
Loading
Loading