Skip to content

Queue manager improvements [part1]: Split out SyclQueueManager from sycl_core into own file. #264

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

Merged
merged 3 commits into from
Feb 2, 2021
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
11 changes: 7 additions & 4 deletions dpctl/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""This file declares the extension types and functions for the Cython API
implemented in sycl_core.pyx.
""" This file declares the extension types and functions for the Cython API
implemented in _sycl_*.pyx files.
"""


# distutils: language = c++
# cython: language_level=3

from dpctl._sycl_core cimport *
from dpctl._sycl_context cimport *
from dpctl._sycl_device cimport *
from dpctl._sycl_event cimport *
from dpctl._sycl_queue cimport *
from dpctl._sycl_queue_manager cimport *
24 changes: 20 additions & 4 deletions dpctl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


"""
**Data Parallel Control (dpCtl)**

Expand All @@ -33,12 +32,29 @@
"""
__author__ = "Intel Corp."

from dpctl._sycl_core import *
from dpctl._sycl_core import __all__ as _sycl_core__all__
from .enum_types import *
from .enum_types import __all__ as _enum_types_all__
from dpctl._sycl_context import *
from dpctl._sycl_context import __all__ as _sycl_context__all__
from dpctl._sycl_device import *
from dpctl._sycl_device import __all__ as _sycl_device__all__
from dpctl._sycl_event import *
from dpctl._sycl_event import __all__ as _sycl_event__all__
from dpctl._sycl_queue import *
from dpctl._sycl_queue import __all__ as _sycl_queue__all__
from dpctl._sycl_queue_manager import *
from dpctl._sycl_queue_manager import __all__ as _sycl_qm__all__
from ._version import get_versions


__all__ = _sycl_core__all__
__all__ = (
_sycl_context__all__
+ _sycl_device__all__
+ _sycl_event__all__
+ _sycl_queue__all__
+ _sycl_qm__all__
+ _enum_types_all__
)


def get_include():
Expand Down
35 changes: 35 additions & 0 deletions dpctl/_sycl_context.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Data Parallel Control (dpCtl)
#
# Copyright 2020-2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# distutils: language = c++
# cython: language_level=3

""" This file declares the SyclContext extension type.
"""

from ._backend cimport DPCTLSyclContextRef
from libcpp cimport bool


cdef class SyclContext:
''' Wrapper class for a Sycl Context
'''
cdef DPCTLSyclContextRef _ctxt_ref

@staticmethod
cdef SyclContext _create (DPCTLSyclContextRef ctxt)
cpdef bool equals (self, SyclContext ctxt)
cdef DPCTLSyclContextRef get_context_ref (self)
67 changes: 67 additions & 0 deletions dpctl/_sycl_context.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Data Parallel Control (dpCtl)
#
# Copyright 2020-2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# distutils: language = c++
# cython: language_level=3

""" Implements SyclContext Cython extension type.
"""

from __future__ import print_function
import logging
from ._backend cimport (
DPCTLSyclContextRef,
DPCTLContext_Delete,
DPCTLContext_AreEq,
)

__all__ = [
"SyclContext",
]

_logger = logging.getLogger(__name__)


cdef class SyclContext:
""" Python wrapper class for cl::sycl::context.
"""
@staticmethod
cdef SyclContext _create (DPCTLSyclContextRef ctxt):
cdef SyclContext ret = SyclContext.__new__(SyclContext)
ret._ctxt_ref = ctxt
return ret

def __dealloc__ (self):
DPCTLContext_Delete(self._ctxt_ref)

cpdef bool equals (self, SyclContext ctxt):
""" Returns true if the SyclContext argument has the same _context_ref
as this SyclContext.
"""
return DPCTLContext_AreEq(self._ctxt_ref, ctxt.get_context_ref())

cdef DPCTLSyclContextRef get_context_ref (self):
return self._ctxt_ref

def addressof_ref (self):
"""
Returns the address of the DPCTLSyclContextRef pointer as a size_t.

Returns:
The address of the DPCTLSyclContextRef object used to create this
SyclContext cast to a size_t.
"""
return int(<size_t>self._ctx_ref)
Loading