Skip to content

Fixing CI for #50 #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7dd904d
Add support for dpctl.dparray.
PokhodenkoSA Dec 4, 2020
26d5e2e
Fix build issues for dppy_rt.c
DrTodd13 Dec 9, 2020
a320b50
Name changes from dparray things to usmarray.
DrTodd13 Dec 9, 2020
f9de97a
Delete old backup file (#45)
1e-to Dec 4, 2020
b8c11f7
Del dppl dir in tests (#43)
1e-to Dec 4, 2020
16fb9b8
Revert "numba-dppy requires cffi"
PokhodenkoSA Dec 4, 2020
56e969a
Remove use of cffi
PokhodenkoSA Dec 4, 2020
0a56e08
Rename dppl to dppy (#42)
1e-to Dec 7, 2020
023fef9
Pass to rewrite Numpy function names to be able to overload them for …
reazulhoque Dec 9, 2020
059a5a3
Store allocation queue on a per-object basis.
DrTodd13 Dec 10, 2020
f895e1d
Merge branch 'main' into spokhode/dparray
PokhodenkoSA Dec 10, 2020
4e99a55
Add imports to usmarray module and fixed setup.py extension initializ…
PokhodenkoSA Dec 10, 2020
595f94b
Register is_usm_callback with dpctl to say whether a given Python obj…
DrTodd13 Dec 11, 2020
c87a94b
Remove printf.
DrTodd13 Dec 11, 2020
1214893
There were some spots where there was a silent assumption that the cl…
DrTodd13 Dec 11, 2020
a2b2bb7
Found another spot where the current module was being used rather tha…
DrTodd13 Dec 11, 2020
0769a97
Fix numba path
Dec 15, 2020
eb53c26
fix
Dec 15, 2020
f4333dd
Convert tests for USM array to unittest (#118)
PokhodenkoSA Dec 15, 2020
313727b
Small code fixes
PokhodenkoSA Dec 15, 2020
ff877fc
use include_path to find numba
Dec 15, 2020
f5b1989
Added loader lib for win
Dec 16, 2020
8b4a946
Merge branch 'main' into spokhode/dparray
PokhodenkoSA Dec 16, 2020
5d8dd39
Use unittest.TestCase as base class for TestUsmArray
PokhodenkoSA Dec 16, 2020
1303b5f
Merge branch 'main' into spokhode/dparray
PokhodenkoSA Dec 16, 2020
0e71fa7
one test in debug
PokhodenkoSA Dec 16, 2020
b00afc6
fix
PokhodenkoSA Dec 16, 2020
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
4 changes: 3 additions & 1 deletion conda-recipe/run_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ call "%ONEAPI_ROOT%\compiler\latest\env\vars.bat"

@echo on

python -m numba.runtests -b -v -m -- numba_dppy.tests
export NUMBA_DEBUG=1

python -m numba.runtests -b -v -m -- numba_dppy.tests.test_usmarray.TestUsmArray.test_numba_usmarray_as_ndarray
IF %ERRORLEVEL% NEQ 0 exit /B 1

exit /B 0
3 changes: 2 additions & 1 deletion conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source ${ONEAPI_ROOT}/tbb/latest/env/vars.sh

set -x

python -m numba.runtests -b -v -m -- numba_dppy.tests
export NUMBA_DEBUG=1
python -m numba.runtests -b -v -m -- numba_dppy.tests.test_usmarray.TestUsmArray.test_numba_usmarray_as_ndarray

exit 0
171 changes: 171 additions & 0 deletions numba_dppy/dppy_rt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#include "_pymodule.h"
#include "core/runtime/nrt_external.h"
#include "assert.h"
#include <stdio.h>
#if !defined _WIN32
#include <dlfcn.h>
#else
#include <windows.h>
#endif

NRT_ExternalAllocator usmarray_allocator;
NRT_external_malloc_func internal_allocator = NULL;
NRT_external_free_func internal_free = NULL;
void *(*get_queue_internal)(void) = NULL;
void (*free_queue_internal)(void*) = NULL;

void * save_queue_allocator(size_t size, void *opaque) {
// Allocate a pointer-size more space than neded.
int new_size = size + sizeof(void*);
// Get the current queue
void *cur_queue = get_queue_internal(); // this makes a copy
// Use that queue to allocate.
void *data = internal_allocator(new_size, cur_queue);
// Set first pointer-sized data in allocated space to be the current queue.
*(void**)data = cur_queue;
// Return the pointer after this queue in memory.
return (char*)data + sizeof(void*);
}

void save_queue_deallocator(void *data, void *opaque) {
// Compute original allocation location by subtracting the length
// of the queue pointer from the data location that Numba thinks
// starts the object.
void *orig_data = (char*)data - sizeof(void*);
// Get the queue from the original data by derefencing the first qword.
void *obj_queue = *(void**)orig_data;
// Free the space using the correct queue.
internal_free(orig_data, obj_queue);
// Free the queue itself.
free_queue_internal(obj_queue);
}

void usmarray_memsys_init(void) {
#if !defined _WIN32
char *lib_name = "libDPCTLSyclInterface.so";
char *malloc_name = "DPCTLmalloc_shared";
char *free_name = "DPCTLfree_with_queue";
char *get_queue_name = "DPCTLQueueMgr_GetCurrentQueue";
char *free_queue_name = "DPCTLQueue_Delete";

void *sycldl = dlopen(lib_name, RTLD_NOW);
assert(sycldl != NULL);
internal_allocator = (NRT_external_malloc_func)dlsym(sycldl, malloc_name);
usmarray_allocator.malloc = save_queue_allocator;
if (usmarray_allocator.malloc == NULL) {
printf("Did not find %s in %s\n", malloc_name, lib_name);
exit(-1);
}

usmarray_allocator.realloc = NULL;

internal_free = (NRT_external_free_func)dlsym(sycldl, free_name);
usmarray_allocator.free = save_queue_deallocator;
if (usmarray_allocator.free == NULL) {
printf("Did not find %s in %s\n", free_name, lib_name);
exit(-1);
}

get_queue_internal = (void *(*)(void))dlsym(sycldl, get_queue_name);
if (get_queue_internal == NULL) {
printf("Did not find %s in %s\n", get_queue_name, lib_name);
exit(-1);
}
usmarray_allocator.opaque_data = NULL;

free_queue_internal = (void (*)(void*))dlsym(sycldl, free_queue_name);
if (free_queue_internal == NULL) {
printf("Did not find %s in %s\n", free_queue_name, lib_name);
exit(-1);
}
#else
char *lib_name = "libDPCTLSyclInterface.dll";
char *malloc_name = "DPCTLmalloc_shared";
char *free_name = "DPCTLfree_with_queue";
char *get_queue_name = "DPCTLQueueMgr_GetCurrentQueue";
char *free_queue_name = "DPCTLQueue_Delete";

HMODULE sycldl = LoadLibrary(lib_name);
assert(sycldl != NULL);
internal_allocator = (NRT_external_malloc_func)GetProcAddress(sycldl, malloc_name);
usmarray_allocator.malloc = save_queue_allocator;
if (usmarray_allocator.malloc == NULL) {
printf("Did not find %s in %s\n", malloc_name, lib_name);
exit(-1);
}

usmarray_allocator.realloc = NULL;

internal_free = (NRT_external_free_func)GetProcAddress(sycldl, free_name);
usmarray_allocator.free = save_queue_deallocator;
if (usmarray_allocator.free == NULL) {
printf("Did not find %s in %s\n", free_name, lib_name);
exit(-1);
}

get_queue_internal = (void *(*)(void))GetProcAddress(sycldl, get_queue_name);
if (get_queue_internal == NULL) {
printf("Did not find %s in %s\n", get_queue_name, lib_name);
exit(-1);
}
usmarray_allocator.opaque_data = NULL;

free_queue_internal = (void (*)(void*))GetProcAddress(sycldl, free_queue_name);
if (free_queue_internal == NULL) {
printf("Did not find %s in %s\n", free_queue_name, lib_name);
exit(-1);
}
#endif
}

void * usmarray_get_ext_allocator(void) {
return (void*)&usmarray_allocator;
}

static PyObject *
get_external_allocator(PyObject *self, PyObject *args) {
return PyLong_FromVoidPtr(usmarray_get_ext_allocator());
}

static PyMethodDef ext_methods[] = {
#define declmethod_noargs(func) { #func , ( PyCFunction )func , METH_NOARGS, NULL }
declmethod_noargs(get_external_allocator),
{NULL},
#undef declmethod_noargs
};

static PyObject *
build_c_helpers_dict(void)
{
PyObject *dct = PyDict_New();
if (dct == NULL)
goto error;

#define _declpointer(name, value) do { \
PyObject *o = PyLong_FromVoidPtr(value); \
if (o == NULL) goto error; \
if (PyDict_SetItemString(dct, name, o)) { \
Py_DECREF(o); \
goto error; \
} \
Py_DECREF(o); \
} while (0)

_declpointer("usmarray_get_ext_allocator", &usmarray_get_ext_allocator);

#undef _declpointer
return dct;
error:
Py_XDECREF(dct);
return NULL;
}

MOD_INIT(_dppy_rt) {
PyObject *m;
MOD_DEF(m, "numba_dppy._dppy_rt", "No docs", ext_methods)
if (m == NULL)
return MOD_ERROR_VAL;
usmarray_memsys_init();
PyModule_AddObject(m, "c_helpers", build_c_helpers_dict());
return MOD_SUCCESS_VAL(m);
}
Loading