Skip to content

Commit 864a620

Browse files
committed
only events from host task has to be passed in keep_args_alive()
1 parent 05c7d77 commit 864a620

File tree

4 files changed

+69
-9
lines changed

4 files changed

+69
-9
lines changed

.github/workflows/conda-package.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ jobs:
194194
# TODO: run the whole scope once the issues on CPU are resolved
195195
- name: Run tests
196196
run: |
197-
python -m pytest -q -ra --disable-warnings -vv ${{ env.TEST_SCOPE }}
197+
python -m pytest -q -ra --disable-warnings -vv -s ${{ env.TEST_SCOPE }}
198198
working-directory: ${{ env.tests-path }}
199+
env:
200+
SYCL_QUEUE_THREAD_POOL_SIZE: 16
199201

200202
test_windows:
201203
name: Test ['windows-latest', python='${{ matrix.python }}']
@@ -331,8 +333,10 @@ jobs:
331333
# TODO: run the whole scope once the issues on CPU are resolved
332334
- name: Run tests
333335
run: |
334-
python -m pytest -q -ra --disable-warnings -vv ${{ env.TEST_SCOPE }}
336+
python -m pytest -q -ra --disable-warnings -vv -s ${{ env.TEST_SCOPE }}
335337
working-directory: ${{ env.tests-path }}
338+
env:
339+
SYCL_QUEUE_THREAD_POOL_SIZE: 16
336340

337341
upload:
338342
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']

.github/workflows/generate_coverage.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
env:
6767
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868
COVERALLS_PARALLEL: true
69+
SYCL_QUEUE_THREAD_POOL_SIZE: 6
6970

7071
coveralls:
7172
name: Indicate completion to coveralls.io

dpnp/backend/extensions/vm/CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ else()
5555
target_compile_options(${python_module_name} PRIVATE
5656
-fno-approx-func
5757
-fno-finite-math-only
58+
-no-ipo
5859
)
60+
target_link_options(${python_module_name} PRIVATE -no-ipo)
5961
endif()
6062

6163
target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel)
@@ -70,6 +72,17 @@ endif()
7072

7173
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_DPCPP)
7274

75+
target_link_libraries(${python_module_name} PUBLIC oneDPL)
76+
77+
if (UNIX)
78+
# needed for STL headers with GCC < 11
79+
target_compile_definitions(${python_module_name} PUBLIC _GLIBCXX_USE_TBB_PAR_BACKEND=0)
80+
endif()
81+
82+
target_compile_definitions(${python_module_name} PUBLIC PSTL_USE_PARALLEL_POLICIES=0)
83+
# work-around for Windows at exit crash with predefined policies
84+
target_compile_definitions(${python_module_name} PUBLIC ONEDPL_USE_PREDEFINED_POLICIES=0)
85+
7386
install(TARGETS ${python_module_name}
7487
DESTINATION "dpnp/backend/extensions/vm"
7588
)

dpnp/backend/extensions/vm/div.cpp

+49-7
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,46 @@ static sycl::event div_impl(sycl::queue exec_q,
6464
{
6565
type_utils::validate_type_for_device<T>(exec_q);
6666

67-
const T* a = reinterpret_cast<const T*>(in_a);
68-
const T* b = reinterpret_cast<const T*>(in_b);
69-
T* y = reinterpret_cast<T*>(out_y);
67+
std::cerr << "enter div_impl" << std::endl;
7068

71-
return mkl_vm::div(exec_q,
69+
const T* _a = reinterpret_cast<const T*>(in_a);
70+
const T* _b = reinterpret_cast<const T*>(in_b);
71+
T* _y = reinterpret_cast<T*>(out_y);
72+
73+
std::cerr << "casting is done" << std::endl;
74+
75+
T* a = sycl::malloc_device<T>(n, exec_q);
76+
T* b = sycl::malloc_device<T>(n, exec_q);
77+
T* y = sycl::malloc_device<T>(n, exec_q);
78+
79+
std::cerr << "malloc is done" << std::endl;
80+
81+
exec_q.copy(_a, a, n).wait();
82+
exec_q.copy(_b, b, n).wait();
83+
exec_q.copy(_y, y, n).wait();
84+
85+
std::cerr << "copy is done" << std::endl;
86+
87+
sycl::event ev = mkl_vm::div(exec_q,
7288
n, // number of elements to be calculated
7389
a, // pointer `a` containing 1st input vector of size n
7490
b, // pointer `b` containing 2nd input vector of size n
7591
y, // pointer `y` to the output vector of size n
7692
depends);
93+
ev.wait();
94+
95+
std::cerr << "div is done" << std::endl;
96+
97+
exec_q.copy(y, _y, n).wait();
98+
99+
std::cerr << "copy is done" << std::endl;
100+
101+
sycl::free(a, exec_q);
102+
sycl::free(b, exec_q);
103+
sycl::free(y, exec_q);
104+
105+
std::cerr << "leaving div_impl" << std::endl;
106+
return sycl::event();
77107
}
78108

79109
std::pair<sycl::event, sycl::event> div(sycl::queue exec_q,
@@ -175,9 +205,21 @@ std::pair<sycl::event, sycl::event> div(sycl::queue exec_q,
175205
throw py::value_error("No div implementation defined");
176206
}
177207
sycl::event sum_ev = div_fn(exec_q, src_nelems, src1_data, src2_data, dst_data, depends);
178-
179-
sycl::event ht_ev = dpctl::utils::keep_args_alive(exec_q, {src1, src2, dst}, {sum_ev});
180-
return std::make_pair(ht_ev, sum_ev);
208+
// sum_ev.wait();
209+
210+
// int* dummy = sycl::malloc_device<int>(1, exec_q);
211+
// sycl::event cleanup_ev = exec_q.submit([&](sycl::handler& cgh) {
212+
// // cgh.depends_on(sum_ev);
213+
// auto ctx = exec_q.get_context();
214+
// cgh.host_task([dummy, ctx]() {
215+
// // dummy host task to pass into keep_args_alive
216+
// sycl::free(dummy, ctx);
217+
// });
218+
// });
219+
220+
// sycl::event ht_ev = dpctl::utils::keep_args_alive(exec_q, {src1, src2, dst}, {sum_ev});
221+
// return std::make_pair(ht_ev, sum_ev);
222+
return std::make_pair(sycl::event(), sycl::event());
181223
}
182224

183225
bool can_call_div(sycl::queue exec_q,

0 commit comments

Comments
 (0)