Skip to content

Commit 609c8fd

Browse files
authored
Queue manager improvements [part1]: Split out SyclQueueManager from sycl_core into own file. (#264)
* Split out SyclQueueManager from sycl_core into own file. * Refactor SyclQueue and SyclDevice into separate source files. * Refactors all Sycl* Cython classes into separate pyx files.
1 parent 0763b21 commit 609c8fd

19 files changed

+1478
-1161
lines changed

dpctl/__init__.pxd

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
"""This file declares the extension types and functions for the Cython API
18-
implemented in sycl_core.pyx.
17+
""" This file declares the extension types and functions for the Cython API
18+
implemented in _sycl_*.pyx files.
1919
"""
2020

21-
2221
# distutils: language = c++
2322
# cython: language_level=3
2423

25-
from dpctl._sycl_core cimport *
24+
from dpctl._sycl_context cimport *
25+
from dpctl._sycl_device cimport *
26+
from dpctl._sycl_event cimport *
27+
from dpctl._sycl_queue cimport *
28+
from dpctl._sycl_queue_manager cimport *

dpctl/__init__.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
1817
"""
1918
**Data Parallel Control (dpCtl)**
2019
@@ -33,12 +32,29 @@
3332
"""
3433
__author__ = "Intel Corp."
3534

36-
from dpctl._sycl_core import *
37-
from dpctl._sycl_core import __all__ as _sycl_core__all__
35+
from .enum_types import *
36+
from .enum_types import __all__ as _enum_types_all__
37+
from dpctl._sycl_context import *
38+
from dpctl._sycl_context import __all__ as _sycl_context__all__
39+
from dpctl._sycl_device import *
40+
from dpctl._sycl_device import __all__ as _sycl_device__all__
41+
from dpctl._sycl_event import *
42+
from dpctl._sycl_event import __all__ as _sycl_event__all__
43+
from dpctl._sycl_queue import *
44+
from dpctl._sycl_queue import __all__ as _sycl_queue__all__
45+
from dpctl._sycl_queue_manager import *
46+
from dpctl._sycl_queue_manager import __all__ as _sycl_qm__all__
3847
from ._version import get_versions
3948

4049

41-
__all__ = _sycl_core__all__
50+
__all__ = (
51+
_sycl_context__all__
52+
+ _sycl_device__all__
53+
+ _sycl_event__all__
54+
+ _sycl_queue__all__
55+
+ _sycl_qm__all__
56+
+ _enum_types_all__
57+
)
4258

4359

4460
def get_include():

dpctl/_sycl_context.pxd

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Data Parallel Control (dpCtl)
2+
#
3+
# Copyright 2020-2021 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# distutils: language = c++
18+
# cython: language_level=3
19+
20+
""" This file declares the SyclContext extension type.
21+
"""
22+
23+
from ._backend cimport DPCTLSyclContextRef
24+
from libcpp cimport bool
25+
26+
27+
cdef class SyclContext:
28+
''' Wrapper class for a Sycl Context
29+
'''
30+
cdef DPCTLSyclContextRef _ctxt_ref
31+
32+
@staticmethod
33+
cdef SyclContext _create (DPCTLSyclContextRef ctxt)
34+
cpdef bool equals (self, SyclContext ctxt)
35+
cdef DPCTLSyclContextRef get_context_ref (self)

dpctl/_sycl_context.pyx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Data Parallel Control (dpCtl)
2+
#
3+
# Copyright 2020-2021 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# distutils: language = c++
18+
# cython: language_level=3
19+
20+
""" Implements SyclContext Cython extension type.
21+
"""
22+
23+
from __future__ import print_function
24+
import logging
25+
from ._backend cimport (
26+
DPCTLSyclContextRef,
27+
DPCTLContext_Delete,
28+
DPCTLContext_AreEq,
29+
)
30+
31+
__all__ = [
32+
"SyclContext",
33+
]
34+
35+
_logger = logging.getLogger(__name__)
36+
37+
38+
cdef class SyclContext:
39+
""" Python wrapper class for cl::sycl::context.
40+
"""
41+
@staticmethod
42+
cdef SyclContext _create (DPCTLSyclContextRef ctxt):
43+
cdef SyclContext ret = SyclContext.__new__(SyclContext)
44+
ret._ctxt_ref = ctxt
45+
return ret
46+
47+
def __dealloc__ (self):
48+
DPCTLContext_Delete(self._ctxt_ref)
49+
50+
cpdef bool equals (self, SyclContext ctxt):
51+
""" Returns true if the SyclContext argument has the same _context_ref
52+
as this SyclContext.
53+
"""
54+
return DPCTLContext_AreEq(self._ctxt_ref, ctxt.get_context_ref())
55+
56+
cdef DPCTLSyclContextRef get_context_ref (self):
57+
return self._ctxt_ref
58+
59+
def addressof_ref (self):
60+
"""
61+
Returns the address of the DPCTLSyclContextRef pointer as a size_t.
62+
63+
Returns:
64+
The address of the DPCTLSyclContextRef object used to create this
65+
SyclContext cast to a size_t.
66+
"""
67+
return int(<size_t>self._ctx_ref)

0 commit comments

Comments
 (0)