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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ conda activate build-env
```bash
conda build conda-recipe
```
On Windows to cope with [long file names](https://github.com/IntelPython/pydppl/issues/15):
On Windows to cope with [long file names](https://github.com/IntelPython/dpctl/issues/15):
```cmd
conda build --croot=C:/tmp conda-recipe
```
3. Install conda package
```bash
conda install pydppl
conda install dpctl
```

Using PyDPPL
Expand Down
2 changes: 1 addition & 1 deletion backends/include/dppl_opencl_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
///
/// \file
/// This file contains the declaration of a C API to expose a lightweight OpenCL
/// interface for the Python dppl package.
/// interface for the Python dpctl package.
///
//===----------------------------------------------------------------------===//

Expand Down
4 changes: 2 additions & 2 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ make -j 4 && make install

cd ..

# required by dppl.opencl_core
# required by dpctl.opencl_core
export DPPL_OPENCL_INTERFACE_LIBDIR=${PREFIX}
export DPPL_OPENCL_INTERFACE_INCLDIR=${PREFIX}/include
export OpenCL_LIBDIR=${DPCPP_ROOT}/lib

# required by dppl.sycl_core
# required by dpctl.sycl_core
export DPPL_SYCL_INTERFACE_LIBDIR=${PREFIX}/lib
export DPPL_SYCL_INTERFACE_INCLDIR=${PREFIX}/include

Expand Down
4 changes: 2 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set name = "pydppl" %}
{% set name = "dpctl" %}

package:
name: {{ name|lower }}
Expand Down Expand Up @@ -39,7 +39,7 @@ about:
software license agreement (as set forth above, in the license section of
the installed Conda package and/or the README file) and all notices,
disclaimers or license terms for third party or open source software
included in or with the software.</strong>
included in or with the software.</strong>
<br/><br/>
EULA: <a href="https://opensource.org/licenses/Apache-2.0" target="_blank">Apache-2.0</a>
<br/><br/>
Expand Down
6 changes: 3 additions & 3 deletions conda-recipe/run_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ set ERRORLEVEL=

@echo on

"%PYTHON%" -c "import dppl"
"%PYTHON%" -c "import dpctl"
IF %ERRORLEVEL% NEQ 0 exit 1

"%PYTHON%" -c "import dppl.ocldrv"
"%PYTHON%" -c "import dpctl.ocldrv"
IF %ERRORLEVEL% NEQ 0 exit 1

"%PYTHON%" -m unittest -v dppl.tests
"%PYTHON%" -m unittest -v dpctl.tests
IF %ERRORLEVEL% NEQ 0 exit 1
6 changes: 3 additions & 3 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -e
# Suppress error b/c it could fail on Ubuntu 18.04
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh || true

${PYTHON} -c "import dppl"
${PYTHON} -c "import dppl.ocldrv"
${PYTHON} -m unittest -v dppl.tests
${PYTHON} -c "import dpctl"
${PYTHON} -c "import dpctl.ocldrv"
${PYTHON} -m unittest -v dpctl.tests
File renamed without changes.
12 changes: 6 additions & 6 deletions dppl/__init__.py → dpctl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

PyDPPL provides a lightweight Python abstraction over DPC++/SYCL and
OpenCL runtime objects. The DPC++ runtime wrapper objects can be
accessed by importing dppl. The OpenCL runtime wrapper objects can be
accessed by importing dppl.ocldrv. The library is in an early-beta
accessed by importing dpctl. The OpenCL runtime wrapper objects can be
accessed by importing dpctl.ocldrv. The library is in an early-beta
stage of development and not yet ready for production usage.

PyDPPL's intended usage is as a common SYCL interoperability layer for
Expand All @@ -13,15 +13,15 @@
of the library.

Currently, only a small subset of DPC++ runtime objects are exposed
through the dppl module. The main API classes inside the dppl module are:
through the dpctl module. The main API classes inside the dpctl module are:

Runtime: The class stores a global SYCL queue and a stack of
currently activated queues. Runtime provides a special getter
method to retrieve the currently activated SYCL queue
as a Py_capsule.

A single global thread local instance of the Runtime class
is created on loading the dppl module for the first time.
is created on loading the dpctl module for the first time.

DeviceArray: A DeviceArray object encapsulates a one-dimensional
cl::sycl::buffer object. A DeviceArray object can be
Expand All @@ -39,9 +39,9 @@
Global data members:
runtime - An instance of the Runtime class.

Please use `pydoc dppl._sycl_core` to look at the current API for dppl.
Please use `pydoc dpctl._sycl_core` to look at the current API for dpctl.

Please use `pydoc dppl.ocldrv` to look at the current API for dppl.ocldrv.
Please use `pydoc dpctl.ocldrv` to look at the current API for dpctl.ocldrv.

'''
__author__ = "Intel Corp."
Expand Down
6 changes: 3 additions & 3 deletions dppl/_memory.pyx → dpctl/_memory.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dppl
from dppl.backend cimport *
import dpctl
from dpctl.backend cimport *
from ._sycl_core cimport SyclContext, SyclQueue

from cpython cimport Py_buffer
Expand All @@ -19,7 +19,7 @@ cdef class Memory:

if (nbytes > 0):
if queue is None:
queue = dppl.get_current_queue()
queue = dpctl.get_current_queue()

if (ptr_type == "shared"):
p = DPPLmalloc_shared(nbytes, queue.get_queue_ref())
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions dppl/ocldrv.py → dpctl/ocldrv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##===---------- ocldrv.py - dppl.ocldrv interface -----*- Python -*-----===##
##===---------- ocldrv.py - dpctl.ocldrv interface -----*- Python -*-----===##
##
## Python Data Parallel Processing Library (PyDPPL)
##
Expand All @@ -22,7 +22,7 @@
### This file exposes Python classes for different OpenCL classes that are
### exposed by the _dppl_binding CFFI extension module.
##===----------------------------------------------------------------------===##
''' The dppl.ocldrv module contains a set of Python wrapper classes for
''' The dpctl.ocldrv module contains a set of Python wrapper classes for
OpenCL objects. The module has wrappers for cl_context, cl_device,
cl_mem, cl_program, and cl_kernel objects.

Expand Down Expand Up @@ -71,14 +71,14 @@


class DpplDriverError(Exception):
""" The exception is raised when dppl.ocldrv cannot find an OpenCL Driver.
""" The exception is raised when dpctl.ocldrv cannot find an OpenCL Driver.
"""
pass


class DeviceNotFoundError(Exception):
""" The exception is raised when the requested type of OpenCL device is
not available or not supported by dppl.ocldrv.
not available or not supported by dpctl.ocldrv.
"""
pass

Expand Down
4 changes: 2 additions & 2 deletions dppl/opencl_core.py → dpctl/opencl_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##===--------- opencl_core.py - dppl.ocldrv interface -----*- Python -*----===##
##===--------- opencl_core.py - dpctl.ocldrv interface -----*- Python -*----===##
##
## Python Data Parallel Processing Library (PyDPPL)
##
Expand Down Expand Up @@ -57,7 +57,7 @@
# globals needed to use the shared object. It must be in valid C syntax.
ffi.cdef(glue_h)

ffi_lib_name = "dppl._opencl_core"
ffi_lib_name = "dpctl._opencl_core"

ffi.set_source(
ffi_lib_name,
Expand Down
2 changes: 1 addition & 1 deletion dppl/sycl_core.pyx → dpctl/sycl_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from __future__ import print_function
from enum import Enum, auto
import logging
from dppl.backend cimport *
from dpctl.backend cimport *


_logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##===---------- test_sycl_queue_manager.py - dppl -------*- Python -*-----===##
##===---------- test_sycl_queue_manager.py - dpctl -------*- Python -*-----===##
##
## Python Data Parallel Processing Library (PyDPPL)
##
Expand All @@ -23,76 +23,76 @@
### in sycl_core.pyx.
##===----------------------------------------------------------------------===##

import dppl
import dpctl
import unittest

class TestGetNumPlatforms (unittest.TestCase):
@unittest.skipIf(not dppl.has_sycl_platforms(), "No SYCL platforms available")
@unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available")
def test_dppl_get_num_platforms (self):
if(dppl.has_sycl_platforms):
self.assertGreaterEqual(dppl.get_num_platforms(), 1)
if(dpctl.has_sycl_platforms):
self.assertGreaterEqual(dpctl.get_num_platforms(), 1)

@unittest.skipIf(not dppl.has_sycl_platforms(), "No SYCL platforms available")
@unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available")
class TestDumpMethods (unittest.TestCase):
def test_dppl_dump (self):
try:
dppl.dump()
dpctl.dump()
except Exception:
self.fail("Encountered an exception inside dump().")

def test_dppl_dump_device_info (self):
q = dppl.get_current_queue()
q = dpctl.get_current_queue()
try:
q.get_sycl_device().dump_device_info()
except Exception:
self.fail("Encountered an exception inside dump_device_info().")

@unittest.skipIf(not dppl.has_sycl_platforms(), "No SYCL platforms available")
@unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available")
class TestDPPLIsInDPPLCtxt (unittest.TestCase):

def test_is_in_dppl_ctxt_outside_device_ctxt (self):
self.assertFalse(dppl.is_in_dppl_ctxt())
self.assertFalse(dpctl.is_in_dppl_ctxt())

def test_is_in_dppl_ctxt_inside_device_ctxt (self):
with dppl.device_context(dppl.device_type.gpu):
self.assertTrue(dppl.is_in_dppl_ctxt())
with dpctl.device_context(dpctl.device_type.gpu):
self.assertTrue(dpctl.is_in_dppl_ctxt())

@unittest.skipIf(not dppl.has_cpu_queues(), "No CPU platforms available")
@unittest.skipIf(not dpctl.has_cpu_queues(), "No CPU platforms available")
def test_is_in_dppl_ctxt_inside_nested_device_ctxt (self):
with dppl.device_context(dppl.device_type.cpu):
with dppl.device_context(dppl.device_type.gpu):
self.assertTrue(dppl.is_in_dppl_ctxt())
self.assertTrue(dppl.is_in_dppl_ctxt())
self.assertFalse(dppl.is_in_dppl_ctxt())
with dpctl.device_context(dpctl.device_type.cpu):
with dpctl.device_context(dpctl.device_type.gpu):
self.assertTrue(dpctl.is_in_dppl_ctxt())
self.assertTrue(dpctl.is_in_dppl_ctxt())
self.assertFalse(dpctl.is_in_dppl_ctxt())

@unittest.skipIf(not dppl.has_sycl_platforms(), "No SYCL platforms available")
@unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available")
class TestGetCurrentQueueInMultipleThreads (unittest.TestCase):

def test_num_current_queues_outside_with_clause (self):
self.assertEqual(dppl.get_num_activated_queues(), 0)
self.assertEqual(dpctl.get_num_activated_queues(), 0)

@unittest.skipIf(not dppl.has_gpu_queues(), "No GPU platforms available")
@unittest.skipIf(not dppl.has_cpu_queues(), "No CPU platforms available")
@unittest.skipIf(not dpctl.has_gpu_queues(), "No GPU platforms available")
@unittest.skipIf(not dpctl.has_cpu_queues(), "No CPU platforms available")
def test_num_current_queues_inside_with_clause (self):
with dppl.device_context(dppl.device_type.cpu):
self.assertEqual(dppl.get_num_activated_queues(), 1)
with dppl.device_context(dppl.device_type.gpu):
self.assertEqual(dppl.get_num_activated_queues(), 2)
self.assertEqual(dppl.get_num_activated_queues(), 0)
with dpctl.device_context(dpctl.device_type.cpu):
self.assertEqual(dpctl.get_num_activated_queues(), 1)
with dpctl.device_context(dpctl.device_type.gpu):
self.assertEqual(dpctl.get_num_activated_queues(), 2)
self.assertEqual(dpctl.get_num_activated_queues(), 0)

@unittest.skipIf(not dppl.has_gpu_queues(), "No GPU platforms available")
@unittest.skipIf(not dppl.has_cpu_queues(), "No CPU platforms available")
@unittest.skipIf(not dpctl.has_gpu_queues(), "No GPU platforms available")
@unittest.skipIf(not dpctl.has_cpu_queues(), "No CPU platforms available")
def test_num_current_queues_inside_threads (self):
from threading import Thread, local
def SessionThread (self):
self.assertEqual(dppl.get_num_activated_queues(), 0)
with dppl.device_context(dppl.device_type.gpu):
self.assertEqual(dppl.get_num_activated_queues(), 1)
self.assertEqual(dpctl.get_num_activated_queues(), 0)
with dpctl.device_context(dpctl.device_type.gpu):
self.assertEqual(dpctl.get_num_activated_queues(), 1)

Session1 = Thread(target=SessionThread(self))
Session2 = Thread(target=SessionThread(self))
with dppl.device_context(dppl.device_type.cpu):
self.assertEqual(dppl.get_num_activated_queues(), 1)
with dpctl.device_context(dpctl.device_type.cpu):
self.assertEqual(dpctl.get_num_activated_queues(), 1)
Session1.start()
Session2.start()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##===---------- test_sycl_queue_manager.py - dppl -------*- Python -*-----===##
##===---------- test_sycl_queue_manager.py - dpctl -------*- Python -*-----===##
##
## Python Data Parallel Processing Library (PyDPPL)
##
Expand All @@ -19,21 +19,21 @@
##===----------------------------------------------------------------------===##

import unittest
import dppl
from dppl._memory import MemoryUSMShared, MemoryUSMHost, MemoryUSMDevice
import dpctl
from dpctl._memory import MemoryUSMShared, MemoryUSMHost, MemoryUSMDevice


class TestMemory (unittest.TestCase):

def test_memory_create (self):
nbytes = 1024
queue = dppl.get_current_queue()
queue = dpctl.get_current_queue()
mobj = MemoryUSMShared(nbytes, queue)
self.assertEqual(mobj.nbytes, nbytes)

def _create_memory (self):
nbytes = 1024
queue = dppl.get_current_queue()
queue = dpctl.get_current_queue()
mobj = MemoryUSMShared(nbytes, queue)
return mobj

Expand All @@ -43,33 +43,33 @@ def test_memory_without_context (self):
# Without context
self.assertEqual(mobj._usm_type(), 'shared')

@unittest.skipIf(not dppl.has_cpu_queues(), "No CPU platforms available")
@unittest.skipIf(not dpctl.has_cpu_queues(), "No CPU platforms available")
def test_memory_cpu_context (self):
mobj = self._create_memory()

# CPU context
with dppl.device_context(dppl.device_type.cpu):
with dpctl.device_context(dpctl.device_type.cpu):
# type respective to the context in which
# memory was created
usm_type = mobj._usm_type()
self.assertEqual(usm_type, 'shared')

current_queue = dppl.get_current_queue()
current_queue = dpctl.get_current_queue()
# type as view from current queue
usm_type = mobj._usm_type(current_queue)
# type can be unknown if current queue is
# not in the same SYCL context
self.assertTrue(usm_type in ['unknown', 'shared'])

@unittest.skipIf(not dppl.has_gpu_queues(), "No GPU platforms available")
@unittest.skipIf(not dpctl.has_gpu_queues(), "No GPU platforms available")
def test_memory_gpu_context (self):
mobj = self._create_memory()

# GPU context
with dppl.device_context(dppl.device_type.gpu):
with dpctl.device_context(dpctl.device_type.gpu):
usm_type = mobj._usm_type()
self.assertEqual(usm_type, 'shared')
current_queue = dppl.get_current_queue()
current_queue = dpctl.get_current_queue()
usm_type = mobj._usm_type(current_queue)
self.assertTrue(usm_type in ['unknown', 'shared'])

Expand All @@ -81,7 +81,7 @@ class TestMemoryUSMBase:
usm_type = None

def test_create_with_queue (self):
q = dppl.get_current_queue()
q = dpctl.get_current_queue()
m = self.MemoryUSMClass(1024, q)
self.assertEqual(m.nbytes, 1024)
self.assertEqual(m._usm_type(), self.usm_type)
Expand Down
Loading