Skip to content

Commit 60eaeb7

Browse files
author
Diptorup Deb
committed
Update examples to latest code base.
- Replace NumPy with dpnp for kernel arguments. - Remove the use of dpctl.device_context
1 parent c4baacd commit 60eaeb7

File tree

15 files changed

+98
-244
lines changed

15 files changed

+98
-244
lines changed

.github/workflows/conda-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
source $CONDA/etc/profile.d/conda.sh
149149
conda activate numba_dpex_env
150150
# echo "libintelocl.so" | tee /etc/OpenCL/vendors/intel-cpu.icd
151-
for script in $(find . \( -not -name "_*" -not -name "vector_sum2D.py" -not -name "vectorize.py" -not -name "scan.py" -and -name "*.py" \))
151+
for script in $(find . \( -not -name "_*" -not -name "side-by-side*" -not -name "vectorize.py" -not -name "scan.py" -and -name "*.py" \))
152152
do
153153
echo "Executing ${script}"
154154
python ${script} || exit 1

numba_dpex/examples/auto_offload_examples/sum-1d.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

numba_dpex/examples/auto_offload_examples/sum-2d.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

numba_dpex/examples/debug/dpex_func.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
import dpctl
6-
import numpy as np
6+
import dpnp as np
77

88
import numba_dpex as ndpx
99

@@ -37,14 +37,7 @@ def main():
3737
b = np.arange(N, dtype=np.float32)
3838
c = np.empty_like(a)
3939

40-
# Use the environment variable SYCL_DEVICE_FILTER to change the default device.
41-
# See https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md#sycl_device_filter.
42-
device = dpctl.select_default_device()
43-
print("Using device ...")
44-
device.print_device_info()
45-
46-
with dpctl.device_context(device):
47-
driver(a, b, c, global_size)
40+
driver(a, b, c, global_size)
4841

4942
print("Done...")
5043

numba_dpex/examples/debug/njit_basic.py

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

5-
from numba import njit
5+
from numba_dpex import dpjit
66

77

8-
@njit(debug=True)
8+
@dpjit(debug=True)
99
def foo(arg):
1010
l1 = arg + 6
1111
l2 = arg * 5.43
@@ -14,8 +14,7 @@ def foo(arg):
1414

1515

1616
def main():
17-
result = foo(987)
18-
print(result)
17+
foo(987)
1918

2019

2120
if __name__ == "__main__":

numba_dpex/examples/debug/simple_dpex_func.py

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

5-
import dpctl
6-
import numpy as np
5+
import dpnp as np
76

87
import numba_dpex as ndpx
98

@@ -25,8 +24,6 @@ def kernel_sum(a_in_kernel, b_in_kernel, c_in_kernel):
2524
b = np.arange(global_size, dtype=np.float32)
2625
c = np.empty_like(a)
2726

28-
device = dpctl.select_default_device()
29-
with dpctl.device_context(device):
30-
kernel_sum[ndpx.Range(global_size)](a, b, c)
27+
kernel_sum[ndpx.Range(global_size)](a, b, c)
3128

3229
print("Done...")

numba_dpex/examples/debug/simple_sum.py

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

55
import dpctl
6-
import numpy as np
6+
import dpnp as np
77

88
import numba_dpex as ndpx
99

@@ -21,8 +21,6 @@ def data_parallel_sum(a, b, c):
2121
b = np.array(np.random.random(N), dtype=np.float32)
2222
c = np.ones_like(a)
2323

24-
device = dpctl.select_default_device()
25-
with dpctl.device_context(device):
26-
data_parallel_sum[ndpx.Range(global_size)](a, b, c)
24+
data_parallel_sum[ndpx.Range(global_size)](a, b, c)
2725

2826
print("Done...")

numba_dpex/examples/debug/sum.py

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

5-
import dpctl
6-
import numpy as np
5+
import dpnp as np
76

87
import numba_dpex as ndpx
98

@@ -32,14 +31,7 @@ def main():
3231
b = np.arange(N, dtype=np.float32)
3332
c = np.empty_like(a)
3433

35-
# Use the environment variable SYCL_DEVICE_FILTER to change the default device.
36-
# See https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md#sycl_device_filter.
37-
device = dpctl.select_default_device()
38-
print("Using device ...")
39-
device.print_device_info()
40-
41-
with dpctl.device_context(device):
42-
driver(a, b, c, global_size)
34+
driver(a, b, c, global_size)
4335

4436
print("Done...")
4537

numba_dpex/examples/debug/sum_local_vars.py

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

55
import dpctl
6-
import numpy as np
6+
import dpnp as np
77

88
import numba_dpex as ndpx
99

@@ -23,8 +23,6 @@ def data_parallel_sum(a, b, c):
2323
b = np.array(np.random.random(N), dtype=np.float32)
2424
c = np.ones_like(a)
2525

26-
device = dpctl.select_default_device()
27-
with dpctl.device_context(device):
28-
data_parallel_sum[ndpx.Range(global_size)](a, b, c)
26+
data_parallel_sum[ndpx.Range(global_size)](a, b, c)
2927

3028
print("Done...")

numba_dpex/examples/debug/sum_local_vars_revive.py

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

5-
import dpctl
6-
import numpy as np
5+
import dpnp as np
76

87
import numba_dpex as ndpx
98

@@ -29,8 +28,6 @@ def data_parallel_sum(a, b, c):
2928
b = np.array(np.random.random(N), dtype=np.float32)
3029
c = np.ones_like(a)
3130

32-
device = dpctl.select_default_device()
33-
with dpctl.device_context(device):
34-
data_parallel_sum[ndpx.Range(global_size)](a, b, c)
31+
data_parallel_sum[ndpx.Range(global_size)](a, b, c)
3532

3633
print("Done...")

0 commit comments

Comments
 (0)