Skip to content

Commit 32c7c40

Browse files
author
Diptorup Deb
committed
Merge tag '0.21.0dev0' into gold/2021
2 parents 8070499 + 68d1221 commit 32c7c40

File tree

77 files changed

+2172
-1947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2172
-1947
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
* @mingjie-intel @diptorupd
2-
31
*.yml @mingjie-intel @diptorupd
4-
52
conda-recipe/* @mingjie-intel @diptorupd
3+
numba_dpex/dpnp_iface @diptorupd @chudur-budur
4+
numba_dpex/core @diptorupd
5+
numba_dpex/core/passes/parfor_lowering_pass.py @mingjie-intel

environment/coverage.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
name: dev
22
channels:
3-
- defaults
43
- dppy/label/dev
54
- numba
65
- intel
76
- numba/label/dev
7+
- pkgs/main
88
- nodefaults
99
dependencies:
1010
- python=3.9
11+
- defaults:libffi
1112
- gxx_linux-64
1213
- dpcpp_linux-64
1314
- cython
1415
- numba 0.56*
15-
- dpctl >=0.14*
16-
- dpnp >=0.10.2
16+
- dppy/label/dev:dpctl
17+
- dppy/label/dev:dpnp
1718
- spirv-tools
1819
- dpcpp-llvm-spirv
1920
- packaging

numba_dpex/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import logging
1010
import os
1111
import platform as plt
12+
import re
13+
from typing import Tuple
1214

1315
import dpctl
1416
import llvmlite.binding as ll
@@ -59,7 +61,22 @@ def load_dpctl_sycl_interface():
5961
Vectorize.target_registry.ondemand["dpex"] = lambda: DpexVectorize
6062

6163

62-
numba_version = tuple(map(int, numba.__version__.split(".")[:3]))
64+
def parse_sem_version(version_string: str) -> Tuple[int, int, int]:
65+
"""Parse sem version into tuple of three integers. If there is a suffix like
66+
rc1, dev0 - it will be ignored."""
67+
return tuple(
68+
map(
69+
int,
70+
re.sub(
71+
"([0-9]+\\.[0-9]+\\.[0-9]+).*",
72+
"\\g<1>",
73+
version_string,
74+
).split(".")[:3],
75+
)
76+
)
77+
78+
79+
numba_version = parse_sem_version(numba.__version__)
6380
if numba_version < (0, 56, 4):
6481
logging.warning(
6582
"numba_dpex needs numba 0.56.4, using "

numba_dpex/core/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def compile_with_dpex(
8585
return_type=return_type,
8686
flags=flags,
8787
locals={},
88-
pipeline_class=OffloadCompiler,
88+
pipeline_class=KernelCompiler,
8989
)
9090
else:
9191
raise UnreachableError()

numba_dpex/core/datamodel/models.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from numba.core import datamodel, types
66
from numba.core.datamodel.models import ArrayModel as DpnpNdArrayModel
7-
from numba.core.datamodel.models import OpaqueModel, PrimitiveModel, StructModel
7+
from numba.core.datamodel.models import PrimitiveModel, StructModel
88
from numba.core.extending import register_model
99

1010
from numba_dpex.utils import address_space
@@ -54,6 +54,33 @@ def __init__(self, dmm, fe_type):
5454
super(ArrayModel, self).__init__(dmm, fe_type, members)
5555

5656

57+
class SyclQueueModel(StructModel):
58+
"""Represents the native data model for a dpctl.SyclQueue PyObject.
59+
60+
Numba-dpex uses a C struct as defined in
61+
numba_dpex/core/runtime._queuestruct.h to store the required attributes for
62+
a ``dpctl.SyclQueue`` Python object.
63+
64+
- ``queue_ref``: An opaque C pointer to an actual SYCL queue C++ object.
65+
- ``parent``: A PyObject* that stores a reference back to the original
66+
``dpctl.SyclQueue`` PyObject if the native struct is
67+
created by unboxing the PyObject.
68+
"""
69+
70+
def __init__(self, dmm, fe_type):
71+
members = [
72+
(
73+
"parent",
74+
types.CPointer(types.int8),
75+
),
76+
(
77+
"queue_ref",
78+
types.CPointer(types.int8),
79+
),
80+
]
81+
super(SyclQueueModel, self).__init__(dmm, fe_type, members)
82+
83+
5784
def _init_data_model_manager():
5885
dmm = datamodel.default_manager.copy()
5986
dmm.register(types.CPointer, GenericPointerModel)
@@ -83,6 +110,6 @@ def _init_data_model_manager():
83110
register_model(DpnpNdArray)(DpnpNdArrayModel)
84111
dpex_data_model_manager.register(DpnpNdArray, DpnpNdArrayModel)
85112

86-
# Register the DpctlSyclQueue type with Numba's OpaqueModel
87-
register_model(DpctlSyclQueue)(OpaqueModel)
88-
dpex_data_model_manager.register(DpctlSyclQueue, OpaqueModel)
113+
# Register the DpctlSyclQueue type
114+
register_model(DpctlSyclQueue)(SyclQueueModel)
115+
dpex_data_model_manager.register(DpctlSyclQueue, SyclQueueModel)

numba_dpex/core/descriptor.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
from functools import cached_property
6+
57
from numba.core import typing, utils
68
from numba.core.cpu import CPUTargetOptions
79
from numba.core.descriptors import TargetDescriptor
@@ -21,12 +23,12 @@ class DpexKernelTarget(TargetDescriptor):
2123

2224
options = CPUTargetOptions
2325

24-
@utils.cached_property
26+
@cached_property
2527
def _toplevel_target_context(self):
2628
"""Lazily-initialized top-level target context, for all threads."""
2729
return DpexKernelTargetContext(self.typing_context, self._target_name)
2830

29-
@utils.cached_property
31+
@cached_property
3032
def _toplevel_typing_context(self):
3133
"""Lazily-initialized top-level typing context, for all threads."""
3234
return DpexKernelTypingContext()
@@ -53,12 +55,12 @@ class DpexTarget(TargetDescriptor):
5355

5456
options = CPUTargetOptions
5557

56-
@utils.cached_property
58+
@cached_property
5759
def _toplevel_target_context(self):
5860
# Lazily-initialized top-level target context, for all threads
5961
return DpexTargetContext(self.typing_context, self._target_name)
6062

61-
@utils.cached_property
63+
@cached_property
6264
def _toplevel_typing_context(self):
6365
# Lazily-initialized top-level typing context, for all threads
6466
return typing.Context()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-FileCopyrightText: 2023 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
//===----------------------------------------------------------------------===//
6+
///
7+
/// \file
8+
/// A helper macro to print debug prints.
9+
///
10+
//===----------------------------------------------------------------------===//
11+
12+
#pragma once
13+
14+
/* Debugging facilities - enabled at compile-time */
15+
/* #undef NDEBUG */
16+
#if 0
17+
#include <stdio.h>
18+
#define DPEXRT_DEBUG(X) \
19+
{ \
20+
X; \
21+
fflush(stdout); \
22+
}
23+
#else
24+
#define DPEXRT_DEBUG(X) \
25+
if (0) { \
26+
X; \
27+
}
28+
#endif
29+
30+
/*
31+
* Debugging printf function used internally
32+
*/
33+
static inline void drt_debug_print(const char *fmt, ...)
34+
{
35+
va_list args;
36+
37+
va_start(args, fmt);
38+
vfprintf(stderr, fmt, args);
39+
va_end(args);
40+
}

0 commit comments

Comments
 (0)