diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 810ff00e928e4ea53867b036b6ff68d68be6fc1a..2c673fda7371ea8cc4aacf80fc354060f42628a5 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -370,9 +370,9 @@ class Program(object): from pyopencl.tools import is_spirv if is_spirv(source): - # no caching in SPIR-V case + # FIXME no caching in SPIR-V case self._context = context - self._prg = _cl._Program(context, source) + self._prg = _cl._create_program_with_il(context, source) return import sys @@ -720,6 +720,8 @@ def _add_functionality(): build_type = "From-source build" elif self.kind() == program_kind.BINARY: build_type = "From-binary build" + elif self.kind() == program_kind.IL: + build_type = "From-IL build" else: build_type = "Build" diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp index 145c0b9c264e024c93298cccf34a39fa281f331d..4892e9155c0d61967482635cdeaafbe0a35a768a 100644 --- a/src/wrap_cl.hpp +++ b/src/wrap_cl.hpp @@ -3768,7 +3768,7 @@ namespace pyopencl class program : noncopyable { public: - enum program_kind_type { KND_UNKNOWN, KND_SOURCE, KND_BINARY }; + enum program_kind_type { KND_UNKNOWN, KND_SOURCE, KND_BINARY, KND_IL }; private: cl_program m_program; @@ -4106,6 +4106,35 @@ namespace pyopencl +#if (PYOPENCL_CL_VERSION >= 0x2010) + inline + program *create_program_with_il( + context &ctx, + std::string const &src) + { + cl_int status_code; + PYOPENCL_PRINT_CALL_TRACE("clCreateProgramWithIL"); + cl_program result = clCreateProgramWithIL( + ctx.data(), src.c_str(), src.size(), &status_code); + if (status_code != CL_SUCCESS) + throw pyopencl::error("clCreateProgramWithIL", status_code); + + try + { + return new program(result, false, program::KND_IL); + } + catch (...) + { + clReleaseProgram(result); + throw; + } + } +#endif + + + + + #if PYOPENCL_CL_VERSION >= 0x1020 inline program *link_program( diff --git a/src/wrap_cl_part_2.cpp b/src/wrap_cl_part_2.cpp index edef9ab7d8ce013a80be87647af6c9e3a6b20d06..22d9f3c178ee245c0e553f4cbedc1bec83530f9d 100644 --- a/src/wrap_cl_part_2.cpp +++ b/src/wrap_cl_part_2.cpp @@ -351,6 +351,7 @@ void pyopencl_expose_part_2(py::module &m) .value("UNKNOWN", cls::KND_UNKNOWN) .value("SOURCE", cls::KND_SOURCE) .value("BINARY", cls::KND_BINARY) + .value("IL", cls::KND_IL) ; py::class_<cls>(m, "_Program", py::dynamic_attr()) @@ -405,6 +406,10 @@ void pyopencl_expose_part_2(py::module &m) ; } +#if (PYOPENCL_CL_VERSION >= 0x2010) + m.def("_create_program_with_il", create_program_with_il); +#endif + #if PYOPENCL_CL_VERSION >= 0x1020 m.def("unload_platform_compiler", unload_platform_compiler); #endif