@@ -1237,9 +1237,11 @@ expressions that might throw `sycl::exception` and `std::runtime_error`.
1237
1237
If no exceptions are thrown, it returns ` syclcompat::error_code::SUCCESS ` .
1238
1238
If a ` sycl::exception ` is caught, it returns ` syclcompat::error_code::BACKEND_ERROR ` .
1239
1239
If a ` std::runtime_error ` exception is caught,
1240
+
1240
1241
` syclcompat::error_code::DEFAULT_ERROR ` is returned instead. For both cases, it
1241
1242
prints the error message to the standard error stream.
1242
1243
1244
+
1243
1245
``` c++
1244
1246
namespace syclcompat {
1245
1247
@@ -1268,6 +1270,7 @@ template <int Arg> class syclcompat_kernel_scalar;
1268
1270
#define SYCLCOMPAT_EXPORT
1269
1271
#endif
1270
1272
1273
+
1271
1274
namespace syclcompat {
1272
1275
enum error_code { SUCCESS = 0, BACKEND_ERROR = 1, DEFAULT_ERROR = 999 };
1273
1276
}
@@ -1287,6 +1290,15 @@ to get the kernel information. Overloads are provided to allow either returning
1287
1290
a `kernel_function_info` object, or to return by pointer argument. In the
1288
1291
current version, `kernel_function_info` describes only maximum work-group size.
1289
1292
1293
+ SYCLcompat also provides the `kernel_library` and `kernel_function` classes.
1294
+ `kernel_library` facilitates the loading and unloading of kernel libraries.
1295
+ `kernel_function` represents a specific kernel function within a loaded librariy
1296
+ and can be invoked with specified arguments.
1297
+ `load_kernel_library`, `load_kernel_library_mem`, and `unload_kernel_library` are
1298
+ free functions to handle the loading and unloading of `kernel_library` objects.
1299
+ `get_kernel_function`, and `invoke_kernel_function` offer a similar functionality
1300
+ for `kernel_function` objects.
1301
+
1290
1302
``` c++
1291
1303
namespace syclcompat {
1292
1304
@@ -1297,6 +1309,34 @@ struct kernel_function_info {
1297
1309
static void get_kernel_function_info(kernel_function_info *kernel_info,
1298
1310
const void *function);
1299
1311
static kernel_function_info get_kernel_function_info(const void *function);
1312
+
1313
+ class kernel_library {
1314
+ kernel_library();
1315
+ kernel_library(void *ptr);
1316
+ operator void *() const;
1317
+ };
1318
+
1319
+ static kernel_library load_kernel_library(const std::string &name);
1320
+ static kernel_library load_kernel_library_mem(char const *const image);
1321
+ static void unload_kernel_library(const kernel_library &library);
1322
+
1323
+ class kernel_function {
1324
+ kernel_function();
1325
+ kernel_function(kernel_functor ptr);
1326
+ operator void *() const;
1327
+ void operator()(sycl::queue &q, const sycl::nd_range<3> &range,
1328
+ unsigned int local_mem_size, void **args, void **extra);
1329
+ };
1330
+
1331
+ static kernel_function get_kernel_function(kernel_library &library,
1332
+ const std::string &name);
1333
+ static void invoke_kernel_function(kernel_function &function,
1334
+ sycl::queue &queue,
1335
+ sycl::range<3> group_range,
1336
+ sycl::range<3> local_range,
1337
+ unsigned int local_mem_size,
1338
+ void **kernel_params, void **extra);
1339
+
1300
1340
} // namespace syclcompat
1301
1341
```
1302
1342
0 commit comments