Skip to content

Commit 4501644

Browse files
authored
Merge pull request #348 from IntelPython/fix/private_arrays
Changes to private array declarations to use new API in dpex
2 parents 2fb19c0 + 35ee147 commit 4501644

File tree

11 files changed

+23
-22
lines changed

11 files changed

+23
-22
lines changed

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build:
1717
requirements:
1818
build:
1919
- {{ compiler('cxx') }}
20-
- {{ compiler('dpcpp') }} ==2024.0.0 # [not osx]
20+
- {{ compiler('dpcpp') }}
2121
- sysroot_linux-64 >=2.28 # [linux]
2222
host:
2323
- python

dpbench/benchmarks/default/gpairs/gpairs_numba_dpex_k.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def count_weighted_pairs_3d_intel_no_slm_ker(
3838

3939
n_wi = 32
4040

41-
dsq_mat = dpex.private.array(shape=(32 * 32), dtype=dtype)
42-
w0_vec = dpex.private.array(shape=(32), dtype=dtype)
43-
w1_vec = dpex.private.array(shape=(32), dtype=dtype)
41+
dsq_mat = kapi.PrivateArray(shape=(32 * 32), dtype=dtype)
42+
w0_vec = kapi.PrivateArray(shape=(32), dtype=dtype)
43+
w1_vec = kapi.PrivateArray(shape=(32), dtype=dtype)
4444

4545
offset0 = gr0 * n_wi * lws0 + lid0
4646
offset1 = gr1 * n_wi * lws1 + lid1
@@ -80,7 +80,7 @@ def count_weighted_pairs_3d_intel_no_slm_ker(
8080

8181
# update slm_hist. Use work-item private buffer of 16 tfloat elements
8282
for k in range(0, slm_hist_size, private_hist_size):
83-
private_hist = dpex.private.array(shape=(32), dtype=dtype)
83+
private_hist = kapi.PrivateArray(shape=(32), dtype=dtype)
8484
for p in range(private_hist_size):
8585
private_hist[p] = 0.0
8686

dpbench/benchmarks/default/kmeans/kmeans_numba_dpex_k.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def groupByCluster(
5656
for i in range(WorkPI):
5757
point_id = grid * WorkPI * local_size + i * local_size + lid
5858
if point_id < numpoints:
59-
localP = dpex.private.array(dims, dtyp)
59+
localP = kapi.PrivateArray(dims, dtyp)
6060
for d in range(dims):
6161
localP[d] = arrayP[point_id, d]
6262

@@ -179,7 +179,7 @@ def updateLabels(
179179
for i in range(WorkPI):
180180
point_id = grid * WorkPI * local_size + i * local_size + lid
181181
if point_id < numpoints:
182-
localP = dpex.private.array(dims, dtyp)
182+
localP = kapi.PrivateArray(dims, dtyp)
183183
for d in range(dims):
184184
localP[d] = arrayP[point_id, d]
185185

dpbench/benchmarks/default/knn/knn_initialize.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def _gen_data_x(ip_size, data_dim, seed, dtype):
2424

2525
def _gen_data_y(ip_size, classes_num, seed):
2626
default_rng.seed(seed)
27-
data = default_rng.randint(classes_num, size=ip_size)
27+
data = default_rng.randint(
28+
classes_num, size=ip_size, dtype=types_dict["int"]
29+
)
2830
return data
2931

3032
def _gen_train_data(train_size, data_dim, classes_num, seed_train, dtype):

dpbench/benchmarks/default/knn/knn_numba_dpex_k.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _knn_kernel( # noqa: C901: TODO: can we simplify logic?
2525
dtype = train.dtype
2626
i = item.get_id(0)
2727
# here k has to be 5 in order to match with numpy
28-
queue_neighbors = dpex.private.array(shape=(5, 2), dtype=dtype)
28+
queue_neighbors = kapi.PrivateArray(shape=(5, 2), dtype=dtype)
2929

3030
for j in range(k):
3131
x1 = train[j]

dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
template <typename FpTy, typename IntTy> class theKernel;
99

10-
template <typename FpTy> struct neighbors
10+
template <typename FpTy, typename IntTy> struct neighbors
1111
{
1212
FpTy dist;
13-
size_t label;
13+
IntTy label;
1414
};
1515

1616
template <typename FpTy, typename IntTy>
1717
sycl::event knn_impl(sycl::queue q,
1818
FpTy *d_train,
19-
size_t *d_train_labels,
19+
IntTy *d_train_labels,
2020
FpTy *d_test,
2121
size_t k,
2222
size_t classes_num,
@@ -33,7 +33,7 @@ sycl::event knn_impl(sycl::queue q,
3333

3434
// here k has to be 5 in order to match with numpy no. of
3535
// neighbors
36-
struct neighbors<FpTy> queue_neighbors[5];
36+
struct neighbors<FpTy, IntTy> queue_neighbors[5];
3737

3838
// count distances
3939
for (size_t j = 0; j < k; ++j) {
@@ -54,7 +54,7 @@ sycl::event knn_impl(sycl::queue q,
5454
for (size_t j = 0; j < k; ++j) {
5555
// push queue
5656
FpTy new_distance = queue_neighbors[j].dist;
57-
FpTy new_neighbor_label = queue_neighbors[j].label;
57+
IntTy new_neighbor_label = queue_neighbors[j].label;
5858
size_t index = j;
5959
while (index > 0 &&
6060
new_distance < queue_neighbors[index - 1].dist)
@@ -83,7 +83,7 @@ sycl::event knn_impl(sycl::queue q,
8383

8484
// push queue
8585
FpTy new_distance = queue_neighbors[k - 1].dist;
86-
FpTy new_neighbor_label = queue_neighbors[k - 1].label;
86+
IntTy new_neighbor_label = queue_neighbors[k - 1].label;
8787
size_t index = k - 1;
8888

8989
while (index > 0 &&

dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void knn_sync(dpctl::tensor::usm_ndarray x_train,
4343
if (typenum == UAR_FLOAT) {
4444
sycl::event res_ev = knn_impl<float, unsigned int>(
4545
x_train.get_queue(), x_train.get_data<float>(),
46-
y_train.get_data<size_t>(), x_test.get_data<float>(), k,
46+
y_train.get_data<unsigned int>(), x_test.get_data<float>(), k,
4747
classes_num, train_size, test_size,
4848
predictions.get_data<unsigned int>(),
4949
votes_to_classes.get_data<float>(), data_dim);

dpbench/configs/framework_info/dpcpp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ postfix = "dpcpp"
1010
class = "DpcppFramework"
1111
arch = "cpu"
1212
sycl_device = "cpu"
13-
dpcpp_version = "IntelLLVM 2024.0.0"
13+
dpcpp_version = "IntelLLVM 2024.1.0"
1414

1515
[[framework.postfixes]]
1616
impl_postfix = "sycl"

dpbench/infrastructure/frameworks/dpcpp_framework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _copy_to_func_impl(ref_array):
5959
else:
6060
order = "K"
6161
return dpt.asarray(
62-
obj=ref_array,
62+
ref_array,
6363
dtype=ref_array.dtype,
6464
device=self.sycl_device,
6565
copy=None,

environments/conda-linux-sycl.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ dependencies:
2323
- dpctl
2424
- dpnp
2525
- numba-dpex
26-
# TODO: fix issues on conda-forge build
27-
- intel::dpcpp_linux-64==2024.0.0
28-
- intel::dpcpp-cpp-rt==2024.0.0
26+
- intel::dpcpp_linux-64
27+
- intel::dpcpp-cpp-rt
2928
- cython
3029
- cmake
3130
- ninja

0 commit comments

Comments
 (0)