[llvm] [libsycl] Add constructors for context (PR #214538)

Kseniya Tikhomirova via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 07:00:25 PDT 2026


================
@@ -40,6 +42,80 @@ using is_context_info_desc_t = typename is_info_desc<T, context>::return_type;
 // SYCL 2020 4.6.3. Context class
 class _LIBSYCL_EXPORT context {
 public:
+  /// @brief Constructs a SYCL context instance using an instance of
+  /// default_selector.
+  ///
+  /// @param propList SYCL properties to be associated with the context.
+  explicit context(const property_list &propList = {});
+
+  /// @brief Constructs a SYCL context instance using an instance of
+  /// device_selector.
+  ///
+  /// @param asyncHandler Async handler to be used for asynchronous error
+  /// reporting.
+  /// @param propList SYCL properties to be associated with the context.
+  explicit context(async_handler asyncHandler,
+                   const property_list &propList = {});
+
+  /// @brief Constructs a SYCL context instance using the provided device.
+  /// The context will be associated with the platform of the provided device.
+  ///
+  /// @param dev is an instance of SYCL device
+  /// @param propList SYCL properties to be associated with the context.
+  explicit context(const device &dev, const property_list &propList = {});
+
+  /// @brief Constructs a SYCL context instance using the provided device.
+  /// The context will be associated with the platform of the provided device.
+  ///
+  /// @param dev is an instance of SYCL device
+  /// @param asyncHandler Async handler to be used for asynchronous error
+  /// reporting.
+  /// @param propList SYCL properties to be associated with the context.
+  explicit context(const device &dev, async_handler asyncHandler,
+                   const property_list &propList = {});
+
+  /// @brief Constructs a SYCL context instance using the provided platform.
+  /// The context will be associated with the provided platform and with each
+  /// SYCL device that is associated with the Platform.
+  ///
+  /// @param plt is an instance of SYCL platform
+  /// @param propList SYCL properties to be associated with the context.
+  explicit context(const platform &plt, const property_list &propList = {});
+
+  /// @brief Constructs a SYCL context instance using the provided platform.
+  /// The context will be associated with the provided platform and with each
+  /// SYCL device that is associated with the Platform.
+  ///
+  /// @param plt is an instance of SYCL platform
+  /// @param asyncHandler Async handler to be used for asynchronous error
+  /// reporting.
+  /// @param propList SYCL properties to be associated with the context.
----------------
KseniyaTikhomirova wrote:

/// \throws would be nice to add. spec declares cases that trigger exception

https://github.com/llvm/llvm-project/pull/214538


More information about the llvm-commits mailing list