Skip to content

Commit 0a7524b

Browse files
committed
fix default values
1 parent 76bb60d commit 0a7524b

2 files changed

Lines changed: 42 additions & 5 deletions

File tree

dpctl/program/_program.pyx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,20 +671,21 @@ cpdef create_kernel_bundle_from_sycl_source(SyclQueue q,
671671
:class:`.SyclKernelBundle` is going to be built.
672672
source (unicode)
673673
SYCL source code string.
674-
headers (list)
674+
headers (list, optional)
675675
Optional list of virtual headers, where each entry in the list
676676
needs to be a tuple of header name and header content. See the
677677
documentation of the ``include_files`` property in the DPC++
678678
``kernel_compiler`` extension for more information.
679-
Default: []
679+
Default: ``None``
680680
registered_names (list, optional)
681681
Optional list of kernel names to register. See the
682682
documentation of the ``registered_names`` property in the DPC++
683683
``kernel_compiler`` extension for more information.
684-
Default: []
685-
copts (list)
684+
Default: ``None``
685+
copts (list, optional)
686686
Optional list of compilation flags that will be used
687-
when compiling the program. Default: ``""``.
687+
when compiling the program.
688+
Default: ``None``
688689
689690
Returns:
690691
kernel_bundle (:class:`.SyclKernelBundle`)
@@ -710,6 +711,14 @@ cpdef create_kernel_bundle_from_sycl_source(SyclQueue q,
710711
cdef bytes bContent
711712
cdef const char* sContent
712713
cdef const char* buildLogContent
714+
715+
if headers is None:
716+
headers = []
717+
if registered_names is None:
718+
registered_names = []
719+
if copts is None:
720+
copts = []
721+
713722
for opt in copts:
714723
if not isinstance(opt, unicode):
715724
DPCTLBuildOptionList_Delete(BuildOpts)

dpctl/tests/test_sycl_program.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,34 @@ def test_sycl_source_compilation_is_available_returns_bool():
570570
assert type(v) is bool
571571

572572

573+
@pytest.mark.parametrize(
574+
"queue_selector", [_get_opencl_queue_or_skip, _get_level_zero_queue_or_skip]
575+
)
576+
def test_create_kernel_bundle_from_sycl_source_defaults(queue_selector):
577+
q = queue_selector()
578+
_skip_if_no_sycl_source_compilation(q)
579+
580+
sycl_source = """
581+
#include <sycl/sycl.hpp>
582+
583+
namespace syclext = sycl::ext::oneapi::experimental;
584+
585+
extern "C" SYCL_EXTERNAL
586+
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclext::nd_range_kernel<1>))
587+
void vector_add(int* in1, int* in2, int* out){
588+
sycl::nd_item<1> item =
589+
sycl::ext::oneapi::this_work_item::get_nd_item<1>();
590+
size_t globalID = item.get_global_linear_id();
591+
out[globalID] = in1[globalID] + in2[globalID];
592+
}
593+
"""
594+
595+
prog = dpctl.program.create_kernel_bundle_from_sycl_source(q, sycl_source)
596+
597+
assert type(prog) is dpctl_prog.SyclKernelBundle
598+
assert prog.has_sycl_kernel("vector_add")
599+
600+
573601
@pytest.mark.parametrize(
574602
"queue_selector", [_get_opencl_queue_or_skip, _get_level_zero_queue_or_skip]
575603
)

0 commit comments

Comments
 (0)